Mysql stats saving problem.
#1

I have a problem with stats saving: I want to do that then player disconnect stats of the this player will save to mysql base.
Everything works fine and files saves to mysql base without bug but then player login he cant get this Scores...
There is my codes:
Код:
	if(dialogid == 05)
	{
	   if(response)
	   {
		  new name[128],query[256],scores[300];
		  GetPlayerName(playerid,name,128);
		  if(IsPlayerConnected(playerid))
		  {
			  MySQLCheck();
			  format(query,sizeof(query),"SELECT Money FROM `"TABLENAME"` WHERE Name = '%s' AND Password = md5('%s') LIMIT 1",name,inputtext);
			  mysql_query(query);
			  format(scores,sizeof(scores),"SELECT Scores FROM `"TABLENAME"` WHERE Name = '%s' AND Password = md5('%s') LIMIT 1",name,inputtext);
			  mysql_query(scores);
			  mysql_store_result();
			  
			  if(mysql_num_rows() == 1)
			  {
				 PlayerMoney[playerid] = mysql_fetch_int();
				 PlayerTaskai[playerid] = mysql_query("SELECT Scores FROM `"TABLENAME"` WHERE Name = '%s' AND Password = md5('%s') LIMIT 1",name,inputtext);
				 SendClientMessage(playerid,COLOR_LIGHTGREEN,"Jūs sėkmingai prisijungėte. Sekmės! ;)");
				 GivePlayerMoney(playerid,PlayerMoney[playerid]);
				 SetPlayerScore(playerid,PlayerTaskai[playerid]);
				 Logged[playerid] = true;
			  }
			  else
			  {
			     mysql_free_result();
				 ShowPlayerDialog(playerid,05,DIALOG_STYLE_INPUT,"Prisijungimas","Jūs įvedėte neteisingą slaptaћodį, proљome įvesti\n jūsų tikrą slaptaћodį.","Prisijungti","Iseiti");
				 return SendClientMessage(playerid,COLOR_RED,"Slaptaћodis neteisingas.");
			  }
		  }
		  else
		  {
			  mysql_store_result();
			  mysql_free_result();
		  }
	   }
	   else if(!response)
	   {
		  Kick(playerid);
		  return 1;
	   }
	   return 1;
	}
	return 1;
}
Please help me.
Reply
#2

Maybe change "TableName" to your table name..?
Reply
#3

mysql log?
Reply
#4

instead of 'vardas' shouldn't it be 'name' ?
Reply
#5

Quote:
Originally Posted by GamingTurf
Посмотреть сообщение
instead of 'vardas' shouldn't it be 'name' ?
It doesn't matter what it is, as long as it is introduced/declared with the 'new' statement...

He's a different language, chill out a bit.
Reply
#6

No, that's his problem.


His code:
new name[128],query[256],scores[300];
GetPlayerName(playerid,name,12;

Its getting the player's name, and putting it into the int "name".

Then continuing, with doing nothing with any name's, the query is called:

format(scores,sizeof(scores),"SELECT Scores FROM `"TABLENAME"` WHERE Name = '%s' AND Password = md5('%s') LIMIT 1",vardas,inputtext);

Its put down that the MySQL Name is 'vardas' - but vardas doesnt even exist in this example, so it's getting the name from nowhere.

Replace vardas with name and it should work fine.


=======
To schurman

Shutup, you don't know anything.
Reply
#7

Quote:
Originally Posted by GamingTurf
Посмотреть сообщение
instead of 'vardas' shouldn't it be 'name' ?
Yes its name I am translate it form lithuanian language and I noticed this bug, but in my code its all right...
Reply
#8

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Maybe change "TableName" to your table name..?
No I defined it:
Код:
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_PASS ""
#define SQL_DB "serveris"
#define TABLENAME "vartotojai"
Reply
#9

Change your query to:

pawn Код:
SELECT `Scores` FROM `"TABLENAME"` WHERE `Name` = '%s' AND `Password` = md5('%s') LIMIT 1
Also, your problem is that you're trying to execute two queries in the same area which is causing problems, because your money variable is going to be your score, because it's the result stored, and you can't get a value from MySQL by trying to assign it as mysql_query().
Reply
#10

pawn Код:
...
                MySQLCheck();
                format(query,sizeof(query),"SELECT Money FROM `"TABLENAME"` WHERE Name = '%s' AND Password = md5('%s') LIMIT 1",name,inputtext);
                mysql_query(query);
                mysql_store_result();
               
                if(mysql_num_rows() == 1)
                {
                    PlayerMoney[playerid] = mysql_fetch_int();
                    mysql_free_result();
                    format(query,sizeof(query),"SELECT Scores FROM `"TABLENAME"` WHERE Name = '%s' AND Password = md5('%s') LIMIT 1",name,inputtext);
                    mysql_query(query);
                    mysql_store_result();
                    PlayerTaskai[playerid] = mysql_fetch_int();
                    mysql_free_result();
                    SendClientMessage(playerid,COLOR_LIGHTGREEN,"Jūs sėkmingai prisijungėte. Sekmės! ;)");
                    GivePlayerMoney(playerid,PlayerMoney[playerid]);
                    SetPlayerScore(playerid,PlayerTaskai[playerid]);
                    Logged[playerid] = true;
                }
...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)