Zum Hauptinhalt springen

NPC_SetWeaponAccuracy

warnung

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

Description

Sets the accuracy of a specific weapon for an NPC.

NameDescription
npcidThe ID of the NPC
weaponidThe weapon ID to set accuracy for
accuracyThe accuracy value (0.0 to 1.0)

Returns

Returns true if the operation was successful, false otherwise.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setweaponaccuracy ", true, 19))
{
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 weapon = NPC_GetWeapon(npcid);
new Float:accuracy = floatstr(cmdtext[19]);

NPC_SetWeaponAccuracy(npcid, WEAPON:weapon, accuracy);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d weapon %d accuracy set to %.2f", npcid, weapon, accuracy);
return 1;
}
return 0;
}

Notes

  • Accuracy value ranges from 0.0 (never hits) to 1.0 (always hits)
  • Default accuracy varies by weapon type
  • Accuracy affects bullet spread and hit probability

No specific callbacks are triggered by this function.