Ugrás a fő tartalomhoz

NPC_SetAmmoInClip

vigyázat

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

Description​

Sets the amount of ammo in an NPC's weapon clip.

NameDescription
npcidThe ID of the NPC
ammoThe amount of ammo to set

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setammoclip ", true, 13))
{
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 ammo = strval(cmdtext[13]);
if (ammo < 0)
return SendClientMessage(playerid, 0xFF0000FF, "Ammo must be positive.");

NPC_SetAmmoInClip(npcid, ammo);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d clip ammo set to %d", npcid, ammo);

return 1;
}
return 0;
}

Notes​

  • Amount cannot exceed the weapon's maximum clip size
  • Setting to 0 will require the NPC to reload before shooting
  • Use NPC_GetAmmoInClip to check current clip amount
  • Affects only the current weapon's clip, not total ammo