SA-MP Forums Archive
[MySQL] tquery does not call callback correctly. - 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] tquery does not call callback correctly. (/showthread.php?tid=603331)



[MySQL] tquery does not call callback correctly. - introzen - 21.03.2016

Hello!

I have a problem. I'm calling a LoginQuery(); from OnPlayerConnect();

This is the code
pawn Код:
forward LoginQuery(playerid);
public LoginQuery(playerid) {
    new query[256];
    mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `players` WHERE `Name` = '%e' LIMIT 1", PlayerName(playerid));
    mysql_tquery(mysql, query, "OnPlayerRegisteredCheck", "i", playerid);
        SendInfoMessage(playerid,"test"); //This is sent to the chat.
    return 1;
}

forward OnPlayerRegisteredCheck(playerid);
public OnPlayerRegisteredCheck(playerid) {
    SendInfoMessage(playerid, "Registered, please login."); //This isn't sent to the player.
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows) {
        cache_get_field_content(0, "Password", PlayerInfo[playerid][pPassword], mysql, 128);
        PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
        ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", "Welcome back!\nYour username is registered. Please fill in your password:", "Login", "Quit");
    } else {
        SendErrorMessage(playerid, "In order to play on this server, you need to fill in an application on http://test.com/.");
        SendErrorMessage(playerid, "Applications are normally responded on within 24 hours. Good luck.");
        SendInfoMessage(playerid, "Should you already be registered, please make sure your character-name is set correctly.");
        Kick(playerid);
    }
    return 1;
}
The second callback OnPlayerRegisteredCheck(); isn't called for some reason. As seen in the code above, the SendInfoMessage(); isn't sent. The function works however.

Any idea is welcome.


Re: [MySQL] tquery does not call callback correctly. - zPain - 21.03.2016

Did you check the mysql log? What does it say?


Re: [MySQL] tquery does not call callback correctly. - introzen - 22.03.2016

Quote:
Originally Posted by zPain
Посмотреть сообщение
Did you check the mysql log? What does it say?
Thank you. Seems like I'm a complete retard but I sure have a lesson learned now.

Problem was connection error.