How To Add Chat Interval?

I was wondering if anyone knows how to add a chat interval for Garry’s Mod. I’m trying
to make it for Dark RP so that there’s an OOC (Out-Of-Character) interval which uses
the chat commands: // and /ooc. I’ve searched the facepunch site and found something
similar but it doesn’t work for me, can anyone help me out?

ooc_interval.lua
[lua]local oldTime = CurTime();

if(CurTime() - oldTime > 10) then
//allow
end[/lua]

If you need any more details feel free to ask

Are you talking about displaying the time when the player trys to type in /OOC?
In seconds or what, because CurTime() only shows for how long the server has been running.

[lua]
function OOCTime( ply, text, public )
if (string.sub(text, 1, 2) == “//”) or (string.sub(text, 1, 4) == “/ooc”) then
local time = math.ceil(CurTime())
return time…" Seconds-- OOC: "…string.sub( text, 4 )
end
end
hook.Add( “PlayerSay”, “ooctime”, OOCTime )
[/lua]

He is trying to limit how often they can use OOC.

[lua]
function OOCTime( ply, text, public )
if (string.sub(text, 1, 2) == “//”) or (string.sub(text, 1, 4) == “/ooc”) then
if (ply.lastooc or 0) > CurTime() - 30 then //replace 30 with how long between OOCs in seconds
local time = math.ceil(CurTime())
ply.lastooc = CurTime()
return "(OOC) "…string.sub( text, 3 )
end
return false
end
end
hook.Add( “PlayerSay”, “ooctime”, OOCTime )[/lua]

Doesn’t seem to work, I’m seeing if I can try to fix it but in the mean
time here’s the code for the OOC chat command(s) so that may be useful:

[lua]
function OOC(ply, args)
if CfgVars[“ooc”] == 0 then
Notify(ply, 1, 4, “OOC is disabled”)
return “”
end

local col = team.GetColor(ply:Team())
local col2 = Color(255,255,255,255)
if not ply:Alive() then
	col2 = Color(255,200,200,255)
	col = col2
end
for k,v in pairs(player.GetAll()) do
	TalkToPerson(v, col, "(OOC) "..ply:Name(), col2, args, ply)
end
return ""

end
AddChatCommand("//", OOC, true)
AddChatCommand("/a", OOC, true)
AddChatCommand("/ooc", OOC, true)
[/lua]

EDIT:
Nevermind, just had to change
[lua]hook.Add( “PlayerSay”, “ooctime”, OOCTime )[/lua]
into
[lua]hook.Add( “PlayerSay”, “OOC”, OOCTime )[/lua]
:slight_smile: