GetPickupAmmo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
 
No edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
{{Server client function}}
This function retrieves the amount of ammo in a weapon pickup.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPickupAmmo ( pickup pickup )         
int getPickupAmmo ( pickup thePickup )         
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''thePickup:''' The pickup in which you wish to retrieve the ammo of
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns an ''integer'' of the amount of ammo in the pickup, ''false'' if the pickup element is invalid, 0 if it's no weapon pickup.


==Example==  
==Example==  
This example does...
This example outputs a message with the picked up weapon and ammo to the player.
<section show="true" name="Server" class="server">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function onPickupHitFunction ( thePlayer )
blabhalbalhb --abababa
if getPickupType ( source ) ~= 2 then return end  -- if the pickup is no weapon, stop
--This line does this...
local ammo = getPickupAmmo ( source )              -- get the amount of ammo
mooo
local weapon = getPickupWeapon ( source )          -- get the weapon of the pickup
outputChatBox ( "You just picked up a " .. getWeaponNameFromID(weapon) .. " with " .. ammo .. " ammo", thePlayer ) -- output a message to the player
end
addEventHandler ( "onPickupHit", root, onPickupHitFunction ) -- add an event handler for onPickupHit
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Pickup functions}}

Latest revision as of 08:09, 4 November 2020

This function retrieves the amount of ammo in a weapon pickup.

Syntax

int getPickupAmmo ( pickup thePickup )         

Required Arguments

  • thePickup: The pickup in which you wish to retrieve the ammo of

Returns

Returns an integer of the amount of ammo in the pickup, false if the pickup element is invalid, 0 if it's no weapon pickup.

Example

This example outputs a message with the picked up weapon and ammo to the player.

Click to collapse [-]
Server
function onPickupHitFunction ( thePlayer )
	if getPickupType ( source ) ~= 2 then return end   -- if the pickup is no weapon, stop
	local ammo = getPickupAmmo ( source )              -- get the amount of ammo
	local weapon = getPickupWeapon ( source )          -- get the weapon of the pickup
	outputChatBox ( "You just picked up a " .. getWeaponNameFromID(weapon) .. " with " .. ammo .. " ammo", thePlayer ) -- output a message to the player
end
addEventHandler ( "onPickupHit", root, onPickupHitFunction ) -- add an event handler for onPickupHit

See Also