SA-MP Forums Archive
save / load in same filterscript - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: save / load in same filterscript (/showthread.php?tid=402705)



save / load in same filterscript - stix - 27.12.2012

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;
}



Re: save / load in same filterscript - Faisal_khan - 27.12.2012

Did you tested it?


Re: save / load in same filterscript - Frede - 27.12.2012

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


Respuesta: save / load in same filterscript - stix - 27.12.2012

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


Re: save / load in same filterscript - RedCrossER - 27.12.2012

Use in gamemode script


Respuesta: save / load in same filterscript - stix - 27.12.2012

thats the point i want to use this as a filterscript


Respuesta: save / load in same filterscript - stix - 29.12.2012

bump


Respuesta: save / load in same filterscript - stix - 30.12.2012

bump


Respuesta: save / load in same filterscript - stix - 01.01.2013

bump


Respuesta: save / load in same filterscript - stix - 04.01.2013

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