Jump to content

addCommandHandler


Enargy,

Recommended Posts

Hi again, I make the point about this basic function, but now I want to place a number after the command.

example:

/<cmd> <number> --- '<number>' would be a specific number 

function testing() 
outputChatBox("Hello everybody!", 0, 0, 200, true) 
end 
addCommandHandler("hi", testing) 

Someone can help me.

Link to comment

This should work, but I might have missed something since I didn't test it. Included an example for several arguments if you'd want that.

function testing(cmd, number) 
    --Example: /hi 10 would output "Hi 10" 
    outputChatBox("Hi "..tostring(number), 0, 0, 200, true) 
end 
addCommandHandler("hi", testing) 
  
-- For Server-Side you might have to add in the source as well, (source, cmd, ...). 
function testing(cmd, ...) 
local numbers = table.concat({...}, " ") 
ArrayString = split(numbers, " ") 
    outputChatBox("Hi "..ArrayString[1].." and "..ArrayString[2], 0, 0, 200, true) 
    --Example: /hi 10 20 would output "Hi 10 and 20" 
end 
addCommandHandler("hi", testing) 

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