SA-MP Forums Archive
Function Not Called (MySQL_Function_Query) - 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: Function Not Called (MySQL_Function_Query) (/showthread.php?tid=461512)



Function Not Called (MySQL_Function_Query) - viveka27 - 02.09.2013

CODE
Код:
public SafeOnPlayerConnect(playerid)
{
    SendClientMessage(playerid, WHITE, "[DEBUG]: MAU #1");
	CheckAccount(playerid);
	return 1;
}
public CheckAccount(playerid)
{	
    new query[82];

	format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
	mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
    SendClientMessage(playerid, WHITE, "[DEBUG]: Mau #2");
	return 1;
}
public OnAccountCheck(playerid)
{
	if(playerid != INVALID_PLAYER_ID) {

		new rows, fields;
		cache_get_data(rows, fields, handle);
		new string[250];
		for (new i = 1; i <= 50; i++) SendClientMessage(playerid, -1, " ");
        SendClientMessage(playerid, WHITE, "[DEBUG]: Mau #3");
		if(rows) {
			cache_get_row(0,2,PlayerInfo[playerid][pKey],handle, 128);
			format(string, sizeof(string), "Selamat Datang Kembali Di %s, %s.", SERVER_NAME, PlayerName(playerid));
			SendClientMessage(playerid, GREY, string);
            SendClientMessage(playerid, WHITE, "[DEBUG]: Show Dialog Login");
			SendClientMessage(playerid, WHITE, "That name is currently registered, please log into your account.");
			ShowMainMenuDialog(playerid, 1);
		}
		else {
			format(string, sizeof(string), "Selamat Datang Di %s, %s.", SERVER_NAME, PlayerName(playerid));
			SendClientMessage(playerid, GREY, string);
            SendClientMessage(playerid, WHITE, "[DEBUG]: Show Dialog Register");
			SendClientMessage(playerid, WHITE, "That name is currently not registered.");
			SendClientMessage(playerid, WHITE, "If you wish to register, please input your password in the box below.");
			ShowMainMenuDialog(playerid, 2);
		}
	}
	return 1;
}
And I am Set Timer in onplayerconnect
SetTimerEx("SafeOnPlayerConnect", 1000, 0, "d", playerid);

But OnAccountCheck not called.So Screen Like This

MySQL Log:
Код:
16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:29] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:30:29] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
[16:30:46] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:31:19] [ERROR] "mysql_tquery" - invalid connection handle. (ID = 0).
[16:31:19] [ERROR] "cache_get_data" - invalid connection handle. (ID = 1).
Question:
How To Fix It? Thanks



Re: Function Not Called (MySQL_Function_Query) - Konstantinos - 02.09.2013

What does the mysql log print?


Re: Function Not Called (MySQL_Function_Query) - viveka27 - 02.09.2013

Where I Can Find It? I'm have check mysql_error_log.txt(Custom Script to write onqueryerror)


Re: Function Not Called (MySQL_Function_Query) - WopsS - 02.09.2013

What is your MySQL version? And change
pawn Код:
format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
with
pawn Код:
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);



Re: Function Not Called (MySQL_Function_Query) - Konstantinos - 02.09.2013

It's on the main directory. It's on the same place where samp-server.exe is located at. If it failed for some reason, it would write the reason.


Re: Function Not Called (MySQL_Function_Query) - Armyy - 02.09.2013

When u have "mysql_debug(1)" in OnGameModeInit you can find your MySQL log in file Debug.txt, it's like server_log.txt

Edit: or in newest version it's "mysql_log(1-4)" and log is in file mysql_log.txt


Re: Function Not Called (MySQL_Function_Query) - viveka27 - 03.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It's on the main directory. It's on the same place where samp-server.exe is located at. If it failed for some reason, it would write the reason.
I Have Check it.No Error founded


Re: Function Not Called (MySQL_Function_Query) - Lorenc_ - 03.09.2013

Quote:
Originally Posted by WopsS
Посмотреть сообщение
What is your MySQL version? And change
pawn Код:
format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
with
pawn Код:
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
You realise you've worsened the query that way?

OT: Use print checks everywhere, see if the callback is being actually called.


Re: Function Not Called (MySQL_Function_Query) - viveka27 - 03.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It's on the main directory. It's on the same place where samp-server.exe is located at. If it failed for some reason, it would write the reason.
I Have Check it.No Error founded


Re: Function Not Called (MySQL_Function_Query) - viveka27 - 03.09.2013

Quote:
Originally Posted by WopsS
Посмотреть сообщение
What is your MySQL version? And change
pawn Код:
format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
with
pawn Код:
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", PlayerName(playerid));
    mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
I Have change it.Still Same.Callback not called