SA-MP Forums Archive
Check if player has gun ? - 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)
+--- Thread: Check if player has gun ? (/showthread.php?tid=284154)



Check if player has gun ? - Trac - 18.09.2011

Code:
new PlayerGun[MAX_PLAYERS][47];


public CheckIfPlayerHasGun(playerid);
{
for(new j=0; j<47; j++)
{
     new wep1, ammo1;
     GetPlayerWeaponData(playerid, GetWeaponSlot(j), wep1, ammo1);
     if(wep1 != j)
     {
           PlayerGun[playerid][j] = 0;
     }
}
}
Does this is a good way to check if player has gun?
IMPORTANT: not to check if player has gun in arm like(GetPlayerWeapon) i want to check all player weapons.


Re: Check if player has gun ? - =WoR=Varth - 18.09.2011

pawn Code:
for(new j;j<=12;j++)
{
     new wep1, ammo1;
     GetPlayerWeaponData(playerid,j,wep1,ammo1);
     if(wep1) return true;
}
return false;