04.11.2016, 17:27
"weaponid" is integer and you use %s specifier in format to get the name of it which won't happen. Since you have an array with the names, just use it and index the weaponid itself.
A native function exists by the way: https://sampwiki.blast.hk/wiki/GetWeaponName
Just for more: If you open sscanf2.inc and scroll at the bottom, you'll notice a custom specifier called "weapon":
You can replace in the if/else if statements the function strcmp with strfind (remember if what returns is not equal to -1, the text was found) and simply use in sscanf (in commands):
A native function exists by the way: https://sampwiki.blast.hk/wiki/GetWeaponName
Just for more: If you open sscanf2.inc and scroll at the bottom, you'll notice a custom specifier called "weapon":
pawn Код:
SSCANF:weapon(string[])
{
...
}
pawn Код:
new weaponid, ammo;
if (sscanf(params, "k<weapon>i", weaponid, ammo)) return ... // send usage
if (weaponid == -1) return ... // invalid weapon name/ID