Difference between revisions of "GetPickupType"

From Multi Theft Auto: Wiki
(See Also)
Line 1: Line 1:
0 - health
+
__NOTOC__
1 - armor
+
This function retreives the type of a pickup, either a health, armour or weapon pickup.
2 - weapon
+
 
 +
==Syntax==
 +
<syntaxhighlight lang="lua">
 +
int getPickupType ( pickup pickup )       
 +
</syntaxhighlight>
 +
 
 +
===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'.
 +
<syntaxhighlight lang="lua">
 +
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
 +
</syntaxhighlight>
  
 
==See Also==
 
==See Also==
 
{{Pickup functions}}
 
{{Pickup functions}}

Revision as of 22:13, 12 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