Jump to content

About MTA server commands


SkatCh

Recommended Posts

hi guys please can any one help me i create a script to prevent players in my server from using server command , like start , restart , refresh , etc ... but me too i can't use them : (i'm staff ) .

i will explane my script it's server side scripte i create table with all MTA server commands eg :

Command = { 
['delaccount']      = true;  
} -- etc .... 
  
-- then i create this function : 
addEventHandler ( 'onPlayerCommand',getRootElement ( ), 
    function ( cmd ) 
        if Command [ cmd ] then 
            cancelEvent (   ); 
            kickPlayer ( source, "Command Not Allowed" ); 
        end; 
    end 
); 

so my question how can i make admin will be able to use those commands i tried many exports function : like isPlayerInTeams , isPlayerStaff but i think there is something wrong , thx fro help .

Link to comment

Commands = { 
'start', 
'stop', 
'refresh', 
'banPlayer', 
'delaccount' 
} 
  
addEventHandler ( 'onPlayerCommand',getRootElement ( ), 
function ( nCommand ) 
    for _, Max in ipairs ( Commands ) do 
     if Commands [ nCommand ] and  ( hasObjectPermissionTo ( source, "function.setServerPassword", false ) ) then 
      kickPlayer ( source, "Command Not Allowed" ); 
    end 
  end 
end 
) 

use /debugscript 3 for erros ..

Link to comment
Commands = { 
'start', 
'stop', 
'refresh', 
'banPlayer', 
'delaccount' 
} 
  
addEventHandler ( 'onPlayerCommand',getRootElement ( ), 
function ( nCommand ) 
    for _, Max in ipairs ( Commands ) do 
     if Commands [ nCommand ] and  ( hasObjectPermissionTo ( source, "function.setServerPassword", false ) ) then 
      kickPlayer ( source, "Command Not Allowed" ); 
    end 
  end 
end 
) 

use /debugscript 3 for erros ..

The loop in this wouldn't work.

Try using this:

local commands = { 
    ['start'] = true, 
    ['stop'] = true, 
    ['refresh'] = true, 
    ['banPlayer'] = true,    
    ['delaccount'] = true 
} 
  
  
addEventHandler ( "onPlayerCommand", root, function ( cmd ) 
    if ( commands [ cmd:lower() ] ) then  
        cancelEvent ( ) 
        outputChatBox ( "This command isn't allowed in the server.", source, 255, 0, 0 ) 
    end  
end ) 

Link to comment
WTF topic can be locked some stupid answers .my script is working fine just i'm asking how to make admin able to use those command without being kicked .

stupid answers ? your the one how blowed the acl groups ! and they will not be abel to use these commands , if they are not admin

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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