SA-MP Forums Archive
Dini account problems. - 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 account problems. (/showthread.php?tid=191412)



Dini account problems. - -Rebel Son- - 19.11.2010

So i made a Dialog Account system, and it saves everything ok, but loads everything all wrong. example: if i had 5000 cash, and i log out and log in, it comes up as negative 5000, and my skin and score doesnt load. , heres the code.


this is the login.
pawn Код:
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Great!  Login with your password!", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp)
{
SendClientMessage(playerid, COLOR_RED, "Wrong PW sir.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Great! Login with your password!", "Login", "Leave");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][PosX] = dini_Float(file, "PosX");
PlayerInfo[playerid][PosY] = dini_Float(file, "PosY");
PlayerInfo[playerid][PosZ] = dini_Float(file, "PosZ");
SetPlayerPos(playerid, PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ]);
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, dini_Int(file, "pscore"));
GivePlayerMoney(playerid, dini_Int(file, "Money"));
SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
SpawnPlayer(playerid);
}
}
return 1;
}



Re: Dini account problems. - Lorenc_ - 19.11.2010

Im not really sure but try:

pawn Код:
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
Try that, btw i think i saw this code i just posted on your TUT 0.0


Re: Dini account problems. - Biesmen - 19.11.2010

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Im not really sure but try:

pawn Код:
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
Try that, btw i think i saw this code i just posted on your TUT 0.0
No, that wouldn't work and it shouldn't be the solution.

You could use an other method.
This is an example of one of my first scripts.
Do not use this, it's not configured to your script
At the begin of the script:
pawn Код:
new money[MAX_PLAYERS];
When you login:
pawn Код:
GetPlayerName(playerid, playername, sizeof(playername));

money[playerid] = dini_Int(playername, "money");
If you want to use this method, you could try this: (configured to your script)
Begin of your script:
pawn Код:
new money[MAX_PLAYERS];
When you login:
pawn Код:
money[playerid] = dini_Int(file, "money");
GivePlayerMoney(playerid, money[playerid]);