GetPickupAmmo: Difference between revisions

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


__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function retreives the amount of ammo in a Weapon Pickup


==Syntax==  
==Syntax==  
Line 10: Line 10:


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''pickup:''' The pickup in which you wish to retrieve the ammo of
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns an integer of the amount of ammo in the pickup.


==Example==  
==Example==  
This example does...
This example gives extra ammo to a player if a pickup only has a small amount of ammo.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
addEventHandler ( onPickupHit, root, onPickupHit ) -- add an event for onPickupHit
blabhalbalhb --abababa
function onPickupHit ( player ) --when a pickup is hit
--This line does this...
    ammo == getPickupAmmo ( source ) --define ammo as the ammo of the pickup
mooo
    weapon == getPickupWeapon ( source ) -- define weapon as the weapon of the pickup
    if ammo < 50 then -- the ammo of hte pickup is less that 50
        giveWeaponAmmo ( player, weapon, 50 ) --then give an extra 50 ammo
    end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Pickup functions}}

Revision as of 21:09, 12 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 ) --define ammo as the ammo of the pickup
    weapon == getPickupWeapon ( source ) -- define weapon as the weapon of the pickup
    if ammo < 50 then -- the ammo of hte pickup is less that 50
        giveWeaponAmmo ( player, weapon, 50 ) --then give an extra 50 ammo
    end
end

See Also