GetPickupAmmo
Jump to navigation
Jump to search
This function retreives the amount of ammo in a Weapon Pickup
Syntax
int getPickupAmmo ( pickup thePickup )
Required Arguments
- thePickup: The pickup in which you wish to retrieve the ammo of
Returns
Returns an integer of the amount of ammo in the pickup, false if the pickup element is invalid, 0 if it's no weapon pickup.
Example
This example outputs a message with the picked up weapon and ammo to the player.
function onPickupHitFunction ( player ) --when a pickup is hit if (getPickupType(source) ~= 2) then return end local ammo = getPickupAmmo ( source ) local weapon = getPickupWeapon ( source ) -- define weapon as the weapon of the pickup outputChatBox("You just picked up "..getWeaponNameFromID(weapon).." with "..ammo.." ammo",player) -- output a message to the player end addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunction ) -- add an event for onPickupHit
See Also