Jump to content

Commands


eduher

Recommended Posts

Hello who can tell me what I can function How to use DOS command to run into one of

EXAMPLE :

I have two commands

A command ( run a function)

B command (executes another function )

But I want a C- command run the A and B Command could help someone :roll:

Link to comment

Server.lua -

function functionA(player,cmd) 
end 
  
function functionB(player,cmd) 
end 
  
addCommandHandler("testa",functionA) 
addCommandHandler("testb",functionB) 
addCommandHandler("testc",{functionA,functionB}) 

Like Cody said, but you need the player,cmd inside of () on function - IF SERVERSIDE, if its clientside then just cmd inside ()

Client.lua -

function functionA(cmd) 
end 
  
function functionB(cmd) 
end 
  
addCommandHandler("testa",functionA) 
addCommandHandler("testb",functionB) 
addCommandHandler("testc",{functionA,functionB}) 

Link to comment

That's odd, I know for a fact I've seen it used before, and it for sure worked. Maybe I just have wrong format.

    addCommandHandler("testa",testfunction) 
    addCommandHandler("testb",testfunction2) 
    addCommandHandler("testc",testfunction) 
    addCommandHandler("testc",testfunction2) 

but try that I guess.

Link to comment
That's odd, I know for a fact I've seen it used before, and it for sure worked. Maybe I just have wrong format.

It's very simple it can be like this:

Method 1:

-- function A 
function functionA(player,cmd) 
   outputChatBox("test A command",player) 
end 
addCommandHandler("testa",functionA) 
  
-- function B 
function functionB(player,cmd) 
    outputChatBox("test B command",player) 
end 
addCommandHandler("testb",functionB) 
  
local functions = {functionA,functionB} 
  
for i,v in pairs(functions) do 
    addCommandHandler("testc",v) 
end 

Method 2:

function allfunctions(player,cmd) 
    if cmd == "testa" then  
        -- testa code here 
    elseif cmd == "testb" then 
        -- testb code here 
    elseif cmd == "testc" 
        -- testa code here 
        -- testb code here 
    end  
end 
addCommandHandler("testa",allfunctions) 
addCommandHandler("testb",allfunctions) 
addCommandHandler("testc",allfunctions) 

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