-1 Ammo bug when loading players weapons.
#1

Hey, had this problems for a year now never thought about asking anybody to give me a answer what the problem is about my players receive a -1 gun sometimes when they relog. Lets see i logon i buy a deagle with 100 bullets, i logout then the gun saves perfectly. But then SOMETIMES(but happens kind of alot for my players) when i logon i will receive my deagle but it has -1 bullets and i wont be able to scroll to it, that means a lost deagle for the player.

Anybody who knows a fix for this or is it just another SA:MP bug?

I'll show some code
pawn Код:
//Saving [ I have 12 slots, for all the weapons] -
GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pAmmo2]);
GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pAmmo3]);
GetPlayerWeaponData(playerid, 4, PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pAmmo4]);
GetPlayerWeaponData(playerid, 5, PlayerInfo[playerid][pGun5], PlayerInfo[playerid][pAmmo5]);
GetPlayerWeaponData(playerid, 6, PlayerInfo[playerid][pGun6], PlayerInfo[playerid][pAmmo6]);
GetPlayerWeaponData(playerid, 7, PlayerInfo[playerid][pGun7], PlayerInfo[playerid][pAmmo7]);
GetPlayerWeaponData(playerid, 8, PlayerInfo[playerid][pGun8], PlayerInfo[playerid][pAmmo8]);
GetPlayerWeaponData(playerid, 9, PlayerInfo[playerid][pGun9], PlayerInfo[playerid][pAmmo9]);
GetPlayerWeaponData(playerid, 10, PlayerInfo[playerid][pGun10], PlayerInfo[playerid][pAmmo10]);
GetPlayerWeaponData(playerid, 11, PlayerInfo[playerid][pGun11], PlayerInfo[playerid][pAmmo11]);
GetPlayerWeaponData(playerid, 12, PlayerInfo[playerid][pGun12], PlayerInfo[playerid][pAmmo12]);
// And now setting the players weapon
stock SetPlayerWeapons(playerid)
{
     ResetPlayerWeapons(playerid); // I have to do this else the player will get double ammo.
      if (PlayerInfo[playerid][pGun1] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
    }
    if (PlayerInfo[playerid][pGun2] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pAmmo2]);
    }
    if (PlayerInfo[playerid][pGun3] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pAmmo3]);
    }
    if (PlayerInfo[playerid][pGun4] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pAmmo4]);
    }
    if (PlayerInfo[playerid][pGun5] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun5], PlayerInfo[playerid][pAmmo5]);
    }
    if (PlayerInfo[playerid][pGun6] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun6], PlayerInfo[playerid][pAmmo6]);
    }
    if (PlayerInfo[playerid][pGun7] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun7], PlayerInfo[playerid][pAmmo7]);
    }
    if (PlayerInfo[playerid][pGun8] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun8], PlayerInfo[playerid][pAmmo8]);
    }
    if (PlayerInfo[playerid][pGun9] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun9], PlayerInfo[playerid][pAmmo9]);
    }
    if (PlayerInfo[playerid][pGun10] > 0)
    {
      GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun10], PlayerInfo[playerid][pAmmo10]);
    }
    if (PlayerInfo[playerid][pGun11] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun11], PlayerInfo[playerid][pAmmo11]);
    }
    if (PlayerInfo[playerid][pGun12] > 0)
    {
      SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pGun12], PlayerInfo[playerid][pAmmo12]);
    }
    return 1;
}

Reply
#2

Are you already loading the data into the PlayerInfo array before attempting to give them the weapon? If so, then it's probably another SA:MP bug.
Reply
#3

I've answered this question in another post yesterday

http://forum.sa-mp.com/index.php?top...304#msg1074304
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)