Lewati ke konten utama

NPC_GetWeaponAccuracy

peringatan

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

Description​

Gets the accuracy setting for an NPC's weapon.

NameDescription
npcidThe ID of the NPC
weaponidThe weapon ID to check

Returns​

Returns the accuracy value (0.0 to 1.0), or -1.0 on error.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkweaponaccuracy", true))
{
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 = NPC_GetWeaponAccuracy(npcid, WEAPON:weapon);

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

Notes​

  • Accuracy is a value between 0.0 (0% accurate) and 1.0 (100% accurate)
  • Returns -1.0 if the NPC ID is invalid or weapon doesn't exist