.:HyPeX:. Posted September 15, 2013 Share Posted September 15, 2013 Guys is there a function to detect or trigger when player does a command? i'm searching to avoid comand flooding. and also, can i detect if a player uses the say with "/command" ? (like if i can make mta or a script recognize read if on player chat it outputs the "/command" or it wont read nothing. Link to comment
Alexs Posted September 15, 2013 Share Posted September 15, 2013 'onPlayerCommand'. local commandSpam = {} function preventCommandSpam() if (not commandSpam[source]) then commandSpam[source] = 1 -- New person so add to table elseif (commandSpam[source] == 5) then cancelEvent() outputChatBox("Please refrain from command spamming!", source, 255, 0, 0) -- This person is command spamming! else commandSpam[source] = commandSpam[source] + 1 -- Add one to the table end end addEventHandler("onPlayerCommand", root, preventCommandSpam) setTimer(function() commandSpam = {} end, 1000, 0) -- Clear the table every second Link to comment
.:HyPeX:. Posted September 27, 2013 Author Share Posted September 27, 2013 Can i get Wich the command was? would this work? function StopCommands(commandname) local CommandNotSay = string.match(commandname, say) Player = getPlayerFromName( source ) if isPlayerMuted( source ) and if CommandNotSay = nil then outputchatbox ( "[AntiSpam]:"..Player.."was kicked for trying to use commands while muted!", 0, 175 ,255 ) kickPlayer( source, AntiSpam, Dont try to use commands while muted! ) addEventHandler("onPlayerCommand", getRootElement(), StopCommands) Link to comment
Castillo Posted September 27, 2013 Share Posted September 27, 2013 No, that's a mess. Link to comment
.:HyPeX:. Posted September 27, 2013 Author Share Posted September 27, 2013 i've further worked it out a bit, but i might stop here, i'm trying to get the command itself and check if its one i want to be blocked in a muted guy. local Checktable = CommandTable = {} function StopCommands(commandname) local thecommand = string.match(commandname) local Player = getPlayerFromName( source ) table.insert( CommandTable[ thecommand ] ) if isPlayerMuted( source ) and if Checktable = true then outputchatbox ( "[AntiSpam]:"..Player.."was kicked for trying to change his nick while muted!", 0, 175 ,255 ) kickPlayer( source, AntiSpam, Dont try to use commands while muted! ) end end addEventHandler("onPlayerCommand", getRootElement(), StopCommands) function(g_CheckTable) if string.match( CommandTable, me) or string.match( CommandTable, pm ) then Checktable = true end end addEventHandler("onPlayerCommand", getRootElement(), g_CheckTable) Link to comment
Castillo Posted September 27, 2013 Share Posted September 27, 2013 What are you trying to do exactly? Link to comment
.:HyPeX:. Posted September 27, 2013 Author Share Posted September 27, 2013 What are you trying to do exactly? Kick a player when he uses the /me or /pm command if he is muted. Link to comment
Castillo Posted September 27, 2013 Share Posted September 27, 2013 local disabledCmds = { [ "me" ] = true, [ "pm" ] = true } addEventHandler ( "onPlayerCommand", root, function ( cmd ) if disabledCmds [ cmd ] then if isPlayerMuted ( source ) then outputChatBox ( "[AntiSpam]: ".. getPlayerName ( source ) .." was kicked for trying to change his nick while muted!", root, 0, 175 ,255 ) kickPlayer ( source, "AntiSpam: Dont try to use commands while muted!" ) end end end ) Link to comment
.:HyPeX:. Posted September 27, 2013 Author Share Posted September 27, 2013 Thanks for the help 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