Jump to content

Very basic command


ThePhill97

Recommended Posts

Hello, I'm attempting to learn MTAs 'lua' and I need an example command, I was following the WIKI, I made a spawn car command, however they didn't explain it very well and I couldn't analyse it.

Can somebody please post a easy command. EG: Spawn weapons?

and explain it in detail?

Link to comment
addCommandHandler ( "w", 
    function ( thePlayer, _, weaponID ) 
        local weaponID = tonumber ( weaponID ) -- Convert the 'weaponID' argument value to a number. 
        if ( weaponID ) then -- Check if the 'weaponID' is really a number. 
            giveWeapon ( thePlayer, weaponID, 500, true ) -- Give the weapon and set it as current to the player who used the command. 
        else -- If the 'weaponID' wasn't really a number... 
            outputChatBox ( "Specify a weapon ID.", thePlayer, 255, 0, 0 ) -- Output it to the player's chat. 
        end -- Close the 'if'. 
    end -- Close the function. 
) 

Link to comment
addCommandHandler ( "w", 
    function ( thePlayer, _, weaponID ) 
        local weaponID = tonumber ( weaponID ) -- Convert the 'weaponID' argument value to a number. 
        if ( weaponID ) then -- Check if the 'weaponID' is really a number. 
            giveWeapon ( thePlayer, weaponID, 500, true ) -- Give the weapon and set it as current to the player who used the command. 
        else -- If the 'weaponID' wasn't really a number... 
            outputChatBox ( "Specify a weapon ID.", thePlayer, 255, 0, 0 ) -- Output it to the player's chat. 
        end 
    end 
) 

Can you explain

    function ( thePlayer, _, weaponID ) 
        local weaponID = tonumber ( weaponID ) -- Convert the 'weaponID' argument value to a number. 
  

abit more?

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