Weapon Data
#1

Why this doesn't save player's weapons after disconnect ??

pawn Код:
#define GUNS_PATH "/Guns/%s.ini"

enum gInfo
{
    gSlot0_gun,
    gSlot0_ammo,
    gSlot1_gun,
    gSlot1_ammo,
    gSlot2_gun,
    gSlot2_ammo,
    gSlot3_gun,
    gSlot3_ammo,
    gSlot4_gun,
    gSlot4_ammo,
    gSlot5_gun,
    gSlot5_ammo,
    gSlot6_gun,
    gSlot6_ammo,
    gSlot7_gun,
    gSlot7_ammo,
    gSlot8_gun,
    gSlot8_ammo,
    gSlot9_gun,
    gSlot9_ammo,
    gSlot10_gun,
    gSlot10_ammo,
    gSlot11_gun,
    gSlot11_ammo,
    gSlot12_gun,
    gSlot12_ammo
}
new GunInfo[MAX_PLAYERS][gInfo];

stock SaveGunStats(playerid)
{
    GetPlayerWeaponData(playerid, 0, GunInfo[playerid][gSlot0_gun], GunInfo[playerid][gSlot0_ammo]);
    GetPlayerWeaponData(playerid, 1, GunInfo[playerid][gSlot1_gun], GunInfo[playerid][gSlot1_ammo]);
    GetPlayerWeaponData(playerid, 2, GunInfo[playerid][gSlot2_gun], GunInfo[playerid][gSlot2_ammo]);
    GetPlayerWeaponData(playerid, 3, GunInfo[playerid][gSlot3_gun], GunInfo[playerid][gSlot3_ammo]);
    GetPlayerWeaponData(playerid, 4, GunInfo[playerid][gSlot4_gun], GunInfo[playerid][gSlot4_ammo]);
    GetPlayerWeaponData(playerid, 5, GunInfo[playerid][gSlot5_gun], GunInfo[playerid][gSlot5_ammo]);
    GetPlayerWeaponData(playerid, 6, GunInfo[playerid][gSlot6_gun], GunInfo[playerid][gSlot6_ammo]);
    GetPlayerWeaponData(playerid, 7, GunInfo[playerid][gSlot7_gun], GunInfo[playerid][gSlot7_ammo]);
    GetPlayerWeaponData(playerid, 8, GunInfo[playerid][gSlot8_gun], GunInfo[playerid][gSlot8_ammo]);
    GetPlayerWeaponData(playerid, 9, GunInfo[playerid][gSlot9_gun], GunInfo[playerid][gSlot9_ammo]);
    GetPlayerWeaponData(playerid, 10, GunInfo[playerid][gSlot10_gun], GunInfo[playerid][gSlot10_ammo]);
    GetPlayerWeaponData(playerid, 11, GunInfo[playerid][gSlot11_gun], GunInfo[playerid][gSlot11_ammo]);
    GetPlayerWeaponData(playerid, 12, GunInfo[playerid][gSlot12_gun], GunInfo[playerid][gSlot12_ammo]);

    new INI:file = INI_Open(GunPath(playerid));
    INI_WriteInt(file, "gSlot0_gun", GunInfo[playerid][gSlot0_gun]);
    INI_WriteInt(file, "gSlot0_ammo", GunInfo[playerid][gSlot0_ammo]);
    INI_WriteInt(file, "gSlot1_gun", GunInfo[playerid][gSlot1_gun]);
    INI_WriteInt(file, "gSlot1_ammo", GunInfo[playerid][gSlot1_ammo]);
    INI_WriteInt(file, "gSlot2_gun", GunInfo[playerid][gSlot2_gun]);
    INI_WriteInt(file, "gSlot2_ammo", GunInfo[playerid][gSlot2_ammo]);
    INI_WriteInt(file, "gSlot3_gun", GunInfo[playerid][gSlot3_gun]);
    INI_WriteInt(file, "gSlot3_ammo", GunInfo[playerid][gSlot3_ammo]);
    INI_WriteInt(file, "gSlot4_gun", GunInfo[playerid][gSlot4_gun]);
    INI_WriteInt(file, "gSlot4_ammo", GunInfo[playerid][gSlot4_ammo]);
    INI_WriteInt(file, "gSlot5_gun", GunInfo[playerid][gSlot5_gun]);
    INI_WriteInt(file, "gSlot5_ammo", GunInfo[playerid][gSlot5_ammo]);
    INI_WriteInt(file, "gSlot6_gun", GunInfo[playerid][gSlot6_gun]);
    INI_WriteInt(file, "gSlot6_ammo", GunInfo[playerid][gSlot6_ammo]);
    INI_WriteInt(file, "gSlot7_gun", GunInfo[playerid][gSlot7_gun]);
    INI_WriteInt(file, "gSlot7_ammo", GunInfo[playerid][gSlot7_ammo]);
    INI_WriteInt(file, "gSlot8_gun", GunInfo[playerid][gSlot8_gun]);
    INI_WriteInt(file, "gSlot8_ammo", GunInfo[playerid][gSlot8_ammo]);
    INI_WriteInt(file, "gSlot9_gun", GunInfo[playerid][gSlot9_gun]);
    INI_WriteInt(file, "gSlot9_ammo", GunInfo[playerid][gSlot9_ammo]);
    INI_WriteInt(file, "gSlot10_gun", GunInfo[playerid][gSlot10_gun]);
    INI_WriteInt(file, "gSlot10_ammo", GunInfo[playerid][gSlot10_ammo]);
    INI_WriteInt(file, "gSlot11_gun", GunInfo[playerid][gSlot11_gun]);
    INI_WriteInt(file, "gSlot11_ammo", GunInfo[playerid][gSlot11_ammo]);
    INI_WriteInt(file, "gSlot12_gun", GunInfo[playerid][gSlot12_gun]);
    INI_WriteInt(file, "gSlot12_ammo", GunInfo[playerid][gSlot12_ammo]);
    INI_Close(file);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SaveGunStats(playerid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(GunPath(playerid)))
    {
        INI_ParseFile(GunPath(playerid), "LoadGun_%s", .bExtra = true, .extra = playerid);
    }
    return 1;
}

forward LoadGun_data(playerid, name[], value[]);
public LoadGun_data(playerid, name[], value[])
{
    INI_Int("gSlot0_gun", GunInfo[playerid][gSlot0_gun]);
    INI_Int("gSlot0_ammo", GunInfo[playerid][gSlot0_ammo]);
    INI_Int("gSlot1_gun", GunInfo[playerid][gSlot1_gun]);
    INI_Int("gSlot1_ammo", GunInfo[playerid][gSlot1_ammo]);
    INI_Int("gSlot2_gun", GunInfo[playerid][gSlot2_gun]);
    INI_Int("gSlot2_ammo", GunInfo[playerid][gSlot2_ammo]);
    INI_Int("gSlot3_gun", GunInfo[playerid][gSlot3_gun]);
    INI_Int("gSlot3_ammo", GunInfo[playerid][gSlot3_ammo]);
    INI_Int("gSlot4_gun", GunInfo[playerid][gSlot4_gun]);
    INI_Int("gSlot4_ammo", GunInfo[playerid][gSlot4_ammo]);
    INI_Int("gSlot5_gun", GunInfo[playerid][gSlot5_gun]);
    INI_Int("gSlot5_ammo", GunInfo[playerid][gSlot5_ammo]);
    INI_Int("gSlot6_gun", GunInfo[playerid][gSlot6_gun]);
    INI_Int("gSlot6_ammo", GunInfo[playerid][gSlot6_ammo]);
    INI_Int("gSlot7_gun", GunInfo[playerid][gSlot7_gun]);
    INI_Int("gSlot7_ammo", GunInfo[playerid][gSlot7_ammo]);
    INI_Int("gSlot8_gun", GunInfo[playerid][gSlot8_gun]);
    INI_Int("gSlot8_ammo", GunInfo[playerid][gSlot8_ammo]);
    INI_Int("gSlot9_gun", GunInfo[playerid][gSlot9_gun]);
    INI_Int("gSlot9_ammo", GunInfo[playerid][gSlot9_ammo]);
    INI_Int("gSlot10_gun", GunInfo[playerid][gSlot10_gun]);
    INI_Int("gSlot10_ammo", GunInfo[playerid][gSlot10_ammo]);
    INI_Int("gSlot11_gun", GunInfo[playerid][gSlot11_gun]);
    INI_Int("gSlot11_ammo", GunInfo[playerid][gSlot11_ammo]);
    INI_Int("gSlot12_gun", GunInfo[playerid][gSlot12_gun]);
    INI_Int("gSlot12_ammo", GunInfo[playerid][gSlot12_ammo]);
    return 1;
}
Reply
#2

go to your scriptfiles and add new folder called Guns
Reply
#3

Quote:
Originally Posted by iThePunisher
Посмотреть сообщение
go to your scriptfiles and add new folder called Guns
i have it for sure. it saves the guns weapons on disconnect but when the player rejoin, it reset all variables of his guns file to 0, i really don't know why -,-
Reply
#4

anyone ?
Reply
#5

Maybe you dont load them on connecting ?
Reply
#6

i posted all my code, nothing wrong in it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)