GiveWeapon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">giveWeapon ( player, weapon, [ammo=30] )</syntaxhighlight>  
<syntaxhighlight lang="lua">giveWeapon ( player thePlayer, int weapon, [ int ammo=30, bool setAsCurrent=false] )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''Player:''' A [[player]] object referencing the specified player   
*'''thePlayer:''' A [[player]] object referencing the specified player   
*'''Weapon:''' A whole number integer that refers to a [[Weapon]] ID. Click weapon for a page with weapon ID listings.
*'''weapon:''' A whole number integer that refers to a [[Weapon]] ID. Click weapon for a page with weapon ID listings.


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''Ammo:''' A whole number integer serving as the ammo amount for the given weapon
*'''ammo:''' A whole number integer serving as the ammo amount for the given weapon
*'''setAsCurrent:''' A boolean value determining whether or not the weapon will be set as the players current.


==Example==  
==Example==  

Revision as of 16:30, 27 November 2006

giveWeapon gives a specified weapon to a certain player. There is an optional argument to specify ammunition. For example, a melee weapon doesn't need an ammo argument.

Syntax

giveWeapon ( player thePlayer, int weapon, [ int ammo=30, bool setAsCurrent=false] )

Required Arguments

  • thePlayer: A player object referencing the specified player
  • weapon: A whole number integer that refers to a Weapon ID. Click weapon for a page with weapon ID listings.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • ammo: A whole number integer serving as the ammo amount for the given weapon
  • setAsCurrent: A boolean value determining whether or not the weapon will be set as the players current.

Example

This example gives a player an M4 with 200 ammo whenever they spawn.

addEventHandler ( "onSpawnpointUse", getRootElement(), "onSpawnpointUse" )
function onSpawnpointUse ( player )
giveWeapon ( player, 31, 200 ) -- Gives the M4 weapon with 200 ammo
end

See Also