Jump to content

Block a command.


wannacry

Recommended Posts

I just made a script, This script effects everyone. I just want the "Staff" team not to be effected from this script.

What should I do to remove the "staff" team from this script?

 -- List of commands to disable 
cmdList = { 
    ["speaker"]=true, 
    ["superman"]=true, 
} 
  
-- Disable unwanted commands 
addEventHandler("onPlayerCommand", root, 
function(cmdName) 
     if cmdList[cmdName] then 
          cancelEvent() 
     end 
end) 

 

Link to comment
Just now, wannacry said:

I just made a script, This script effects everyone. I just want the "Staff" team not to be effected from this script.

What should I do to remove the "staff" team from this script?


 -- List of commands to disable 
cmdList = { 
    ["speaker"]=true, 
    ["superman"]=true, 
} 
  
-- Disable unwanted commands 
addEventHandler("onPlayerCommand", root, 
function(cmdName) 
     if cmdList[cmdName] then 
          cancelEvent() 
     end 
end) 

 

 


test it

 

 

commandList = { 
	["speaker"]=true, 
	["superman"]=true, 
}

function onCommand ( command ) 
	if commandList [ command ] and not ( getTeamName ( getPlayerTeam ( source ) ) == "Staff" ) then 
		cancelEvent() 
	end 
end
addEventHandler("onPlayerCommand", root, onCommand )

 

Link to comment

Or if you have a 'Staff' acl group then use this:

 -- List of commands to disable 
cmdList = { 
    ["speaker"]=true, 
    ["superman"]=true, 
} 
  
-- Disable unwanted commands 
function onPlayerCommand(cmdName)
	local accName = getAccountName(getPlayerAccount(source))
	if isObjectInACLGroup("user."..accName, aclGetGroup("Staff")) then
		return
	end
	if cmdList[cmdName] then 
		cancelEvent() 
	end 
end
addEventHandler("onPlayerCommand", root, onPlayerCommand)

 

Link to comment
6 minutes ago, Killer Project said:

 


test it

 

 


commandList = { 
	["speaker"]=true, 
	["superman"]=true, 
}

function onCommand ( command ) 
	if commandList [ command ] and not ( getTeamName ( getPlayerTeam ( source ) ) == "Staff" ) then 
		cancelEvent() 
	end 
end
addEventHandler("onPlayerCommand", root, onCommand )

 

Oh yeah, It works. Thanks for helping.

Link to comment

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...