SA-MP Forums Archive
GetPlayerWeaponData ammo returns -1 in a loop (sometimes) - 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: GetPlayerWeaponData ammo returns -1 in a loop (sometimes) (/showthread.php?tid=121622)



GetPlayerWeaponData ammo returns -1 in a loop (sometimes) - Nakash - 17.01.2010

I have scripted that code;
pawn Код:
for(new slot = 0; slot < 13; slot++)
          {
            new wep, ammo;
            GetPlayerWeaponData(playerid, slot, wep, ammo);
           }
The problem is that sometimes it returns ammo -1.
How can i fix this?
thanks


Re: GetPlayerWeaponData ammo returns -1 in a loop (sometimes) - pagie1111 - 17.01.2010

pawn Код:
new bullets[12],
   weapons[12];

for(new i = 0; i < 12; i++)
{
GetPlayerWeaponData(targetid, i+1, weapons[i], bullets[i]);
}



Re: GetPlayerWeaponData ammo returns -1 in a loop (sometimes) - Nakash - 17.01.2010

Thanks but the problem is that i am using the fuction that way;

pawn Код:
for(new slot = 0; slot < 13; slot++)
          {
            new wep, ammo;
            GetPlayerWeaponData(playerid, slot, wep, ammo);

            if(wep != 0 && ammo != 0)
            {
                  if(PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wep; PlayerInfo[playerid][pAmmo1] = ammo; }
             }
           }
I don't think i can do this with your function.


Re: GetPlayerWeaponData ammo returns -1 in a loop (sometimes) - Backwardsman97 - 17.01.2010

All this code is doing is looping through 13 different weapon slots and formatting pGun1. So weapon slot 1 and ammo gets set to pGun1, then the loop goes back through and does weapon slot 2 and ammo and sets that to pGun1. So you're not really doing anything. I think you have a logic error here.