跳到主要内容

NPC_Spawn

注意

这个函数是在omp v1.5.8.3079中添加的,在以前的版本中不起作用!

描述

生成 NPC 到游戏世界中,使其可见并活跃。

参数说明
npcidNPC 的 ID

返回值

如果 NPC 成功生成返回 true,否则返回 false

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/createnpc", true))
{
new name[24];
format(name, sizeof name, "Bot_%d", g_NPCCount++);

new npcid = NPC_Create(name);
if (NPC_IsValid(npcid))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

NPC_Spawn(npcid);
NPC_SetPos(npcid, x + 3.0, y, z);
NPC_SetWeapon(npcid, WEAPON_M4);
NPC_SetAmmo(npcid, 500);

PlayerNPC[playerid] = npcid;
SendClientMessage(playerid, 0x00FF00FF, "NPC %s (ID %d) 已在你附近生成!", name, npcid);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "创建NPC失败!");
}
return 1;
}
return 0;
}

注意事项

注意
  • NPC 在生成前必须通过 NPC_Create 创建。

相关函数

相关回调