Help - Login/Register system.
#1

pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        if(PlayerInfo[playerid][pBan] == 1)
        {
            Kick(playerid);
            SCM(playerid, RED, "You are banned.");
        }
        else
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
        }
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}
Do you see anything wrong with this? It compiles, but when I go in game neither register or login dialog shows up.
Reply
#2

Because you forgot the OnDialogResponse
Reply
#3

Try it under OnPlayerRequestClass instead.
Reply
#4

Quote:
Originally Posted by (A)rray
Посмотреть сообщение
Because you forgot the OnDialogResponse
*Facepalm* The dialog doesn't show up...Oh my god..Read please.
Reply
#5

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
*Facepalm* The dialog doesn't show up...Oh my god..Read please.
Exactly why he said it... You need to script what the dialog will do also. I believe you are following this tutorial:

https://sampforum.blast.hk/showthread.php?tid=273088

So just following everything on the tutorial, and it should work out perfectly.
Reply
#6

*Facepalm* I have a dialog response...

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Faction",0);
                INI_WriteInt(File,"Frank",0);
                INI_WriteInt(File,"LeaderFlag",0);
                INI_WriteFloat(File,"Health",100);
                INI_WriteFloat(File,"Armor",0);
                INI_WriteFloat(File,"X",0);
                INI_WriteFloat(File,"Y",0);
                INI_WriteFloat(File,"Z",0);
                INI_WriteInt(File,"VW",0);
                INI_WriteInt(File,"Interior",0);
                INI_WriteInt(File,"Skin", 7);
                INI_Close(File);
                pLogged[playerid] = 1;
                SetSpawnInfo(playerid, 0, 7, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_GREEN"Success!",""COL_RED"You are now registered on our server, welcome.","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    pLogged[playerid] = 1;
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ], 269.15, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by JJB562
Посмотреть сообщение
Exactly why he said it... You need to script what the dialog will do also. I believe you are following this tutorial:

https://sampforum.blast.hk/showthread.php?tid=273088

So just following everything on the tutorial, and it should work out perfectly.
Wrong,you can put a dialog with nothing to OnDialogResponse,but when you select something nothing happen but the dialog appaer.
I thing that your problem is becouse you didn`t put the dialog to show on he`s place.
Try to put it on OnPlayerRequescClass
Reply
#8

check your dialog's ids again? make sure it's not colliding with any other.
Reply
#9

pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        if(PlayerInfo[playerid][pBan] == 1)
        {
            Kick(playerid);
            SCM(playerid, RED, "You are banned.");
        }
        else
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{FFFFFF}Login", "{FFFFFF}Type your password below to login.", "Login", "Quit");
        }
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{FFFFFF}Registering...", "{FFFFFF}Type your password below to register a new account.", "Register", "Quit");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)