NPC_Respawn
cảnh báo
Đã thêm hàm trong phiên bản omp v1.5.8.3079. Mục này không hoạt động trên các phiên bản cũ hơn!
Description
Respawns an NPC to their spawn position, resetting their state.
| Name | Description |
|---|---|
| npcid | The 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
ghi chú
- Resets NPC health, position, and state.
- NPC returns to their original spawn coordinates.
- All current activities (movement, combat) are stopped.
Related Functions
- NPC_Spawn: Initial spawn of NPC.
- NPC_SetPos: Set NPC position.
- NPC_GetHealth: Get NPC health.
- NPC_IsDead: Check if NPC is dead.
Related Callbacks
- OnNPCSpawn: Called when NPC spawns.
- OnNPCRespawn: Called when NPC respawns.