Skip to main content

OnNPCCreate

warning

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

Description​

This callback is called when an NPC is successfully created and added to the server.

NameDescription
npcidThe ID of the NPC that was created

Examples​

public OnNPCCreate(npcid)
{
printf("[NPC] NPC %d has been created", npcid);

// Notify all connected players
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
if (!IsPlayerConnected(playerid))
continue;

SendClientMessage(playerid, 0x00FF00FF, "NPC %d has been created", npcid);
}
return 1;
}

Notes​

  • This callback is called immediately after the NPC is created but before it's spawned
  • The NPC will need to be spawned using NPC_Spawn to become visible in the game world

The following functions might be useful, as they're related to this callback in one way or another.