Jump to content

Commandhandler question


greenops011

Recommended Posts

Hey guys. I’m working on a TP system based off the owlGaming script that was made opensourced on github. I have a question about using multiple command handlers for the same thing. Basically an alias of a command handler.

 

here is of course what the original is:

function openLocationManager(thePlayer)
    if canViewTPS(thePlayer) then
        triggerClientEvent(thePlayer, "client:openLocationManager", thePlayer, locs)
    else
        return nil
    end
end
addEvent("server:openLocationManager", true)
addEventHandler("server:openLocationManager", root, openLocationManager)
addCommandHandler("tps", openLocationManager)

Now, if I wanted to add an alias to “tps” would I have to add a second line, so like this:

function openLocationManager(thePlayer)
    if canViewTPS(thePlayer) then
        triggerClientEvent(thePlayer, "client:openLocationManager", thePlayer, locs)
    else
        return nil
    end
end
addEvent("server:openLocationManager", true)
addEventHandler("server:openLocationManager", root, openLocationManager)
addCommandHandler("tps", openLocationManager)
addCommandHandler("places", openLocationManager)

Or would I just add it as a second string like this:

function openLocationManager(thePlayer)
    if canViewTPS(thePlayer) then
        triggerClientEvent(thePlayer, "client:openLocationManager", thePlayer, locs)
    else
        return nil
    end
end
addEvent("server:openLocationManager", true)
addEventHandler("server:openLocationManager", root, openLocationManager)
addCommandHandler("tps", "places", openLocationManager)

 

Thanks in advance

Link to comment
8 hours ago, shishani said:

Hi. The second argument to addCommandHandler must be equal to the bound function.

Just add a second addCommandHandler.

 

addCommandHandler("tps", openLocationManager)
addCommandHandler("places", openLocationManager)

 

Awesome, thanks buddy. Really appreciate it :)

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