[Help] Register and Login Dialogs are not working correctly
#1

REMOVED
Reply
#2

Bump
Reply
#3

Try to remove the
PHP код:
PlayerInfo[playerid][FirstLog] = 0
which is below the dialog of login
Reply
#4

Quote:
Originally Posted by Clad
Посмотреть сообщение
Try to remove the
PHP код:
PlayerInfo[playerid][FirstLog] = 0
which is below the dialog of login
I've tried moving it under OnPlayerSpawn, and that causes the player not to spawn after logging in.
Reply
#5

pawn Код:
#define DIALOG_REGISTER 200
#define DIALOG_LOGIN 201

public OnPlayerConnect(playerid)
{
    SetPVarInt(playerid, "ConnectTime", GetTickCount());
    new file[96],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file,sizeof(file),"/User_Database/%s.ini",pName);
    attempt[playerid] = 0;
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 200, DIALOG_STYLE_INPUT, "Account", "A registration is required to play on this server. \nPlease fill in a password to create a free account!", "Register", "Cancel");
    } else {
        ShowPlayerDialog(playerid, 201, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
    }
    SpamCount[playerid]=0;
    AutoRepairUsed[playerid] = 0;
    AdminDuty[playerid] = 0;
    AutoRepairTrigger[playerid] = 0;
    PlayerInfo[playerid][FirstLog] = 0;
    TextDrawShowForPlayer(playerid,WebsiteTextdraw);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    //---------------------------ANTI CHEAT-----------------------------------------
    #if defined AntiCheat
    Timer[playerid] = SetTimerEx("CheckPing",3000,1,"i",playerid);
    Timer2[playerid] = SetTimerEx("CheckMG",1000,1,"i",playerid);
    Timer3[playerid] = SetTimerEx("ArmourHack",1000,1,"i",playerid);
    Timer4[playerid] = SetTimerEx("Jetpack",1000,1,"i",playerid);
    Timer5[playerid] = SetTimerEx("SpeedHack",1000,1,"i",playerid);
    #endif
    if (PlayerInfo[playerid][FirstLog] == 1)
    {
        SetPlayerPos(playerid,1573.4,-2330.8,13.2);
        SetPlayerFacingAngle(playerid, 90);
        SetCameraBehindPlayer(playerid);
        PlayerInfo[playerid][FirstLog] = 0;
    }
    else if (PlayerInfo[playerid][FirstLog] == 0)
    {
        new pName[MAX_PLAYER_NAME];GetPlayerName(playerid, pName, sizeof(pName));
        new file[96];format(file,sizeof file,"/User_Database/%s.ini",pName);
        INI_ParseFile(file, "GetData", .bExtra = true, .extra =playerid);
        SetPlayerPos(playerid,PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ]);
        SetPlayerFacingAngle(playerid,PlayerInfo[playerid][Ang]);
        SetPlayerInterior(playerid,PlayerInfo[playerid][Int]);
        SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][VW]);
        SetPlayerSkin(playerid,PlayerInfo[playerid][Skin]);
        SetCameraBehindPlayer(playerid);
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER) //register dialog
    {
        if(response)
        {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            new file[96];
            format(file,sizeof(file),"/User_Database/%s.ini",pName);
            if(!fexist(file))
            {
                new INI:handler = INI_Open(file);
                PlayerInfo[playerid][level] = 0;
                INI_WriteString(handler,"Password",inputtext);
                INI_WriteInt(handler,"Score",0);
                INI_WriteInt(handler,"Money",0);
                INI_WriteInt(handler,"Playerlevel",0);
                INI_WriteFloat(handler, "PosX", 0);
                INI_WriteFloat(handler, "PosY", 0);
                INI_WriteFloat(handler, "PosZ", 0);
                INI_WriteInt(handler,"FirstLog", 1);
                INI_Close(handler);
                PlayerInfo[playerid][FirstLog] = 1;
            }
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
        } else Kick(playerid);
    }
    if(dialogid == DIALOG_LOGIN) //login dialog
    {
        if(response)
        {
            new pName[MAX_PLAYER_NAME];GetPlayerName(playerid, pName, sizeof(pName));
            new file[96];format(file,sizeof file,"/User_Database/%s.ini",pName);
            INI_ParseFile(file, "GetData", .bExtra = true, .extra =playerid);
            SendClientMessage(playerid, COLOR_GREEN,"You have succesfully logged in!");
            if (strcmp(inputtext, PlayerInfo[playerid][password]))
            {
                new string[128];
                if (attempt[playerid] <3)
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
                    attempt[playerid]++;
                    PlayerPlaySound(playerid,1057,0,0,0);
                    printf("%s has failed to login", pName);
                    format(string,sizeof string,"Invalid password! [%i/3]",attempt[playerid]);
                    SendClientMessage(playerid, 0xFF3200FF, string);
                    attempt[playerid] = attempt[playerid]++;
                } else {
                    GetPlayerName(playerid,pName,8);
                    format(string,sizeof string,"%s(%i) Has been kicked by the server(Failed to login).",pName,playerid);
                    SendClientMessageToAll(COLOR_GRAY,string);
                    Kick(playerid);
                }
            }
            else if (!strcmp(inputtext, PlayerInfo[playerid][password]))
            {
                if (PlayerInfo[playerid][FirstLog] == 0)
                {
                    SpawnPlayer(playerid);
                    return 1;
                }
                if (PlayerInfo[playerid][FirstLog] == 1)
                {
                    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Gender Selection", "Choose a gender:", "Male", "Female");
                    SetPlayerPos(playerid, 1555.5999800,-2312.6001000,-23.4000000);
                    SetPlayerFacingAngle(playerid, 160);
                    SetPlayerCameraPos(playerid, 1554.5999800,-2315.6001000,-22.0000000);
                    SetPlayerCameraLookAt(playerid, 1555.5999800,-2312.6001000,-23.0000000);
                    return 1;
                }
            }
        } else Kick(playerid);
    }
    if(dialogid == 1)
    {
        //do something here
        //if you wish to spawn player use SpawnPlayer(playerid);
        return 1;
    }
    return 0;
}
can you show me the gender choosing Dialog response?
Reply
#6

Added dialog 1.
Reply
#7

Quote:
Originally Posted by mahardika
Посмотреть сообщение
pawn Код:
#define DIALOG_REGISTER 200
#define DIALOG_LOGIN 201

public OnPlayerConnect(playerid)
{
    SetPVarInt(playerid, "ConnectTime", GetTickCount());
    new file[96],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file,sizeof(file),"/User_Database/%s.ini",pName);
    attempt[playerid] = 0;
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 200, DIALOG_STYLE_INPUT, "Account", "A registration is required to play on this server. \nPlease fill in a password to create a free account!", "Register", "Cancel");
    } else {
        ShowPlayerDialog(playerid, 201, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
    }
    SpamCount[playerid]=0;
    AutoRepairUsed[playerid] = 0;
    AdminDuty[playerid] = 0;
    AutoRepairTrigger[playerid] = 0;
    PlayerInfo[playerid][FirstLog] = 0;
    TextDrawShowForPlayer(playerid,WebsiteTextdraw);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    //---------------------------ANTI CHEAT-----------------------------------------
    #if defined AntiCheat
    Timer[playerid] = SetTimerEx("CheckPing",3000,1,"i",playerid);
    Timer2[playerid] = SetTimerEx("CheckMG",1000,1,"i",playerid);
    Timer3[playerid] = SetTimerEx("ArmourHack",1000,1,"i",playerid);
    Timer4[playerid] = SetTimerEx("Jetpack",1000,1,"i",playerid);
    Timer5[playerid] = SetTimerEx("SpeedHack",1000,1,"i",playerid);
    #endif
    if (PlayerInfo[playerid][FirstLog] == 1)
    {
        SetPlayerPos(playerid,1573.4,-2330.8,13.2);
        SetPlayerFacingAngle(playerid, 90);
        SetCameraBehindPlayer(playerid);
        PlayerInfo[playerid][FirstLog] = 0;
    }
    else if (PlayerInfo[playerid][FirstLog] == 0)
    {
        new pName[MAX_PLAYER_NAME];GetPlayerName(playerid, pName, sizeof(pName));
        new file[96];format(file,sizeof file,"/User_Database/%s.ini",pName);
        INI_ParseFile(file, "GetData", .bExtra = true, .extra =playerid);
        SetPlayerPos(playerid,PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ]);
        SetPlayerFacingAngle(playerid,PlayerInfo[playerid][Ang]);
        SetPlayerInterior(playerid,PlayerInfo[playerid][Int]);
        SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][VW]);
        SetPlayerSkin(playerid,PlayerInfo[playerid][Skin]);
        SetCameraBehindPlayer(playerid);
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER) //register dialog
    {
        if(response)
        {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            new file[96];
            format(file,sizeof(file),"/User_Database/%s.ini",pName);
            if(!fexist(file))
            {
                new INI:handler = INI_Open(file);
                PlayerInfo[playerid][level] = 0;
                INI_WriteString(handler,"Password",inputtext);
                INI_WriteInt(handler,"Score",0);
                INI_WriteInt(handler,"Money",0);
                INI_WriteInt(handler,"Playerlevel",0);
                INI_WriteFloat(handler, "PosX", 0);
                INI_WriteFloat(handler, "PosY", 0);
                INI_WriteFloat(handler, "PosZ", 0);
                INI_WriteInt(handler,"FirstLog", 1);
                INI_Close(handler);
                PlayerInfo[playerid][FirstLog] = 1;
            }
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
        } else Kick(playerid);
    }
    if(dialogid == DIALOG_LOGIN) //login dialog
    {
        if(response)
        {
            new pName[MAX_PLAYER_NAME];GetPlayerName(playerid, pName, sizeof(pName));
            new file[96];format(file,sizeof file,"/User_Database/%s.ini",pName);
            INI_ParseFile(file, "GetData", .bExtra = true, .extra =playerid);
            SendClientMessage(playerid, COLOR_GREEN,"You have succesfully logged in!");
            if (strcmp(inputtext, PlayerInfo[playerid][password]))
            {
                new string[128];
                if (attempt[playerid] <3)
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
                    attempt[playerid]++;
                    PlayerPlaySound(playerid,1057,0,0,0);
                    printf("%s has failed to login", pName);
                    format(string,sizeof string,"Invalid password! [%i/3]",attempt[playerid]);
                    SendClientMessage(playerid, 0xFF3200FF, string);
                    attempt[playerid] = attempt[playerid]++;
                } else {
                    GetPlayerName(playerid,pName,8);
                    format(string,sizeof string,"%s(%i) Has been kicked by the server(Failed to login).",pName,playerid);
                    SendClientMessageToAll(COLOR_GRAY,string);
                    Kick(playerid);
                }
            }
            else if (!strcmp(inputtext, PlayerInfo[playerid][password]))
            {
                if (PlayerInfo[playerid][FirstLog] == 0)
                {
                    SpawnPlayer(playerid);
                    return 1;
                }
                if (PlayerInfo[playerid][FirstLog] == 1)
                {
                    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Gender Selection", "Choose a gender:", "Male", "Female");
                    SetPlayerPos(playerid, 1555.5999800,-2312.6001000,-23.4000000);
                    SetPlayerFacingAngle(playerid, 160);
                    SetPlayerCameraPos(playerid, 1554.5999800,-2315.6001000,-22.0000000);
                    SetPlayerCameraLookAt(playerid, 1555.5999800,-2312.6001000,-23.0000000);
                    return 1;
                }
            }
        } else Kick(playerid);
    }
    if(dialogid == 1)
    {
        //do something here
        //if you wish to spawn player use SpawnPlayer(playerid);
        return 1;
    }
    return 0;
}
can you show me the gender choosing Dialog response?
He is right, now show us your Gender dialog... Because the won't spawn until after it is responded to, if it has to respond to then the player will never get to choose-a-class/spawn
Reply
#8

Quote:
Originally Posted by Crayder
Посмотреть сообщение
He is right, now show us your Gender dialog... Because the won't spawn until after it is responded to, if it has to respond to then the player will never get to choose-a-class/spawn
It's at the very bottom, please take a look.
Reply
#9

Final Bump
Reply
#10

I'm not sure what the issue is, can you reupdate?

Also, read the forum rules:
Quote:

No Double Posting - There is a modify button , use it. However, bumping a topic in which you have or require further information is allowed after at least 24 hours.

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)