SA-MP Forums Archive
Saving help! [Edited] - 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: Saving help! [Edited] (/showthread.php?tid=285937)



Saving help! [Edited] - Yamoo - 26.09.2011

Problem - Saving, the cash,kills,deaths,adminlevel and VIP won't save (only if it's done through scriptfiles it saves).


Code - Click here

This is also under OnPlayerDisconnect


pawn Код:
new userfile[132];
    format(userfile, sizeof (userfile), "users/%s.ini", pname);
    new INI:file = INI_Open(userfile);
    INI_SetTag(INI:file, "data");
    INI_WriteInt(file,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(file,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(file,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(file,"Adminlevel",PlayerInfo[playerid][pAdminlevel]);
    INI_WriteInt(file,"VIP",PlayerInfo[playerid][pVIP]);
    INI_Close(file);
Thanks in advanced.


Re : Saving help! [Edited] - timaoux - 26.09.2011

pawn Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname,sizeof(pname));
and you need create users folder in your scriptfiles folder


Re: Re : Saving help! [Edited] - Yamoo - 26.09.2011

Quote:
Originally Posted by timaoux
Посмотреть сообщение
pawn Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname,sizeof(pname));
and you need create users folder in your scriptfiles folder
I know you're trying to help, but I ain't that retarded to know that I need to know how to create a folder in my scriptfiles (I don't want this to sound cheeky heh so apologies if it does).


Re : Saving help! [Edited] - timaoux - 26.09.2011

use dini its better for save the users info


Re: Saving help! [Edited] - Wesley221 - 26.09.2011

pawn Код:
new userfile[132];
    format(userfile, sizeof (userfile), "users/%s.ini", pname);
print("1");
    new INI:file = INI_Open(userfile);
print("2");
    INI_SetTag(INI:file, "data");
print("3");
    INI_WriteInt(file,"Cash",GetPlayerMoney(playerid));
print("4");
    INI_WriteInt(file,"Kills",PlayerInfo[playerid][pKills]);
print("5");
    INI_WriteInt(file,"Deaths",PlayerInfo[playerid][pDeaths]);
print("6");
    INI_WriteInt(file,"Adminlevel",PlayerInfo[playerid][pAdminlevel]);
print("7");
    INI_WriteInt(file,"VIP",PlayerInfo[playerid][pVIP]);
print("8");
    INI_Close(file);
print("9");
Check where it stops, and post that here; if it prints them all check the file if it actually creates a line 'VIP' in the file.

Edit:
Quote:
Originally Posted by timaoux
Посмотреть сообщение
use dini its better for save the users info
Dini sucks compared to y_ini, well actually for everything else


Re : Saving help! [Edited] - timaoux - 26.09.2011

i hate y_ini , thats too complicated


Re: Saving help! [Edited] - Aprezt - 26.09.2011

Mby you do this.

pawn Код:
// Forward
forward SaveAccount(playerid);
// Public
public SaveAccount(playerid)
{
    new
                userfile[ 132 ],
        INI:File = INI_Open(userfile)
    ;
    format(userfile, sizeof (userfile), "users/%s.ini", pname);
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Adminlevel",PlayerInfo[playerid][pAdminlevel]);
    INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]);
    INI_Close(File);
    return 1;
}

// And add line to OnPlayerDisconnect
SaveAccount(playerid);
EDIT:
Quote:
Originally Posted by timaoux
Посмотреть сообщение
i hate y_ini , thats too complicated
Mby you are so noob to use this ?

OUCH Sorry i forgot. I update my post you got userfile sorry my mistake.


Re: Saving help! [Edited] - Yamoo - 26.09.2011

Sorry I forgot to post, I fixed it before hand.


But thanks for the help and reputation points will be giving.