GetPickupAmount

From Multi Theft Auto: Wiki
Revision as of 11:01, 28 November 2006 by JonChappell (talk | contribs) (→‎Example)
Jump to navigation Jump to search

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