SA-MP Forums Archive
Mysql - 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)
+--- Thread: Mysql (/showthread.php?tid=548385)



Mysql - MikE1990 - 29.11.2014

I have problem with newest mysql when i connect to server dialog doesnt appear.
Код:
public OnPlayerConnect(playerid)
{
	new string[255];
    GetPlayerName(playerid,PlayerInfo[playerid][Username],128);
	format(string,255,"SELECT * FROM `accounts` WHERE Username = '%s'",PlayerInfo[playerid][Username]);
	mysql_function_query(Mysql,string,true,"Check","i",playerid);
	return 1;
}
forward Check(playerid);
public Check(playerid)
{
	new rows,fields;
	cache_get_data(rows,fields);
	if(rows)
	{
	    ShowPlayerDialog(playerid, Dialog_Login, DIALOG_STYLE_PASSWORD, "Login", "Type your password below to login.", "Login", "Quit");
	}
	else
	{
	    ShowPlayerDialog(playerid, Dialog_Register, DIALOG_STYLE_PASSWORD, "Register", "Type your password below to register.", "Register", "Quit");
	}
	return 1;
}



Re: Mysql - Chilli9434 - 29.11.2014

Can you show a copy of the MySQL Log?


Re: Mysql - Galletziz - 29.11.2014

you use invalid function for check if player is registered or not, you must use, cache_num_rows() or cache_get_row_count() function.


Re: Mysql - Galletziz - 29.11.2014

Quote:
Originally Posted by Galletziz
Посмотреть сообщение
you use invalid function for check if player is registered or not, you must use, cache_num_rows() or cache_get_row_count() function.
pawn Код:
if(cache_get_row_count < 1 ) {
 //player isn't registered
}else{
 //player is registered
}
sorry for duble post.. з_з


Re: Mysql - MikE1990 - 29.11.2014

Quote:

Can you show a copy of the MySQL Log?

Код:
[16:37:46] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:37:46] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:37:46] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:37:46] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:37:46] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:37:46] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:37:46] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:38:09] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `accounts` WHERE Username = 'Test'", callback: "Check", format: "i"
[16:38:09] [DEBUG] CMySQLQuery::Execute[Check] - starting query execution
[16:38:09] [DEBUG] CMySQLQuery::Execute[Check] - query was successfully executed within 0.581 milliseconds
[16:38:09] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[16:38:09] [DEBUG] Calling callback "Check"..
[16:38:09] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
Quote:

you use invalid function for check if player is registered or not, you must use, cache_num_rows() or cache_get_row_count() function.

I tried withg cache_get_row_count() but same


Re: Mysql - MikE1990 - 29.11.2014

Help please


Re: Mysql - Galletziz - 29.11.2014

Look, you must download another include, this is the best that you can use and then, you can do as i explain
https://sampforum.blast.hk/showthread.php?tid=337810


Re: Mysql - MikE1990 - 29.11.2014

I think problem is in mysql_function_query tried to print rows but nothing print


Re: Mysql - Raweresh - 29.11.2014

This functions is not anymore in mysql cache version (R33+), download last mysql plugin and include. In gamemode change mysql_function_query to mysql_tquery or mysql_pquery.


Re: Mysql - MikE1990 - 29.11.2014

I downloaded lastest plugin and changed script little bit.
Код:
public OnPlayerConnect(playerid)
{
	new string[255];
    GetPlayerName(playerid,PlayerInfo[playerid][Username],128);
	format(string,255,"SELECT * FROM `accounts` WHERE Username = '%s'",PlayerInfo[playerid][Username]);
	mysql_tquery(Mysql,string,"Check","i",playerid);
	return 1;
}
forward Check(playerid);
public Check(playerid)
{
	printf("%i",cache_get_row_count());
	if(cache_get_row_count() < 1)
	{
        ShowPlayerDialog(playerid, Dialog_Register, DIALOG_STYLE_PASSWORD, "Register", "Type your password below to register.", "Register", "Quit");
	}
	else
	{
	    ShowPlayerDialog(playerid, Dialog_Login, DIALOG_STYLE_PASSWORD, "Login", "Type your password below to login.", "Login", "Quit");
	}
	return 1;
}
But its same