Jump to content

OnCommand?


.:HyPeX:.

Recommended Posts

Posted

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.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

'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 

Developer @ MYVAL

  • 2 weeks later...
Posted

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) 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

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) 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

What are you trying to do exactly?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
What are you trying to do exactly?

Kick a player when he uses the /me or /pm command if he is muted.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...