Пређи на главни садржај

NPC_Respawn

warning

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description​

Respawns an NPC to their spawn position, resetting their state.

NameDescription
npcidThe ID of the NPC.

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/respawnnpc", true))
{
new npcid = PlayerNPC[playerid];

if (!NPC_IsValid(npcid))
{
SendClientMessage(playerid, 0xFF0000FF, "You don't have a valid NPC to respawn.");
return 1;
}

if (NPC_Respawn(npcid))
{
SendClientMessage(playerid, 0x00FF00FF, "Your NPC (ID %d) has been respawned.", npcid);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Failed to respawn your NPC (ID %d).", npcid);
}

return 1;
}
return 0;
}

Notes​

warning
  • Resets NPC health, position, and state.
  • NPC returns to their original spawn coordinates.
  • All current activities (movement, combat) are stopped.