NPC_GetWeapon
注意
这个函数是在omp v1.5.8.3079中添加的,在以前的版本中不起作用!
描述
获取 NPC 当前持有的武器。
| 参数 | 说明 |
|---|---|
| npcid | NPC 的 ID |
返回值
返回 NPC 当前持有的武器 ID。
示例
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkweapon", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "你没有在调试NPC。");
if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "无效的NPC。");
new weapon = NPC_GetWeapon(npcid);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d 武器: %d", npcid, weapon);
return 1;
}
return 0;
}
注意事项
- 若 NPC 没有武器则返回 0(拳头)
- 武器 ID 与玩家武器 ID 相同
相关函数
- NPC_SetWeapon: 设置 NPC 武器
- NPC_GetAmmo: 获取 NPC 弹药
- NPC_SetAmmo: 设置 NPC 弹药
- NPC_RemoveWeapon: 移除 NPC 武器
相关回调
- ../callbacks/OnNPCWeaponShot: NPC 开火时调用