• Trying to make an anti chat-spam
    5 replies, posted
I made this : hook.Add( "PlayerSay", "CommandsHAS", function( ply, text, public )     if ply.has_ChatCooldown == true then         ply:ChatPrint("Hey, please don't spam")         return ""     end end) But it's not working Any idea on how to make it work ?
Are you defining ply.has_ChatCooldown?
You don't have to check 'if bool == true/false then' you can just do 'if bool then' or 'if not bool then' for false bools. To answer your question you you should use CurTime to check when the client's last chat message was and check if ply.LastChat + delay <= CurTime().
    if ply.LastChat + 1 <= CurTime() then         ply:ChatPrint("Hey, please don't spam")         return ""     end          ply.LastChat = CurTime() This isn't working
Are you putting it in a PlayerSay hook? And I believe the source engine adds a 1 second delay between sending messages automatically so just setting a 1 second delay yourself is pointless.
My bad, I modified the message
Sorry, you need to Log In to post a reply to this thread.