முதன்மை உள்ளடக்கத்துக்குச் செல்லவும்

NPC_SetHealth

எச்சரிக்கை

செயல்பாடு என்பது omp v1.5.8.3079 பதிப்பில் சேர்க்கப்பட்டது. இது முந்தைய பதிப்புகளில் இயங்காது!

Description​

Sets the health value of an NPC.

NameDescription
npcidThe ID of the NPC
healthThe health value to set

Returns​

Returns true if the health was set successfully, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/sethealth ", true, 11))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");

new Float:health = floatstr(cmdtext[11]);
if (health < 0.0 || health > 100.0)
return SendClientMessage(playerid, 0xFF0000FF, "Health must be between 0.0 and 100.0.");

NPC_SetHealth(npcid, health);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d health set to %.1f", npcid, health);

return 1;
}
return 0;
}

Notes​

  • Health values typically range from 0.0 to 100.0, but can be set higher
  • Setting health to 0.0 will kill the NPC
  • NPCs spawn with 100.0 health by default