Check all the guns in all slots? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Check all the guns in all slots? (
/showthread.php?tid=204490)
Check all the guns in all slots? -
Fj0rtizFredde - 29.12.2010
Hi. I tried to make a function that checks if the player has any weapon in any slot, I tried to use GetPlayerWeaponData but I think I faild

The thing I need help with is just to check if there is any gun in any slot.. If there is the code should do something

I hope you get what I mean
Re: Check all the guns in all slots? -
Anwix_ - 29.12.2010
pawn Код:
new WeaponData[13][2], string[128];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, WeaponData[i][0], WeaponData[i][1]);
format(string, sizeof(string), "Slot %d: weapon id %d with %d ammo.", i, WeaponData[i][0], WeaponData[i][1]);
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
Re: Check all the guns in all slots? -
Fj0rtizFredde - 29.12.2010
Well not really like you did it

Im trying to do so that if the player has a gun in ANY slot it will do something else it wont

The code needs to stop if finds a gun in one of the slots
Re: Check all the guns in all slots? -
Anwix_ - 31.12.2010
You mean something like this? Untested.
pawn Код:
new WeaponData[13][2], string[128];
for (new i = 0; i < 13; i++)
{
WeaponData[i][0] = 255;
GetPlayerWeaponData(playerid, i, WeaponData[i][0], WeaponData[i][1]);
if(WeaponData[i][0] != 255)
{
format(string, sizeof(string), "Found a weapon in slot %d", i);
SendClientMessage(playerid, 0xFFFFFFFF, string);
break;
}
}