GetPlayerWeaponData ammo returns -1 in a loop (sometimes)
#1

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
Reply
#2

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

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

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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)