GiveWeapon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 17: Line 17:
<syntaxhighlight lang="lua">addEventHandler ( "onSpawnpointUse", root, "onSpawnpointUse" )
<syntaxhighlight lang="lua">addEventHandler ( "onSpawnpointUse", root, "onSpawnpointUse" )
function onSpawnpointUse ( player )
function onSpawnpointUse ( player )
giveWeapon ( player, 31, 200 )
giveWeapon ( player, 31, 200 ) -- I'm giving the m4 with 200 ammo to any player that uses a spawnpoint
end</syntaxhighlight>
end</syntaxhighlight>

Revision as of 04:50, 18 May 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, weapon, [ammo=30] )

Required Arguments

  • Player: A player object referencing the specified player
  • Weapon: A whole number integer that refers to a Weapon ID

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

Example

Explain what the example does here

addEventHandler ( "onSpawnpointUse", root, "onSpawnpointUse" )
function onSpawnpointUse ( player )
giveWeapon ( player, 31, 200 ) -- I'm giving the m4 with 200 ammo to any player that uses a spawnpoint
end