SA-MP Forums Archive
Score wont Save - 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: Score wont Save (/showthread.php?tid=247260)



Score wont Save - Basker101 - 08.04.2011

Hey.

I'll Followed this TuT about making your own Register/Login system whit savings But the Problem is that when I'm Log off It's Don't save my Money/Score/Admin Level

Код:
	dcmd_register(playerid, params[])
{
    new file[256], 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, "USAGE:/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, "level", 0);
    dini_IntSet(file, "score", GetPlayerScore(playerid));
    dini_IntSet(file, "money", GetPlayerMoney(playerid));
	
    new string[256];
    format(string, 256, "You succesfully registered the 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[256];
    new string[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(string), "\\Users\\%s.ini", pname);
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /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[256];
    tmp = dini_Get(file, "hashPW");
    if(udb_hash(params) != strval(tmp))
    {
        format(string, 256, "You specified the wrong password for %s!", pname);
        SendClientMessage(playerid, COLOR_RED, string);
    }
    else
    {
        logged[playerid] = 1;
        level[playerid] = dini_Int(file, "level");
		SetPlayerScore(playerid, dini_Int(file, "score"));
		GivePlayerMoney(playerid,dini_Int(file, "money")-GetPlayerMoney(playerid));
        SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!");
        printf("%s (%i) logged in with password %s", pname, playerid, params);
    }
    return 1;
}
Any BTW The Script has No Errors/Warnings

So hope someone can help me (:

Peace out "Basker"


Re: Score wont Save - [DJ]Boki - 08.04.2011

so? you need save score script


Re: Score wont Save - Basker101 - 08.04.2011

Hmm Don't need a other script I'll just need to get this saving system to work


Re: Score wont Save - leong124 - 08.04.2011

Scores will only be changed after registering/logging in.
You'll need some more scripts in OnPlayerDisconnect.


Re: Score wont Save - Basker101 - 08.04.2011

Quote:
Originally Posted by leong124
Посмотреть сообщение
Scores will only be changed after registering/logging in.
You'll need some more scripts in OnPlayerDisconnect.
I'll tryed this code Under OnPlayerDisconnect

But Still wont give me my money back when I'll relog

Код:
new file[256], pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pname, sizeof(pname));
	format(file, sizeof(file), "\\Users\\%s.ini", pname);
	dini_IntSet(file, "money", GetPlayerMoney(playerid));



AW: Re: Score wont Save - xerox8521 - 08.04.2011

Quote:
Originally Posted by Basker101
Посмотреть сообщение
I'll tryed this code Under OnPlayerDisconnect

But Still wont give me my money back when I'll relog

Код:
format(file, sizeof(file), "Users/%s.ini", pname);
why \\ ?

you just need
pawn Код:
format(file, sizeof(file), "/Users/%s.ini", pname);



Re: AW: Re: Score wont Save - Basker101 - 08.04.2011

Quote:
Originally Posted by xerox8521
Посмотреть сообщение
why \\ ?

you just need
pawn Код:
format(file, sizeof(file), "/Users/%s.ini", pname);
Under OnPlayerDisconnet ?


AW: Score wont Save - xerox8521 - 08.04.2011

every time there where you / register or login or save stats into the userfile


Re: Score wont Save - Jochemd - 08.04.2011

I don't think there's any need for the \\. Where are your accounts located? If you tell me, I can probably tell you the problem.


Re: Score wont Save - -Rebel Son- - 08.04.2011

Yay! My tutorial! It's a crappy one at that.

Problem. is easy.

Under disconnect.

dini_IntSet(file, "score", GetPlayerScore(playerid));

and yes, it was a typo.
You only need /users/ Sorry.


Re: Score wont Save - Basker101 - 09.04.2011

Now The Score Saves but The Money Still not saving

Код:
new file[256], pname[MAX_PLAYER_NAME];
         GetPlayerName(playerid, pname, sizeof(pname));
         format(file, sizeof(file), "\\Users\\%s.ini", pname);
         dini_IntSet(file, "score", GetPlayerScore(playerid));
         dini_IntSet(file, "money", GetPlayerMoney(playerid));
This is what I'll have under OnPlayerDisconncet.