GetPickupAmmo: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
mNo edit summary  | 
				mNo edit summary  | 
				||
| Line 16: | Line 16: | ||
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">  | ||
addEventHandler ( onPickupHit, root, onPickupHit ) -- add an event for onPickupHit  | addEventHandler ( "onPickupHit", root, "onPickupHit" ) -- add an event for onPickupHit  | ||
function onPickupHit ( player ) --when a pickup is hit  | function onPickupHit ( player ) --when a pickup is hit  | ||
     ammo == getPickupAmmo ( source )    |      ammo == getPickupAmmo ( source )    | ||
Revision as of 15:48, 13 August 2006
This function retreives the amount of ammo in a Weapon Pickup
Syntax
int getPickupAmmo ( pickup pickup )
Required Arguments
- pickup: The pickup in which you wish to retrieve the ammo of
 
Returns
Returns an integer of the amount of ammo in the pickup.
Example
This example gives extra ammo to a player if a pickup only has a small amount of ammo.
addEventHandler ( "onPickupHit", root, "onPickupHit" ) -- add an event for onPickupHit
function onPickupHit ( player ) --when a pickup is hit
    ammo == getPickupAmmo ( source ) 
    weapon == getPickupWeapon ( source ) -- define weapon as the weapon of the pickup
    if ammo < 50 then -- the ammo of the pickup is less that 50
        giveWeaponAmmo ( player, weapon, 50 ) --then give an extra 50 ammo
    end
end
See Also