ThePhill97 Posted January 6, 2013 Posted January 6, 2013 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?
Castillo Posted January 6, 2013 Posted January 6, 2013 By spawn weapons you mean give to the command executer the weapons? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ThePhill97 Posted January 6, 2013 Author Posted January 6, 2013 By spawn weapons you mean give to the command executer the weapons? Yes eg: /w [weaponid] [ammoamount] givesthe weapon to the executer with specified ammo or something? or /w [weaponid] give default 500 bullets for each spawn i dunno
Castillo Posted January 6, 2013 Posted January 6, 2013 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. ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ThePhill97 Posted January 6, 2013 Author Posted January 6, 2013 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?
Castillo Posted January 6, 2013 Posted January 6, 2013 A bit more? how? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ThePhill97 Posted January 6, 2013 Author Posted January 6, 2013 A bit more? how? Explain what its doing and stuff? Its just writing to me right now
Castillo Posted January 6, 2013 Posted January 6, 2013 I explained what it's doing, don't you see the comments? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ThePhill97 Posted January 6, 2013 Author Posted January 6, 2013 I explained what it's doing, don't you see the comments? Yes, but what is function ( thePlayer, _, weaponID ) Explain.. thePlayer? _?
Castillo Posted January 6, 2013 Posted January 6, 2013 thePlayer = who used the command. _ = the command name, I named the argument like this because I was not using, I could have named it anything else anyway. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ThePhill97 Posted January 6, 2013 Author Posted January 6, 2013 thePlayer = who used the command._ = the command name, I named the argument like this because I was not using, I could have named it anything else anyway. Thats cleared things up, thanks.
Castillo Posted January 6, 2013 Posted January 6, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now