Mysql select
#1

Hello! not works(
Code:
Код:
stock OnPlayerLogin(playerid,password[])
{
    new Pass[32],str[1000],string[128],query[256];
    format(query, sizeof(query), "SELECT * FROM `players` WHERE `pNick` = '%s' LIMIT 1", sendername(playerid));
	if(mysql_query(query) && mysql_store_result())
	{
	    if(mysql_num_rows())
    	{
			if(mysql_fetch_row_format(str))
			{
				sscanf(str, "p<|>ds[24]s[34]dddd",
		               PlayerInfo[playerid][pID],sendername(playerid), Pass,
				PlayerInfo[playerid][pScore],
				PlayerInfo[playerid][pAdminLevel],
				PlayerInfo[playerid][pMoney],
				PlayerInfo[playerid][pSkin]);
				if(!(strcmp(password,Pass,true)))
				{
					SpawnPlayer(playerid);
					gPlayerLogged[playerid] = 1;
					printf("Logged");
				}
			    else
				{
                                 if bad password...
				}
			}
		}
	}
	mysql_free_result();
	return true;
}
Reply
#2

Up! I need help
Reply
#3

Try this
Код:
stock OnPlayerLogin(playerid,password[])
{
    new Pass[32],str[1000],string[128],query[256];
    format(query, sizeof(query), "SELECT * FROM `players` WHERE `pNick` = '%s' LIMIT 1", sendername(playerid));
	mysql_query(query)
	mysql_store_result()
 	if(mysql_num_rows())
	{
		if(mysql_fetch_row_format(str))
		{
			sscanf(str, "p<|>ds[24]s[34]dddd",
   			PlayerInfo[playerid][pID],sendername(playerid), Pass,
			PlayerInfo[playerid][pScore],
			PlayerInfo[playerid][pAdminLevel],
			PlayerInfo[playerid][pMoney],
			PlayerInfo[playerid][pSkin]);
			if(!(strcmp(password,Pass,true)))
			{
				SpawnPlayer(playerid);
				gPlayerLogged[playerid] = 1;
				printf("Logged");
			}
   			else
			{
   				if bad password...
			}
		}
	}
	mysql_free_result();
	return 1;
}
Reply
#4

Not works again(
Reply
#5

Can you explain more and can you give mysql log?
Reply
#6

Код:
[16:52:47] CMySQLHandler::Query(SELECT * FROM `players` WHERE `pNick` = 'Admin' LIMIT 1) - Successfully executed.

[16:52:47] >> mysql_store_result( Connection handle: 1 )

[16:52:47] CMySQLHandler::StoreResult() - Result was stored.

[16:52:47] >> mysql_num_rows( Connection handle: 1 )

[16:52:47] CMySQLHandler::NumRows() - Returned 1 row(s)

[16:52:47] >> mysql_fetch_row_format( Connection handle: 1 )

[16:52:47] CMySQLHandler::FetchRow() - Return: 1|Admin|123456|127.0.0.1|0|115|0|228

[16:52:47] >> mysql_free_result( Connection handle: 1 )

[16:52:47] CMySQLHandler::FreeResult() - Result was successfully free'd.

[16:53:07] >> mysql_ping( Connection handle: 1 )

[16:53:07] CMySQLHandler::Ping() - Connection is still alive.

[16:53:07] >> mysql_query( Connection handle: 1 )

[16:53:07] CMySQLHandler::Query(UPDATE players SET `pAdminLevel`=0, `pScore`=0, `pMoney`=0, `pSkin`=0 WHERE `pNick` = 'Admin') - Successfully executed.
Reply
#7

Ok and what is the problem ?
Reply
#8

Stats not loading
Reply
#9

can you change this
Код:
if(!strcmp(password,Pass,true)))
with
Код:
if(!strcmp(password,Pass, false))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)