if ( SERVER ) then
local TAUNT_DELAY = 3 //Taunt Delay Variable
ply.LastTauntTime = 0
util.AddNetworkString("send_taunt")
net.Receive("sent_taunt",function(_, ply)
local taunt = net.ReadString()
if ply.LastTauntTime + TAUNT_DELAY <= CurTime() then
ply.LastTauntTime = CurTime()
ply.EmitSound(taunt,150)
end
end )
end
Now the thing is I want to make by default ply.LastTimeTime be 0 and also affect each player individually.
net.Receive("sent_taunt",function(_, ply)
local taunt = net.ReadString()
ply.LastTauntTime = ply.LastTauntTime or 0 // If the variable does not exist by default ( which it does not on server start ), make it 0
if ply.LastTauntTime + TAUNT_DELAY <= CurTime() then
ply.LastTauntTime = CurTime()
ply.EmitSound(taunt,150)
end
end )
[editline]2nd March 2016[/editline]
This will also cover the case where something might set the variable to nil for whatever reason.
I would make a table containing the taunt delays as values and make the taunt’s name (Or any identification form) the key, like so:
[lua]local taunt_length = {
[“taunts/props/1.wav”] = 1, //Boom Headshot!
[“taunts/props/2.wav”] = 0, //Doh!
[“taunts/props/3.wav”] = 3, //Go away, or I shall taunt you.
//And so on and so on
}[/lua]
And then use taunt_length[taunt] instead of TAUNT_DELAY
I thought this was included by default in your menu O.o