Chuyển tới nội dung chính

NPC_SetPos

cảnh báo

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

Description

Sets the position of an NPC instantly without movement animation.

NameDescription
npcidThe ID of the NPC.
Float:xThe X coordinate.
Float:yThe Y coordinate.
Float:zThe Z coordinate.

Returns

Returns true on success, false on failure.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setposhere", true))
{
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:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

NPC_SetPos(npcid, x + 2.0, y, z);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d teleported to your position", npcid);

return 1;
}
return 0;
}

Notes

cảnh báo
  • This function teleports the NPC instantly without animation
  • Any current movement is stopped when setting position
  • Use NPC_Move if you want the NPC to walk to a position