Passa al contenuto principale

NPC_SetWeaponState

warning

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

Description​

Sets the weapon state of an NPC.

NameDescription
npcidThe ID of the NPC
weaponStateThe weapon state to set

Returns​

Returns true on success, false on failure.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setweaponstate ", true, 16))
{
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 weaponstate = strval(cmdtext[16]);

static weaponStates[5][64] =
{
"Unknown",
"No ammo remaining",
"Single bullet left",
"More than one bullet left",
"Reloading"
};

NPC_SetWeaponState(npcid, WEAPONSTATE:weaponstate);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d weapon state set to: %s (%d)", npcid, weaponStates[weaponstate], weaponstate);
return 1;
}
return 0;
}

Notes​

  • Weapon state controls the current action of the NPC's weapon
  • Use NPC_GetWeaponState to retrieve the current state
  • Changing weapon state affects NPC shooting behavior