SA-MP Forums Archive
dialog not showing - 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: dialog not showing (/showthread.php?tid=602656)



dialog not showing - austin070 - 10.03.2016

For some reason, this dialog is refusing to show under any conditions. I added some debug lines and 'a' and 'c' print. 'b' does not print because it never makes it to the existing file condition because the registration dialog does not appear.

pawn Код:
#define dialog_login 1
#define dialog_register 2

stock ShowPlayerRegister(playerid)
{
    ShowPlayerDialog(playerid, dialog_register, DIALOG_STYLE_INPUT, "Welcome to ARP!", "Enter a password to register your account.", "Register", "Cancel");
}


forward CheckPlayerExists(playerid);
public CheckPlayerExists(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, sHandle);

    if(rows)
    {
        cache_get_field_content(0, "password", PlayerInfo[playerid][Password], sHandle, 129);
        ShowPlayerLogin(playerid);
        print("b");
    }
    else
    {
        print("c");
        ShowPlayerRegister(playerid);
    }

    return 1;
}


public OnPlayerConnect(playerid)
{
    new query[128];
    mysql_format(sHandle, query, sizeof(query), "SELECT `password` FROM `users` WHERE `name` = '%e' LIMIT 1", GetPName(playerid));
    mysql_tquery(sHandle, query, "CheckPlayerExists", "i", "playerid");
    print("a");
   
    return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case dialog_login:
        {
            if(!response) Kick(playerid);
           
            new hash[129], query[128];
            WP_Hash(hash, sizeof(hash), inputtext);
            if(strcmp(hash, PlayerInfo[playerid][Password])== 0)
            {
                mysql_format(sHandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%e' LIMIT 1", GetPName(playerid));
                mysql_tquery(sHandle, query, "OnAccountLoad", "i", "playerid");
            }
            else
            {
                ShowBadLogin(playerid);
            }
        }
        case dialog_register:
        {
            if(!response) Kick(playerid);
            if(!strlen(inputtext)) ShowBadRegister(playerid);
           
            new query[512];
            new ip[24];
           
            GetPlayerIp(playerid, ip, 24);
            WP_Hash(PlayerInfo[playerid][Password], 129, inputtext);
           
            mysql_format(sHandle, query, sizeof(query), "INSERT INTO `users` (`name`, `password`, `ip`, `adminlevel`, `posx`, `posy`, `posz`, `posa`, `money`, `bank`) VALUES ('%e', '%e', '%e', 0, '%f', '%f', '%f', '%f', 0, 0)", GetPName(playerid), PlayerInfo[playerid][Password], ip, 0, 0, 0, 0, 0, 0);
            mysql_tquery(sHandle, query, "SendQuery");
        }
    }

    return 1;
}



Re: dialog not showing - Joron - 10.03.2016

Show the dialog again Onplayerconnect..


Re: dialog not showing - austin070 - 10.03.2016

Quote:
Originally Posted by Joron
Посмотреть сообщение
Show the dialog again Onplayerconnect..
It's not supposed to be shown regardlessly in OnPlayerConnect. That's why I have it in CheckPlayerExists.


Re: dialog not showing - zPain - 10.03.2016

Add a print to the ShowPlayerRegister function just to make sure it's being executed.


Re: dialog not showing - austin070 - 10.03.2016

Quote:
Originally Posted by zPain
Посмотреть сообщение
Add a print to the ShowPlayerRegister function just to make sure it's being executed.
I did this and it does call the function.


Re: dialog not showing - zPain - 10.03.2016

Quote:
Originally Posted by austin070
Посмотреть сообщение
I did this and it does call the function.
That's odd. Did you check the mysql_log?


Re: dialog not showing - austin070 - 10.03.2016

Quote:
Originally Posted by zPain
Посмотреть сообщение
That's odd. Did you check the mysql_log?
Yes. No errors.


Re: dialog not showing - Joron - 10.03.2016

Instead of print("a"); try print("c"); onplayerconnect
Am Guessing eh.


Re: dialog not showing - zPain - 10.03.2016

Quote:
Originally Posted by Joron
Посмотреть сообщение
Instead of print("a"); try print("c"); onplayerconnect
Am Guessing eh.
With all due respect, that's preposterous.


Re: dialog not showing - austin070 - 10.03.2016

Quote:
Originally Posted by zPain
Посмотреть сообщение
With all due respect, that's preposterous.
Indeed.

I have no other leads to what the issue is.