Saving dini stats in new folder - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving dini stats in new folder (
/showthread.php?tid=178695)
Saving dini stats in new folder -
nejc001 - 23.09.2010
How to make in script like this:
Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[MAX_PLAYER_NAME+5], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SAVE_FILE, name);
dini_IntSet(file, "Score", GetPlayerScore(playerid));
return 1;
}
that this stats would save in /scriptfiles/mygamemode/users
now it just saves in scriptfiles folder
Re: Saving dini stats in new folder -
wups - 23.09.2010
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "mygamemode/users/%s.txt", name);
dini_IntSet(file, "Score", GetPlayerScore(playerid));
return 1;
}
Don't forget to create that directory!
Re: Saving dini stats in new folder -
ColdXX - 23.09.2010
And how to load it when the player re-connects?
Re: Saving dini stats in new folder -
Mauzen - 23.09.2010
The same way, just with loading and not setting.
pawn Код:
public OnPlayerConnect(playerid, reason)
{
new file[MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "mygamemode/users/%s.txt", name);
SetPlayerScore(playerid, dini_IntGet(file, "Score")); //Is it Get? not sure about dini
return 1;
}
Re: Saving dini stats in new folder -
Hiddos - 23.09.2010
pawn Код:
public OnPlayerConnect(playerid)
{
new file[MAX_PLAYER_NAME + 25];
GetPlayerName(playerid, file, sizeof file);
format(file, sizeof file, "mygamemode/users/%s", file);
SetPlayerScore(playerid, dini_Int(file, "Score"));
}
Obvious
Dunno if this is correct dini usage, I hate it anyways lol.