SA-MP Forums Archive
Problem with 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: Problem with dini saving. (/showthread.php?tid=154093)



Problem with dini saving. - Kayaque - 12.06.2010

In my script I save money, skin and admin level.
And it works perfectly, until I restart the server. Once i restart the server, it resets all the player accounts as well.
Any suggestions to what I can do to save them all?



Quote:

public OnPlayerDisconnect(playerid, reason)
{
Object_OnPlayerDisconnect(playerid, reason);
dini_IntSet(udb_encode(playername), "pSkin", pSkin[playerid]);
dini_IntSet(udb_encode(playername), "pMoney", pMoney[playerid]);
dini_IntSet(udb_encode(playername), "pAdmin", pAdmin[playerid]);
dini_IntSet(udb_encode(playername), "pLeadAdmin", pLeadAdmin[playerid]);
return 0;
}

Quote:

new cmd[256],tmp[256], tmp2[256];
new idx;
new string[256];
cmd = strtok(cmdtext, idx);
GetPlayerName(playerid, playername, sizeof(playername));
if(strcmp(cmd, "/register", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, WHITE, "Server: /register (password)");
}
else
{
if (!dini_Exists(udb_encode(playername)))
{
dini_Create(udb_encode(playername));
dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
dini_IntSet(udb_encode(playername), "pMoney", 15000);
dini_IntSet(udb_encode(playername), "pAdmin", 0);
dini_IntSet(udb_encode(playername), "pLeadAdmin", 0);
dini_IntSet(udb_encode(playername), "pSkin", 60);
format(string, sizeof(string), "Server: Account %s has been created. You can now /login", playername);
SendClientMessage(playerid, WHITE, string);
}
else
{
SendClientMessage(playerid, RED, "Server: Accountname not found. Please use /register");
}
}
return 1;
}

Quote:

if(strcmp(cmd, "/login", true)==0)
{
if(logged[playerid]==1)
{
SendClientMessage(playerid, RED, "Server: You are already logged in.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, WHITE, "Server: Usage /login (password)");
}
else
{
if (dini_Exists(udb_encode(playername)))
{
tmp2 = dini_Get(udb_encode(playername), "password");
if (udb_hash(tmp) != strval(tmp2))
{
SendClientMessage(playerid, WHITE, "Server: Wrong / Invalid password.");
}
else
{
logged[playerid]=1;
SendClientMessage(playerid, WHITE, "Server: Successfully logged in. Welcome back.");
pSkin[playerid] = dini_Int(udb_encode(playername), "pSkin");
pMoney[playerid] = dini_Int(udb_encode(playername), "pMoney");
pAdmin[playerid] = dini_Int(udb_encode(playername), "pAdmin");
pLeadAdmin[playerid] = dini_Int(udb_encode(playername), "pLeadAdmin");
GivePlayerMoney(playerid, pMoney[playerid]);
SetPlayerSkin(playerid, pSkin[playerid]);
}
}
else
{
format(string, sizeof(string), "Server: %s is already registered. Please pick another name.", playername,tmp);
SendClientMessage(playerid, WHITE, string);
}
}
return 1;
}




Re: Problem with dini saving. - TheInnocentOne - 12.06.2010

Why are you creating the file names as hashes?


Re: Problem with dini saving. - DarkPower - 12.06.2010

You can use timer evry 5 min. what will update your account settings. And you can make FUNC what will recognize if happened server CRASH ( gmx )


Re: Problem with dini saving. - Kayaque - 12.06.2010

Well, what I mean is.. When i register I get a stats... Which is 15000 dollars and skin id 60.
Then when i change it on the database i spawn with it ingame as well. But somehow when i restart the server, it keeps going back to skinid 60 and 15000 dollars.
Is my OnPlayerDisconnect stuff wrong?