Weapon Saving Problem
#1

Hi everyone, I am having a problem with my weapon saving system, If the player does not have a file in the weapons subfolder in the scriptfiles, it automatically creates a new one for them, Every 2 seconds the weapon info saves, and it saves perfectly, but when they reconnect, a new file is created inside the subfolder, not duplicating anything, just rewriting the info.

My code.
pawn Код:
if(!fexist(WepPath(playerid)))
    {
        new INI:File = INI_Open(WepPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteInt(File, "Weapon1",weaponinfo[playerid][Weapon1] = 0);
          INI_WriteInt(File,"Weapon1ammo",weaponinfo[playerid][Weapon1a] = 0);
          INI_WriteInt(File, "Weapon2",weaponinfo[playerid][Weapon2] = 0);
          INI_WriteInt(File,"Weapon2ammo",weaponinfo[playerid][Weapon2a] = 0);
          INI_WriteInt(File, "Weapon3",weaponinfo[playerid][Weapon3] = 0);
          INI_WriteInt(File,"Weapon3ammo",weaponinfo[playerid][Weapon3a] = 0);
          INI_WriteInt(File, "Weapon4",weaponinfo[playerid][Weapon4] = 0);
          INI_WriteInt(File,"Weapon4ammo",weaponinfo[playerid][Weapon4a] = 0);
          INI_WriteInt(File, "Weapon5",weaponinfo[playerid][Weapon5] = 0);
          INI_WriteInt(File,"Weapon5ammo",weaponinfo[playerid][Weapon5a] = 0);
          INI_WriteInt(File, "Weapon6",weaponinfo[playerid][Weapon6] = 0);
          INI_WriteInt(File,"Weapon6ammo",weaponinfo[playerid][Weapon6a] = 0);
          INI_WriteInt(File, "Weapon7",weaponinfo[playerid][Weapon7] = 0);
          INI_WriteInt(File,"Weapon7ammo",weaponinfo[playerid][Weapon7a] = 0);
          INI_WriteInt(File, "Weapon8",weaponinfo[playerid][Weapon8] = 0);
          INI_WriteInt(File,"Weapon8ammo",weaponinfo[playerid][Weapon8a] = 0);
          INI_WriteInt(File, "Weapon9",weaponinfo[playerid][Weapon9] = 0);
          INI_WriteInt(File,"Weapon9ammo",weaponinfo[playerid][Weapon9a] = 0);
          INI_WriteInt(File, "Weapon10",weaponinfo[playerid][Weapon10] = 0);
          INI_WriteInt(File,"Weapon10ammo",weaponinfo[playerid][Weapon10a] = 0);
          INI_WriteInt(File, "Weapon11",weaponinfo[playerid][Weapon11] = 0);
          INI_WriteInt(File,"Weapon11ammo",weaponinfo[playerid][Weapon11a] = 0);
          INI_WriteInt(File, "Weapon12",weaponinfo[playerid][Weapon12] = 0);
          INI_WriteInt(File,"Weapon12ammo",weaponinfo[playerid][Weapon12a] = 0);
          INI_Close(File);
          return 1;
    }
    else
    {
         INI_ParseFile(WepPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    }
Any suggestions?
Reply
#2

Not sure if this is right-.. playerids do change, depending on the IP, it should be the player's name, not ID.
pawn Код:
INI_ParseFile(WepPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
New:
pawn Код:
stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}
pawn Код:
INI_ParseFile(WepPath(playerid), "LoadUser_%s", .bExtra = true, .extra = PlayerName(playerid));
Try it and lemme know how it goes.
Reply
#3

Argument mismatch, got anything else to try?
Reply
#4

Can we see your WepPath(playerid) function?
Reply
#5

Of course
pawn Код:
stock WepPath(playerid)
{
    new string[128], playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername,sizeof(playername));
    format(string,sizeof(string),PATH4,playername);
    return string;
}
And this is all the weapon info data
pawn Код:
enum WepData
{
        Weapon1,
        Weapon1a,
        Weapon2,
        Weapon2a,
        Weapon3,
        Weapon3a,
        Weapon4,
        Weapon4a,
        Weapon5,
        Weapon5a,
        Weapon6,
        Weapon6a,
        Weapon7,
        Weapon7a,
        Weapon8,
        Weapon8a,
        Weapon9,
        Weapon9a,
        Weapon10,
        Weapon10a,
        Weapon11,
        Weapon11a,
        Weapon12,
        Weapon12a,
}
new weaponinfo[MAX_PLAYERS][WepData];
#define PATH4 "weapons/%s.ini"
Reply
#6

There's clearly an issue with WepPath, seeing as the script sees it as not existing. Try removing PATH4 and just put the path in your WepPath function. Your script is all over the place.
Reply
#7

After I did that, my player stats system malfunctioned and would not work, would it be easier just to put all of these into the regular player information?
Reply
#8

Got TeamSpeak/Skype? PM Me, i will fix it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)