Difference between revisions of "GetPickupType"

From Multi Theft Auto: Wiki
Line 19: Line 19:
 
This example takes a player's money appropriately according to the amount of health 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
 
function onPickupHit ( player ) --when someone hits a pickup
 
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
 
     if getPickupType ( source ) == 0 then --check the type of pickup, if it is a health pickup then

Revision as of 15:49, 13 August 2006

This function retreives the type of a pickup, either a health, armour or weapon pickup.

Syntax

int getPickupType ( pickup pickup )        

Required Arguments

  • pickup: The pickup you wish to retrieve the type of

Returns

Returns an integer of the type of the pickup, which include:

  • 0: Health pickup
  • 1: Armour pickup
  • 2: Weapon pickup

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
        health = getPickupHealth ( source )
        takePlayerMoney ( player, health ) -- take the player's money according to the amount of hp points in the pickup
    end
end

See Also