Anti ooc spam

im trying to make code to stop people from spaming ooc it should only be used very little this is what code i have atm i know it wont work, but you well get an idea of what i need when you see,

this function is in sv_gamemode_functions.lua
[lua]
function GM:PlayerSay(ply, text)–We will make the old hooks run AFTER DarkRP’s playersay has been run.
if ply:saidSimlar("//") then
timer.Simple(7, function()
ply:ChatPrint(“You cannot use ooc you must wait 7s untill your next message”)
end)
else

local text2 = text
local callback
text2, callback, DoSayFunc = RP_PlayerChat(ply, text2)
if tostring(text2) == " " then text2, callback = callback, text2 end
for k,v in SortedPairs(otherhooks, false) do
	if type(v) == "function" then
		text2 = v(ply, text2) or text2
	end
end
if isDedicatedServer() then
	ServerLog("\""..ply:Nick().."<"..ply:UserID()..">" .."<"..ply:SteamID()..">".."<"..team.GetName( ply:Team() )..">\" say \""..text.. "\"

")
end

if DoSayFunc then DoSayFunc(text2) return "" end
text2 = RP_ActualDoSay(ply, text2, callback) 
return ""

end)
end

end
[/lua]

[lua] if LastPrint < CurTime() + 5 then ply:PrintChat(“You have to wait 5 seconds.”, false) return false end[/lua]

Good example, I just wrote up.

[editline]11:50AM[/editline]

use lua tags.

[lua]
function GM:PlayerSay(ply, text)–We will make the old hooks run AFTER DarkRP’s playersay has been run.
if LastPrint < CurTime() + 5 then ply:PrintChat(“You have to wait 5 seconds.”, false) return false end
LastPrint = CurTime()
local text2 = text
local callback
text2, callback, DoSayFunc = RP_PlayerChat(ply, text2)
if tostring(text2) == " " then text2, callback = callback, text2 end
for k,v in SortedPairs(otherhooks, false) do
if type(v) == “function” then
text2 = v(ply, text2) or text2
end
end
if isDedicatedServer() then
ServerLog("""…ply:Nick()…"<"…ply:UserID()…">" …"<"…ply:SteamID()…">"…"<"…team.GetName( ply:Team() )…">" say “”…text… “”
")
end

if DoSayFunc then DoSayFunc(text2) return "" end
text2 = RP_ActualDoSay(ply, text2, callback) 
return ""

end
[/lua]

Haven’t tried it, I’m bit sleepy.

ok that didnt work :stuck_out_tongue: all we get is people can see the //
in the messages


if ply:saidSimlar("//") then

This isn’t E2.

Also psst, it’s ChatPrint.

Not to mention that LastPrint is global, so only one player can use OOC every 5 seconds.