use getplayerweapondata as condition.
#1

I am trying to use getplayerweapon data to get player weapon and ammo. I want it to work as when he gets minigun and gets ammo greater than 100. He gets banned.
How to use it in conditional form ?
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerAmmo

pawn Код:
new ammo = GetPlayerAmmo(playerid);
if(ammo > 100)
{
   // code
}
Reply
#3

Код:
	new weapons[12][2];
	for(new w = 0; w < 12; w++)
	{
		GetPlayerWeaponData(playerid, w, weapons[w][0], weapons[w][1]);
		// weapons[w][0] = Weapon
		// weapons[w][1] = Ammo
		if(weapons[w][0] == 38 && weapons[w][1] > 100)
		{
			// Code ...
		}
	}
Something like this will should work fine
Reply
#4

thanks bro
Reply
#5

Why a two-dimensional array when a one-dimensional array would be enough? As far as I see, you do not have to temporarily store the results you get in the for-loop. Aswell, you should make sure to check all slots (0 - 12):

pawn Код:
new weaponData[2];
for(new s = 0; s <= 12; s++) {
    GetPlayerWeaponData(playerid, s, weaponData[0], weaponData[1]);
    if(weaponData[0] == 38 && weaponData[1] > 100) {
        // Player has Minigun with an amount of ammo greater than 100.
    }
}
Reply


Forum Jump:


Users browsing this thread: