HUNGRY:3 Posted July 4, 2015 Share Posted July 4, 2015 Hello I Have A Chat Script But...... people can spam how can i add anti spam for it? function globalMessage(thePlayer, cmd, ...) local message = table.concat ( { ... }, " " ); local name = getPlayerName(thePlayer); local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if cmd == "global" then if isPlayerMuted ( thePlayer ) then outputChatBox ("You are muted!", thePlayer, 255, 128, 22, true) return end end if isObjectInACLGroup("user." .. account, aclGetGroup("Owner")) then outputChatBox("GLOBAL - [#FF0000"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("GLOBAL - [#0000FF"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("GLOBAL - [#3ADF00"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("GLOBAL - [#5F04B4"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Supporter")) then outputChatBox("GLOBAL - [#2EFEF7"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else outputChatBox("GLOBAL - [#FFFFFF"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return end end addCommandHandler("global", globalMessage) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for index,player in pairs(getElementsByType("player")) do bindKey(player,"u", "down", "chatbox", "global") end end) addEventHandler("onPlayerJoin", root,function() bindKey(source, "u", "down", "chatbox", "global") end) Link to comment
manawydan Posted July 4, 2015 Share Posted July 4, 2015 one easy way: disable the chat for all players and enable with time local delayTime = (1*1000) -- one second local canChat = true function globalMessage(thePlayer, cmd, ...) if(canChat==false)return end canChat = false setTimer(ResetChatToOn,delayTime,1) local message = table.concat ( { ... }, " " ); local name = getPlayerName(thePlayer); local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if cmd == "global" then if isPlayerMuted ( thePlayer ) then outputChatBox ("You are muted!", thePlayer, 255, 128, 22, true) return end end if isObjectInACLGroup("user." .. account, aclGetGroup("Owner")) then outputChatBox("GLOBAL - [#FF0000"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("GLOBAL - [#0000FF"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("GLOBAL - [#3ADF00"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("GLOBAL - [#5F04B4"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else end local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Supporter")) then outputChatBox("GLOBAL - [#2EFEF7"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return else outputChatBox("GLOBAL - [#FFFFFF"..name.."#FA8258]: #FFFFFF"..message,root, 255, 255, 255, true) return end end addCommandHandler("global", globalMessage) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for index,player in pairs(getElementsByType("player")) do bindKey(player,"u", "down", "chatbox", "global") end end) addEventHandler("onPlayerJoin", root,function() bindKey(source, "u", "down", "chatbox", "global") end) function ResetChatToOn() canChat = true end Link to comment
xXMADEXx Posted July 4, 2015 Share Posted July 4, 2015 This is my chat system (that includes anti-spam) if you would like to look at it. https://github.com/braydondavis/Nerd-Ga ... server.lua Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now