Script won't display dialog [MySQL]
#1

I am creating an account system using MySQL. I don't know what's wrong here, as the dialog to either to register/login won't show. Here's the code.

pawn Код:
public OnPlayerConnect(playerid)
{
    //RESERTTING VARIABLES:
    IsNewHere[playerid] = false;
    MaxLoginAmount[playerid] = 0;
    for(new playerdata:e; e < playerdata; ++e)
    pData[playerid][e] = 0;
   
    new query[128]; //We use this variable to format our query
    GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
    GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP
    mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
    // - We use mysql_format instead of format because we can use an %e specifier. %e specifier escapes a string so we can avoid sql injection which means we don't have to use mysql_real_escape_string
    // - Formatting our query; SELECT `Password`, `ID` FROM `players` WHERE `Username`='%e' means we are selecting a Password and ID's column in the table that has player's name in Username column.
    // - LIMIT 1; we only need 1 result to be shown
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    //lets execute the formatted query and when the execution is done, a callback OnAccountCheck will be called
    //You can name the callback however you like
    return 1;
}

public OnAccountCheck(playerid)
{
    new str[200];
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
        cache_get_field_content(0, "PASS", pData[playerid][Password], mysql, 129);
        pData[playerid][ID] = cache_get_field_content_int(0, "ID");
        printf("%s", pData[playerid][Password]); //Debug
        format(str, sizeof(str), "Welcome back to Reindience Roleplay, %s! \nLooks like your account is registered, please enter your password below:", GPName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "Welcome back to Reindience Roleplay!", str, "Login", "Quit");
    }
    else
    {
        format(str, sizeof(str), "Welcome to Reindience Roleplay, %s! \nLooks like your account is not registered, please enter a password below:", GPName(playerid));
        ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "Welcome to Reindience Roleplay!", str, "Register", "Quit");
    }
    return 1;
}
And yes, DIALOG_LOG and DIALOG_REG are already defined.
Reply
#2

Does it print your password?
Reply
#3

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Does it print your password?
No it doesn't. It probably won't, as there is no file where I have my data, in other words, I am not registered.
This was my first time running this script. I don't find any way.
Reply
#4

Are you running Streamer plugin by any chance? The latest updates for that plugin (2.7.3 and above) seem to interfere with the MySQL plugin, resulting in callbacks not getting called when they should.
Reply
#5

Make sure you haven't defined anyother dialog with same number

this is 'DIALOG_LOG'
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Are you running Streamer plugin by any chance? The latest updates for that plugin (2.7.3 and above) seem to interfere with the MySQL plugin, resulting in callbacks not getting called when they should.
Quote:
Originally Posted by Ryz
Посмотреть сообщение
Make sure you haven't defined anyother dialog with same number

this is 'DIALOG_LOG'
Dang it. Thank you guys for you help, but the case wasn't that.
Actually I started my dialog id's from 0, from where when I changed to starting from 1, dayum, it worked.
And no, I am not using any streamer yet.

Thank you for your help!

-CLOSED-
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
Are you running Streamer plugin by any chance? The latest updates for that plugin (2.7.3 and above) seem to interfere with the MySQL plugin, resulting in callbacks not getting called when they should.
This problem also happened to me.
Using the latest streamer update and MySQL R39-2 prevented my code to work as well, and I couldn't login because the callbacks from tqueries didn't get called.

That's why I reverted back to MySQL R34, which works perfectly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)