முதன்மை உள்ளடக்கத்துக்குச் செல்லவும்

NPC_SetWeapon

எச்சரிக்கை

செயல்பாடு என்பது omp v1.5.8.3079 பதிப்பில் சேர்க்கப்பட்டது. இது முந்தைய பதிப்புகளில் இயங்காது!

Description​

Sets an NPC's current weapon to a specific weapon ID.

NameDescription
npcidThe ID of the NPC
weaponThe weapon ID to set

Returns​

Returns true if the weapon was set successfully, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setweapon ", true, 11))
{
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 weaponid = strval(cmdtext[11]);
if (weaponid < 0 || weaponid > 46)
return SendClientMessage(playerid, 0xFF0000FF, "Invalid weapon ID. Must be between 0 and 46.");

NPC_SetWeapon(npcid, WEAPON:weaponid);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d weapon set to %d", npcid, weaponid);

return 1;
}
return 0;
}

Notes​

  • Setting a weapon will equip the NPC with that weapon
  • Use NPC_SetAmmo to provide ammunition for the weapon
  • Use NPC_GetWeapon to check current weapon