GetPickupAmount: Difference between revisions
Jump to navigation
Jump to search
JonChappell (talk | contribs) m (→Example) |
No edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getPickupAmount ( pickup thePickup ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''thePickup:''' The pickup you wish to retrieve the amount from. | ||
===Returns=== | ===Returns=== | ||
Returns an integer of the amount the pickup is set to. | Returns an ''integer'' of the amount the pickup is set to, ''false'' if it's invalid. | ||
==Example== | ==Example== | ||
This example | This example outputs the amount of health a player picked up. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPickupHitFunction ( player ) --when someone hits a pickup | |||
function | |||
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 | ||
amount = getPickupAmount ( source ) | amount = getPickupAmount ( source ) | ||
outputChatBox("You picked up "..amount.." health",player) | |||
end | end | ||
end | end | ||
addEventHandler ( "onPickupHit", root, onPickupHitFunction ) --add an event handler for onPickupHit | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Pickup functions}} | {{Pickup functions}} |
Revision as of 20:35, 28 July 2007
This function retreives the amount of health or armour given from a pickup.
Syntax
int getPickupAmount ( pickup thePickup )
Required Arguments
- thePickup: The pickup you wish to retrieve the amount from.
Returns
Returns an integer of the amount the pickup is set to, false if it's invalid.
Example
This example outputs the amount of health a player picked up.
function onPickupHitFunction ( 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 ) outputChatBox("You picked up "..amount.." health",player) end end addEventHandler ( "onPickupHit", root, onPickupHitFunction ) --add an event handler for onPickupHit
See Also