dini saving. - 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: dini saving. (
/showthread.php?tid=80440)
dini saving. -
Koppa, - 04.06.2009
Okay I have these commands:
Код:
dcmd_register(playerid, params[])
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\Users\\%s.ini", pname);
if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "* Try '/register' [Password]");
if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "* You are already registered!");
dini_Create(file);
dini_IntSet(file, "HashPW", udb_hash(params));
dini_Set(file, "Password", params);
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
dini_IntSet(file, "pJob", PlayerInfo[playerid][pJob]);
new string[128];
format(string, 128, "* Welcome to Blueberry Role-Play! Nickname %s with password %s", pname, params);
SendClientMessage(playerid, COLOR_YELLOW, string);
Logged[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "* You have been automatically logged in!");
return 1;
}
dcmd_login(playerid, params[])
{
new file[128];
new string[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\Users\\%s.ini", pname);
if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "* Try '/login' [Password]");
if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "* You are not registered!");
if(Logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "* You are already logged in!");
new tmp[128];
tmp = dini_Get(file, "HashPW");
if(udb_hash(params) != strval(tmp))
{
format(string, 128, "You specified the wrong password for %s!", pname);
SendClientMessage(playerid, COLOR_RED, string);
}
else
{
Logged[playerid] = 1;
SetPlayerScore(playerid, dini_Int(file, "Score"));
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
PlayerInfo[playerid][pJob] = dini_Int(file, "pJob");
SendClientMessage(playerid, COLOR_YELLOW, "* You have succesfully logged in!");
}
return 1;
}
My question, when player disconnect, will it save?
Re: dini saving. -
Correlli - 04.06.2009
No. You need to save it under OnPlayerDisconnect, or in timer, or both.
Re: dini saving. -
Hot - 04.06.2009
How?
EDIT:Koppa it's my brother.
Re: dini saving. -
Koppa, - 04.06.2009
Please, helpp!
What do I need to do?
Re: dini saving. -
Correlli - 04.06.2009
Since you're using dini/dudb ->
http://forum.sa-mp.com/index.php?topic=4798.0
Re: dini saving. -
Koppa, - 04.06.2009
I made one by my self but I am not at my home, so I can't test it:
But, just looking, it's alright?
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(Logged[playerid] == 1)
{
new file[128];
new plName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plName, sizeof(plName));
format(file, sizeof(file), "\\Users\\%s.ini", plName);
if(dini_Exists(file))
{
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
dini_IntSet(file, "pJob", PlayerInfo[playerid][pJob]);
return 1;
}
}
return 1;
}
Re: dini saving. -
Correlli - 04.06.2009
You forgot to logout the player, after you save all that.
pawn Код:
Logged[playerid] = false;
Re: dini saving. -
Koppa, - 04.06.2009
Код:
public OnPlayerDisconnect(playerid, reason)
{
if(Logged[playerid] == 1)
{
new file[128];
new plName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plName, sizeof(plName));
format(file, sizeof(file), "\\Users\\%s.ini", plName);
if(dini_Exists(file))
{
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
dini_IntSet(file, "pJob", PlayerInfo[playerid][pJob]);
return 1;
}
}
Logged[playerid] = false;
return 1;
}
Like this ?
Re: dini saving. -
Correlli - 04.06.2009
Like that. I guess that is good, try it and you'll know.
Re: dini saving. -
Koppa, - 04.06.2009
Thanks, it's working!