Jump to content

Problem


-Doc-

Recommended Posts

How it's possible to make more than one command at this script.I can use only with single commands /cd or /rules. But i wanna for example /mute blue and its not working. Here is the code.

if string.sub(first,1,1) == "/" then 
            local command = string.sub(first,2,string.len(first)) 
            executeCommandHandler( command, thePlayer ) 

Link to comment

Just use addCommandHandler, no need to do whatever you tried to do. Use the examples, it's really simple.

playerSource: The player who triggered the command. If not triggered by a player (e.g. by admin), this will be false.

commandName: The name of the command triggered. This is useful if multiple commands go through one function.

arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below.

Quick example;

function ExampleCode(theCMD, arg1) 
    if(type(arg1) == "string") then 
        outputChatBox("Hello "...arg1) -- /Hello World will output "Hello World". /Hello Space will output "Hello Space". 
    end 
end 
addCommandHandler("Hello", ExampleCode) 

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