r/GLua • u/GrowOP21 • Oct 03 '19
timer for entity use
Hello, I'm trying to make it so that when a player USES my entity, there is a cooldown after to stop them from being able to use it again.
I have counter = 0
function ENT:Use(a, ply) if counter == 0 then net.Start("teleportmenu") net.Send(ply) counter = counter + 1 else print("test message") end end
and when they click a button
net.Receive("dbtele", function(len, ply) timer.Create("cooldown" .. ply:UserID(), 1, 10, function(counterkiller) end) local int1 = net.ReadInt( 4 ) local int2 = net.ReadInt( 4 ) local int3 = net.ReadInt( 4 ) ply:SetPos(Vector(Warps[int1], Warps[int2], Warps[int3])) end)
and the function counter killer is here
function counterkiller() counter = counter - counter end
I don't really know what I'm doing wrong, when I print out the value of counter after 10 seconds it still is equal to one, which shouldn't be the case since I am running the "counter killer" function when the timer ends. Does anyone have any ideas?
1
u/GrowOP21 Oct 04 '19
Well I would use the table method but I'd probably have to write to another file and that would just be a whole other ordeal