GetPickupAmount: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function | This function retrieves the amount of health or armor given from a pickup. | ||
==Syntax== | ==Syntax== | ||
Line 18: | Line 18: | ||
<section show="true" name="Server" class="server"> | <section show="true" name="Server" class="server"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPickupHitFunction ( thePlayer ) | function onPickupHitFunction ( thePlayer ) | ||
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", thePlayer) | outputChatBox ( "You picked up " .. amount .. " health", thePlayer) | ||
end | end | ||
end | end | ||
addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunction ) --add an event handler for onPickupHit | addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunction ) -- add an event handler for onPickupHit | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Revision as of 18:21, 19 August 2007
This function retrieves the amount of health or armor 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, 0 if it's no health or amor pickup.
Example
This example outputs the amount of health a player picked up.
Click to collapse [-]
Serverfunction onPickupHitFunction ( thePlayer ) 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", thePlayer) end end addEventHandler ( "onPickupHit", getRootElement(), onPickupHitFunction ) -- add an event handler for onPickupHit
See Also