SetPedOxygenLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 18: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function fillOxygen ( command )
function fillOxygen ( command )
local maxOxygen = getPedStat ( localPlayer, 225 ) * 1.5 + 1750
local maxOxygen = math.floor ( 1000 + getPedStat ( localPlayer, 22 ) * 1.5 + getPedStat ( localPlayer, 225 ) * 1.5 )
setPedOxygenLevel ( localPlayer, maxOxygen )
setPedOxygenLevel ( localPlayer, maxOxygen )
end
end
Line 24: Line 24:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}

Revision as of 06:24, 2 September 2014

This function allows you to set the oxygen level of a ped.

Syntax

bool setPedOxygenLevel ( ped thePed, float oxygen )

Required Arguments

  • thePed: the ped whose oxygen level you want to modify.
  • oxygen: the amount of oxygen you want to set on the ped. Native values are from 0 to 1000. Each of the stamina (22) and underwater stamina (225) stat maximum adds a bonus of 1500. So the maximum oxygen level is 4000.

Returns

Returns true if the oxygen level was changed succesfully. Returns false if an invalid ped and/or oxygen level was specified.

Example

Click to collapse [-]
Client

This example fills the local player's oxygen.

function fillOxygen ( command )
	local maxOxygen = math.floor ( 1000 + getPedStat ( localPlayer, 22 ) * 1.5 + getPedStat ( localPlayer, 225 ) * 1.5 )
	setPedOxygenLevel ( localPlayer, maxOxygen )
end
addCommandHandler ( "filloxygen", fillOxygen )

See Also