跳到主要内容

NPC_EnableReloading

注意

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

Description

Enables or disables automatic reloading for an NPC.

NameDescription
npcidThe ID of the NPC
enabletrue to enable reloading, false to disable

Returns

Returns true if the operation was successful, false otherwise.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/togglereload", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

new bool:reload = NPC_IsReloadEnabled(npcid);
NPC_EnableReloading(npcid, !reload);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d reloading: %s", npcid, !reload ? "Enabled" : "Disabled");

return 1;
}
return 0;
}

Notes

  • When enabled, the NPC will automatically reload when its clip is empty
  • When disabled, the NPC will not reload and will eventually run out of ammo in clip
  • The reload time can be customized with NPC_SetWeaponReloadTime