GetPickupWeapon: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function | This function retrieves the Weapon ID of the Weapon Pickup | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getPickupWeapon ( pickup | int getPickupWeapon ( pickup thePickup ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''thePickup:''' The pickup in which you wish to retrieve the weapon of | ||
===Returns=== | ===Returns=== | ||
Returns an integer of the Weapon ID of the pickup | Returns an integer of the [[Weapons|Weapon ID]] of the pickup, ''false'' if it's an invalid pickup. | ||
==Example== | ==Example== | ||
This example gives extra ammo to a player if a pickup only has a small amount of ammo. | This example gives extra ammo to a player if a pickup only has a small amount of ammo. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPickupHitFunc ( player ) --when a pickup is hit | |||
function | if (getPickupType(source) == 2) then -- check if it's a weapon pickup | ||
local ammo = getPickupAmmo(source) -- get ammo | |||
if (ammo < 50) then -- if ammo is less than 50 | |||
local weapon = getPickupWeapon(source) -- store pickup weapon | |||
giveWeaponAmmo(player,weapon,50) -- give an extra 50 ammo | |||
end | |||
end | |||
end | end | ||
addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunc ) -- add an event for onPickupHit | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 21:42, 29 July 2007
This function retrieves the Weapon ID of the Weapon Pickup
Syntax
int getPickupWeapon ( pickup thePickup )
Required Arguments
- thePickup: The pickup in which you wish to retrieve the weapon of
Returns
Returns an integer of the Weapon ID of the pickup, false if it's an invalid pickup.
Example
This example gives extra ammo to a player if a pickup only has a small amount of ammo.
function onPickupHitFunc ( player ) --when a pickup is hit if (getPickupType(source) == 2) then -- check if it's a weapon pickup local ammo = getPickupAmmo(source) -- get ammo if (ammo < 50) then -- if ammo is less than 50 local weapon = getPickupWeapon(source) -- store pickup weapon giveWeaponAmmo(player,weapon,50) -- give an extra 50 ammo end end end addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunc ) -- add an event for onPickupHit
See Also
GTASA IDs (vehicles, weapons, weathers, characters, colors): http://info.vces.net/ (Special thanks to Brophy and Ratt for making these lists)