GetMyHealth: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 41: | Line 41: | ||
} | } | ||
</source>| | </source>| | ||
retval= Returns the current health of the npc as an integer.| | |||
relfuncs=*[[GetMyArmour]] | relfuncs=*[[GetMyArmour]] | ||
*[[SetMyHealth]]| | *[[SetMyHealth]]| | ||
}} | }} | ||
Revision as of 04:43, 6 September 2024
Description:
This function returns the current health of the npc as an integer.
Parameters:
NoParams
Return Values:
This function does not return any specific values.
Example
Possible implementation: The following npc uses a timer and send chat 'i need medic' when it's health goes down to 25.
timerid<-null;
function OnNPCSpawn()
{
if(!timerid) //precaution for double timers
{
SetTimer("CheckHealth",10000,1);
}
}
function CheckHealth()
{
if(AmISpawned())
{
if(GetMyHealth()<25)
{
SendChat("i need medic");
}else
{
SendChat("How you all are doing?");
}
}
}
function OnPlayerDeath(playerid)
{
if(playerid==GetMyID())
{
if(timerid)
{
KillTimer(timerid);
timerid=null;
}
}
}Related Functions
The following functions may be helpful as they relate to this function in one way or another.