GetPickupAmount: Difference between revisions

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


==Example==  
==Example==  
This example takes a player's money appropriately according to the amount of heakth he 'buys'.
This example takes a player's money appropriately according to the amount of health he 'buys'.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onPickupHit", root, "onPickupHit" ) --add an event handler for onPickupHit
addEventHandler ( "onPickupHit", root, "onPickupHit" ) --add an event handler for onPickupHit

Revision as of 11:01, 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 health 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