summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/common_plantable.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-21 15:01:07 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-21 15:01:07 -0400
commitc2358c4659b5adc200a8bcd37d36b0160cc3a856 (patch)
tree86d9f1032e2365f9f05bc7096786f23d04142a69 /gamemode/itemsystem/common_plantable.lua
parentfcdc442a59841957844d3c28e134fd813ac6e9ab (diff)
downloadgmstranded-c2358c4659b5adc200a8bcd37d36b0160cc3a856.tar.gz
gmstranded-c2358c4659b5adc200a8bcd37d36b0160cc3a856.tar.bz2
gmstranded-c2358c4659b5adc200a8bcd37d36b0160cc3a856.zip
Added plant limits
Diffstat (limited to 'gamemode/itemsystem/common_plantable.lua')
-rw-r--r--gamemode/itemsystem/common_plantable.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/gamemode/itemsystem/common_plantable.lua b/gamemode/itemsystem/common_plantable.lua
index 44b491b..4db5618 100644
--- a/gamemode/itemsystem/common_plantable.lua
+++ b/gamemode/itemsystem/common_plantable.lua
@@ -18,9 +18,15 @@ local function plant(player, resourcename)
assert(tbl.GrowTime != nil,tbl.Name .. " .GrowTime is nil!")
assert(isfunction(tbl.OnGrow),tbl.Name .. " .OnGrow is not a table")
+ if(player:GetNWInt("plants") > GetConVar("gms_PlantLimit")) then
+ player:SendMessage( "You man only have " .. GetConVar("gms_PlantLimit") .. " plants at a time.", 3, Color( 10, 200, 10, 255 ) )
+ return
+ end
+
local tr = player:GetEyeTrace()
if (player:GetPos():Distance(tr.HitPos) > 180 ) then
player:SendMessage( "Too far away to plant", 3, Color( 10, 200, 10, 255 ) )
+ return
end
local pent = ents.Create("gms_generic_plantable")
@@ -29,6 +35,7 @@ local function plant(player, resourcename)
pent.OnGrow = tbl.OnGrow
pent:SetOwner(player)
pent:Spawn()
+ player.NumPlants += 1
player:DecResource( resourcename, 1 )
end
end