Dini reads wrongly!
#1

Who doesn't loves Dini..
I certainly do, but there's one thing annoying me I'll try to explain it below.
Please help me out here :P

Alright so I got a script where you can make an account and all, with money admin levels and such.
You can successfully register and make an account. And on my local server (127.0.0.1) it works all fine.
But when I'm going on to my dedicated server (or however you want to name it) I get the specs of another player who isn't even online.
So, my dini is mixing the file stats!

Here's the register form (Dialogs)
Код:
	if(dialogid == 6)
	{
	    format(UserFile, sizeof(UserFile), "UserFiles/%s.txt", udb_encode(playername));
		if(response)
		{
			PlayerInfo[playerid][Frank] = dini_Int(UserFile, "Frank:");
     	 	PlayerInfo[playerid][Faction] = dini_Int(UserFile, "Faction:");
      		PlayerInfo[playerid][adminlevel] = dini_Int(UserFile, "adminlevel:");
      		PlayerInfo[playerid][money] = dini_Int(UserFile, "money:");
      		PlayerInfo[playerid][bankmoney] = dini_Int(UserFile, "Bankmoney:");
      		PlayerInfo[playerid][age] = dini_Int(UserFile, "age:");
      		PlayerInfo[playerid][job] = dini_Int(UserFile,"job:");
			PlayerInfo[playerid][Phone] = dini_Int(UserFile,"Phone:");
		    dini_IntSet(UserFile,"Faction:",0);
		    dini_IntSet(UserFile,"Frank:",0);
		    dini_IntSet(UserFile,"job:",0);
		    dini_IntSet(UserFile,"PhoneNumber:",0);
		    dini_IntSet(UserFile,"Phone:",0);
		    dini_IntSet(UserFile, "Bankmoney:", 5000);
		    dini_IntSet(UserFile,"money:", 5000);
		    GivePlayerMoney(playerid, 5000);
			logged[playerid] = 1;
			SetPlayerColor(playerid, COLOR_WHITE);
  		}
	  	else
	  	{
			PlayerInfo[playerid][Frank] = dini_Int(UserFile, "Frank:");
     	 	PlayerInfo[playerid][Faction] = dini_Int(UserFile, "Faction:");
      		PlayerInfo[playerid][adminlevel] = dini_Int(UserFile, "adminlevel:");
      		PlayerInfo[playerid][money] = dini_Int(UserFile, "money:");
      		PlayerInfo[playerid][bankmoney] = dini_Int(UserFile, "Bankmoney:");
      		PlayerInfo[playerid][job] = dini_Int(UserFile,"job:");
      		PlayerInfo[playerid][age] = dini_Int(UserFile, "age:");
			PlayerInfo[playerid][Phone] = dini_Int(UserFile,"Phone:");
		    dini_IntSet(UserFile,"Faction:",0);
		    dini_IntSet(UserFile,"Frank:",0);
	  	    dini_IntSet(UserFile,"job:",0);
	  	    dini_IntSet(UserFile,"PhoneNumber:",0);
	  	    dini_IntSet(UserFile,"Phone:",0);
		    dini_IntSet(UserFile, "Bankmoney:", 5000);
		    dini_IntSet(UserFile,"money:", 5000);
		    GivePlayerMoney(playerid, 5000);
        	logged[playerid] = 1;
        	SetPlayerColor(playerid, COLOR_WHITE);
		}
		return 1;
	}
And before that a UserFile.txt has been made already of course.

Now here's the login code:
Код:
new password[MAX_PLAYER_NAME];
     	 	new message[128];
     	 	PlayerInfo[playerid][Frank] = dini_Int(UserFile, "Frank:");
     	 	PlayerInfo[playerid][Faction] = dini_Int(UserFile, "Faction:");
      		password[playerid] = dini_Int(UserFile, "password");
      		PlayerInfo[playerid][adminlevel] = dini_Int(UserFile, "adminlevel:");
      		PlayerInfo[playerid][money] = dini_Int(UserFile, "money:");
      		PlayerInfo[playerid][bankmoney] = dini_Int(UserFile, "Bankmoney:");
      		PlayerInfo[playerid][job] = dini_Int(UserFile,"job:");
			dini_Get(UserFile, "Origin:");
			PlayerInfo[playerid][Phone] = dini_Int(UserFile,"Phone:");
			SendClientMessage(playerid, COLOR_ORANGE, "Want to quit? Type 'quit' in the login bar.");
      		if(password[playerid] != udb_hash(inputtext))
	 		{
    			SendClientMessage(playerid, COLOR_RED, "The password is wrong.");
  				ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Welcome to the RP project","Please enter your password","Login","Cancel");
      		}
 			else
	 		{
	 		    if(logged[playerid] == 0)
	 		    {
	 		    	PlayerInfo[playerid][money] = dini_Int(UserFile, "money:");
                	format(message, sizeof(message), "%s you have succesfully logged in.", playername, inputtext);
                	SendClientMessage(playerid, COLOR_YELLOW, message);
                	logged[playerid] = 1;
                	GivePlayerMoney(playerid, PlayerInfo[playerid][money]);
                	TogglePlayerControllable(playerid,1);
                	SetPlayerColor(playerid, COLOR_WHITE);
				}
				else
				{
				    SendClientMessage(playerid, COLOR_YELLOW, "You're already logged in!");
				    return 0;
				}
 			}
The compiler gives me no errors and it works fine on my servers as long as it includes ONE saved player.
Got the problem? :P If not, please take a second to ask me or to explain it to me .

OH and before I forget, I do save the new variables made while in game at Disconnect of course. But that's not the problem either.
Reply
#2

You must reset all variables (set them to 0) on connect. Otherwise they can be messed up
Reply
#3

Still doesn't work.
Plus, sometimes the password doesn't work.
Reply
#4

Quote:
Originally Posted by Himynameis
Посмотреть сообщение
Still doesn't work.
Plus, sometimes the password doesn't work.
That could be because you have to use strcmp to compare strings, not standard operators.

And do not use dini, it is outdated and inefficient. I cannot possibly see why people still use it when there was a new release, djSon, which was specifically created to replace dini - Hence the name, dini2!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)