save / load in same filterscript
#1

ok i made a filterscript and i want to create a file to store the information each time a player logs off and when he spawns if the file exists already load it up, is there anything wrong with this ?

pawn Код:
#define PATH "/Users/%s.ini"

public OnPlayerDisconnect(playerid, reason)
{


   


    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"PlayerData");
    INI_WriteInt(File,"LSPDRank",PlayerData[playerid][LSPDRank]);
    INI_WriteInt(File,"FBIRank",PlayerData[playerid][FBIRank]);
    INI_WriteInt(File,"Cells",Cell[playerid]);
    INI_WriteInt(File,"FPrison",FPrison[playerid]);
    INI_WriteInt(File,"Jailed",Jailed[playerid]);
    INI_WriteInt(File,"Jailed2",Jailed2[playerid]);
    INI_WriteInt(File,"FBIJailed",FBIJailed[playerid]);
    INI_WriteInt(File,"FBIJailed2",FBIJailed2[playerid]);
    INI_WriteInt(File,"Wanted",PlayerData[playerid][Wanted]);
    INI_WriteInt(File,"Minutes",countn[playerid]);
    INI_WriteInt(File,"time",timeleft[playerid]);
    INI_Close(File);
    return 1;
   }

public OnPlayerSpawn(playerid)
{

new pFile[128];
    new name[24];
    GetPlayerName(playerid,name,sizeof name);
    format(pFile,sizeof pFile,"/Users/%s.ini",name);
    if(fexist(pFile))
    {
        INI_ParseFile(pFile, "LoadUser_data", .bExtra = true, .extra = playerid);
    }
    else
    {
        fcreate(pFile);
    }

return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("LSPDRank",PlayerData[playerid][LSPDRank]);
    INI_Int("FBIRank",PlayerData[playerid][FBIRank]);
    INI_Int("Cells",Cell[playerid]);
    INI_Int("FPrison",FPrison[playerid]);
    INI_Int("Jailed",Jailed[playerid]);
    INI_Int("Jailed2",Jailed2[playerid]);
    INI_Int("FBIJailed",FBIJailed[playerid]);
    INI_Int("FBIJailed2",FBIJailed2[playerid]);
    INI_Int("Wanted",PlayerData[playerid][Wanted]);
    INI_Int("Minutes",countn[playerid]);
    INI_Int("time",timeleft[playerid]);

    return 1;
}

stock fcreate(filename[])
{
    if (fexist(filename)){return false;}
    new File:fhandle = fopen(filename,io_write);
    fclose(fhandle);
    return true;
}
Reply
#2

Did you tested it?
Reply
#3

I got same problem, but i removed my stuff from a FS to the main script. So maybe you should do the same.
Reply
#4

yes i tried but it saves the information to IDS instead names
Reply
#5

Use in gamemode script
Reply
#6

thats the point i want to use this as a filterscript
Reply
#7

bump
Reply
#8

bump
Reply
#9

bump
Reply
#10

can some1 tell me why it loads through id and not player name
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)