GetPickupAmount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 4: Line 4:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPickupAmount ( pickup pickup )         
float getPickupAmount ( pickup pickup )         
</syntaxhighlight>  
</syntaxhighlight>  



Revision as of 10:54, 28 November 2006

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

Syntax

float getPickupAmount ( pickup pickup )        

Required Arguments

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

Returns

Returns an integer of the amount the pickup is set to.

Example

This example takes a player's money appropriately according to the amount of heakth he 'buys'.

addEventHandler ( "onPickupHit", root, "onPickupHit" ) --add an event handler for onPickupHit
function onPickupHit ( player ) --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 )
        takePlayerMoney ( player, amount ) -- take the player's money according to the amount in the pickup
    end
end

See Also