GetPlayerAmmo(playerid)
#1

Function does not return ammo 0 on weapon slot 8 and slot 9. Unnecessary to mention that it does on other weapon slots.

Код:
public OnPlayerUpdate(playerid)
{
	new weaponid = GetPlayerWeapon(playerid);
	if(39 >= weaponid >= 16 || 43 >= weaponid >= 41)
	{
		new const ammo = GetPlayerAmmo(playerid);
		if(ammo < 1)
		{
			printf("weaponid %d ammo: %d", weaponid, ammo);
		}
	}
	return 1;
}
Reply
#2

GetPlayerWeapon(playerid) mean, what you are holding a weapon. But when ammo is 0, that weapon is disappearing.
Reply
#3

Yes, in theory it means that weapon is going to disappear, unfortunately it does not return ammo 0 for weapon slots 8 and 9 when it should.
Reply
#4

Why are you using "new const" in that situation? The best would be to use "static" in that situation. Try it.
Reply
#5

lolwut? It does not change how GetPlayerAmmo works. Try it yourself before giving an opinion on solution. In case you dont know what weapnos are in slot 8 and 9 then I will tell you: grenade, teargas, molotov cocktail, satchel (remote explosives), spraycan, fire extinguisher, camera.

I think this problem is linked to OnPlayerWeaponShot update as these are not bullet weapons.
Reply
#6

Possible solution:

pawn Код:
public OnPlayerUpdate(playerid)
{
    new cWep;
    switch(cWep))
    {
    case 0: return 1;
    case 16,17,18,39,41,42,43: {
        if(GetPlayerAmmo(playerid) == 1) gAmmo = 1;
        return 1;
        }
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE && isValSlot(GetPlayerWeapon) && GetPlayerWeapon(playerid) > 0)
    {
        if(gAmmo == 1) OnPlayerAmmoEmpty(playerid);
        return 1;
    }
}
stock IsValSlot(weaponid)
{
    case 0: return 0;
    case 16,17,18,39,41,42,43:return 1;
    default: return 0;
}
Untested...
Reply
#7

I have a solution but a more complex than this, will release it soon.
Reply
#8

Quote:
Originally Posted by Hanger
Посмотреть сообщение
lolwut? It does not change how GetPlayerAmmo works. Try it yourself before giving an opinion on solution. In case you dont know what weapnos are in slot 8 and 9 then I will tell you: grenade, teargas, molotov cocktail, satchel (remote explosives), spraycan, fire extinguisher, camera.

I think this problem is linked to OnPlayerWeaponShot update as these are not bullet weapons.
I wasn't giving you a SOLUTION. I was giving you CODING ADVICE.

Christ this community nowadays.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)