Wait time for entities

So what I’m trying to do is when you hit e on the panel you wait 10 mins before you can use it again. Iv tried using timers but I’ve got so close and I just can’t wrap my mind around how to do this.

So these are the 2 entities.

Entity 1 (“Panel”)
Description: Hit e and it sends the networking to the NPC Block and spawns the NPCs at all the blocks.

init.lua


AddCSLuaFile("shared.lua")
include("shared.lua")

function ENT:Initialize()
	self:SetModel("models/cire992/props/locker02.mdl")
	self:SetUseType(SIMPLE_USE)
    self:SetSolid(SOLID_VPHYSICS)
	self:DropToFloor()
end

function ENT:AcceptInput(name, activator, caller)
	if name == "Use" and caller:IsPlayer() then
	print("OK")
	timer.Create("slow", 2, 1, function()
			net.Start("spawn_npcs")
			net.Send( activator )
			timer.Pause("slow")
	end)
	timer.Create("cooldown", 600, 1, function()
	timer.Start("slow")
	print("STARTING THE THING")
		end)	
	end
end

Entity 2 (“NPC Block”)
Description: When it receives the networking it spawns the NPCs at all blocks at once
init.lua


AddCSLuaFile("shared.lua")

include("shared.lua")


local CFG = CFG

function ENT:Initialize()
	self:SetModel("models/hunter/blocks/cube025x025x025.mdl")
	self:SetUseType(SIMPLE_USE)
    self:SetSolid(SOLID_BBOX)
	self:DropToFloor()
end


function ENT:Think()
net.Receive( "sending_to_server", function( len, pl )
for k, v in pairs( ents.FindByClass( "npc_block" ) ) do

    v:SetSolid(SOLID_NONE)

local npc_spawn_spot = v:GetPos()

local NPC_TRAINING_DROID = ents.Create( "npc_combine_s" )
if ( !IsValid( NPC_TRAINING_DROID ) ) then return end 
NPC_TRAINING_DROID:SetModel("models/tfa/comm/gg/npc_reb_sw_t_droid_b1.mdl")
NPC_TRAINING_DROID:Give("npc_sw_weapon_752_e5")
NPC_TRAINING_DROID:SetPos( npc_spawn_spot )
NPC_TRAINING_DROID:Spawn()

end
		end)
end



EDIT: P.S. ignore the prints they helped me see if the networking was even working and if the whole thing was coming together.

Create a variable in acceptinput in the entity’s table and set to true inside the 600 second timer and get rid of the ‘slow’ timer. There’s no point in that. Then detect if the variable is true, then allow execute the code you want and turn it back to false.

So something like this?


function AcceptInput(name, activator, caller)
	acceptinput = true
	if name == "Use" and caller:IsPlayer() then
	print("OK")

	if acceptinput == true then
			net.Start("spawn_npcs")
			net.Send( activator )

	timer.Create("cooldown", 600, 1, function()
	timervariable = true
	print("STARTING THE THING")
		end)	
	end
end

I dont want to be spoon fed but I’m not totally understanding what your saying. Im sorry.

[editline]19th October 2017[/editline]

Hopefully the thing I just did works
If this thread is closed then I use this link
https://wiki.garrysmod.com/page/Delays_and_Cooldowns
And it worked and helped me.