GetPickupAmount: Difference between revisions

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


===Returns===
===Returns===
Returns an ''integer'' of the amount the pickup is set to, ''false'' if it's invalid.
Returns an ''integer'' of the amount the pickup is set to, ''false'' if it's invalid or 0 if it's no health or amor pickup.


==Example==  
==Example==  

Revision as of 15:49, 29 July 2007

This function retreives the amount of health or armour given from a pickup.

Syntax

int getPickupAmount ( pickup thePickup )        

Required Arguments

  • thePickup: The pickup you wish to retrieve the amount from.

Returns

Returns an integer of the amount the pickup is set to, false if it's invalid or 0 if it's no health or amor pickup.

Example

This example outputs the amount of health a player picked up.

function onPickupHitFunction ( thePlayer ) --when someone hits a pickup
    if getPickupType ( source ) == 0 then --check the type of pickup, if it is a health pickup then
        amount = getPickupAmount ( source )
        outputChatBox("You picked up "..amount.." health", thePlayer)
    end
end
addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunction ) --add an event handler for onPickupHit 

See Also