跳到主要內容

NPC_Respawn

注意

此函式於 omp v1.5.8.3079 版本中新增,在更早的版本中無法使用!

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​

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