Ammo increased after buying a new weapon(same slot).
#6

GTA: SA seems to treat ammo per weaponslot, not per individual weapon, which doesn't really make sense. I'm no gun expert but I don't think a desert eagle uses the same ammo as a 9mm.

Here's a fix I wrote:

pawn Код:
new const weapon_slot[] = {
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
10, // 10
10,
10,
10,
10,
10,
8,
8,
8,
0,
0, // 20
0,
2,
2,
2,
3,
3,
3,
4,
4,
5, // 30
5,
4,
6,
6,
7,
7,
7,
7,
8,
12, // 40
9,
9,
9,
11,
11,
11
};

stock h_GivePlayerWeapon(playerid, weaponid, ammo)
{
    if(!IsPlayerConnected(playerid)) return 0;

    new weapon, oldammo;
    GetPlayerWeaponData(playerid, weapon_slot[weaponid], weapon, oldammo);

    GivePlayerWeapon(playerid, weaponid, ammo);
    if(weapon != weaponid && weapon != 0)
    {
        SetPlayerAmmo(playerid, weaponid, oldammo);
    }
    else
    {
        SetPlayerAmmo(playerid, weaponid, oldammo+ammo);
    }
    return 1;
}
#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    #define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon h_GivePlayerWeapon
All you need to do is put that before you ever use GivePlayerWeapon. Somewhere above all callbacks like above OnGameModeInit (which should be your first callback tbh).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)