1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
ITEM = {}
ITEM.Name = "Berries"
ITEM.Description = "A delicious edible!"
ITEM.Icon = "test.png"
ITEM.UniqueData = false
if(SERVER) then
util.AddNetworkString( "gms_eatberry" )
end
local eat = function(ln, player)
if(CLIENT) then
net.Start("gms_eatberry")
net.SendToServer()
end
if(SERVER) then
if(player.Resources[ITEM.Name] <= 0) then
player:SendMessage( "You don't have enough to do that!", 3, Color( 10, 200, 10, 255 ) )
return
end
startProcessGeneric(player,"Eating some berries",3,function()
player:DecResource( "Berries", 1 )
player:SendMessage( "You're a little less hungry and thirsty now.", 3, Color( 10, 200, 10, 255 ) )
--Set hunger and thirst
player:SetFood(math.Clamp(player.Hunger+100,0,1000))
player:SetThirst(math.Clamp(player.Thirst+100,0,1000))
end)
end
end
net.Receive( "gms_eatberry", eat)
local drop1 = function(player)
genericDropResource(player,ITEM.Name,1)
end
local dropall = function(player)
genericDropResource(player,ITEM.Name,9999)
end
local dropx = function(player)
print("Drop x called")
end
ITEM.Actions = {}
ITEM.Actions["EatBerry"] = eat
ITEM.Actions["Drop"] = {}
ITEM.Actions["Drop"]["Drop 1"] = drop1
ITEM.Actions["Drop"]["Drop all"] = dropall
ITEM.Actions["Drop"]["Drop X"] = dropx
GMS.RegisterResource(ITEM)
|