Login Dialog stops working after server restart
#1

I have made some changes after my previous topic. Yet, I'm still having the same problem.
The 'bug' occurs after I restart my server.

Here's the updated script:

OnGameModeExit:
pawn Код:
public OnGameModeExit()
{
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if (IsPlayerConnected(i))
        {
            SavePlayer(i);
        }
    }
    return 1;
}
OnPlayerConnect:
pawn Код:
public OnPlayerConnect(pID)
{
    TogglePlayerSpectating(pID,1);
    TogglePlayerControllable(pID,0);
    SetPlayerCameraPos(pID, 1982.5140,-1703.8862,124.3137);
    SetPlayerCameraLookAt(pID, 1765.5276,-1451.8524,137.7477);
    new name1[MAX_PLAYER_NAME], string[2048], logstring[256];
    new day, month, year;
    new hour, minute, second;
    if(!IsValidName(pID))
    {
        format(string, sizeof(string), "[AdmCmd] %s has been kicked by Vagismajis, reason: Inappropiate name", name1);
        SendClientMessage(pID, COLOR_LIGHTRED, "You've been kicked by Vagismajis, reason: Inappropiate name, remove all numbers and special characters!");
        new INI:File = INI_Open(UserPath(pID));
        INI_RemoveEntry(File, UserPath(pID));
        INI_Close(File);
        SetTimerEx("kickbugfix", 1000, false, "i", pID);
        getdate(day, month, year);
        gettime(hour, minute, second);
        format(logstring, sizeof(logstring), "[AdmCmd] %s has been kicked by Vagismajis, reason: Inappropiate name [%d-%d-%d](%d:%d:%d)", name1, day, month, year, hour, minute, second);
        KickLog(logstring);
    }
    if(IsValidName(pID))
    {
        if(fexist(UserPath(pID)) || gPlayerRegistered[pID] == 1)
        {
            INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
            ShowPlayerDialog(pID, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back to {00FF26}West Coast Life Roleplay!{FFFFFF}\n\nThat name is registered. Please enter your password below.","Login","Quit"); //login
        }
        else
        {
            format(string, sizeof(string), "{FFFFFF}Welcome %s to {00FF00}West Coast Life Roleplay!{FFFFFF}\n\nThe registration process will be as following:\n\nStep 1: Agreement on server rules.\nStep 2: Password selection.\nStep 3: Age selection.\nStep 4: A roleplay test that consists out of 5 random questions.\n\nGood luck!\n Kind regards, the WCL community!", GetName(pID));
            ShowPlayerDialog(pID, DIALOG_REGISTER, DIALOG_STYLE_MSGBOX, "West Coast Life Roleplay",string, "Continue", "Quit");
        }
        if(gPlayerLogged[pID] == 1)
        {
            SpawnPlayer(pID);
        }
    }
    ResetPlayerCash(pID);
    return 1;
}
DIALOG_LOGIN
pawn Код:
if(dialogid == DIALOG_LOGIN) // login
            {
                if(!response) return Kick(pID);
                if(response)
                {
                    if(udb_hash(inputtext) == PlayerInfo[pID][pPass])
                    {
                        INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
                        gPlayerLogged[pID] = 1;
                        SetSpawnInfo(pID, 0, PlayerInfo[pID][pSkin], PlayerInfo[pID][pLastX], PlayerInfo[pID][pLastY], PlayerInfo[pID][pLastZ], PlayerInfo[pID][pFacingAngle], 0, 0, 0, 0, 0, 0);
                        SpawnPlayer(pID);
                        GivePlayerCash(pID, PlayerInfo[pID][pCash]);
                        SetPlayerScore(pID, PlayerInfo[pID][pLevel]);
                        SetPlayerHealth(pID, PlayerInfo[pID][pHealth]);
                        SetPlayerArmour(pID, PlayerInfo[pID][pArmour]);
                        SetPlayerInterior(pID, PlayerInfo[pID][pInt]);
                        SetPlayerVirtualWorld(pID, PlayerInfo[pID][pVW]);
                        format(tmp2, sizeof(tmp2), "~g~Welcome ~n~~w~   %s", GetName(pID));
                        GameTextForPlayer(pID, tmp2, 5000, 1);
                        TogglePlayerSpectating(pID, 0);
                        SetPlayerColor(pID, TRANSPARENT_WHITE);
                        if(PlayerInfo[playerid][pAdmin] >= 1)
                        {
                            format(tmp2, sizeof(tmp2), "[SERVER] You are logged in as a Level %d Admin.",PlayerInfo[playerid][pAdmin]);
                            SendClientMessage(playerid, COLOR_WHITE,tmp2);
                        }
                        return 1;
                    }
                    else
                    {
                        ShowPlayerDialog(pID, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back to {00FF26}West Coast Life Roleplay!{FFFFFF}\n\nThat name is registered. Please enter your password below.\n\n{FF0000} You have entered an incorrect password!","Login","Quit"); //login
                        return 1;
                    }
                }
                return 1;
            }
If you need more, just let me know.

Helpers +rep

Quote:
Originally Posted by Previous topic
Hello folks
I'm having a weird bug with my Login Dialog.

When I make a new account everything works, logging off and back in and loading the correct information works good. But when I restart my server the login dialog disappears when I enter an incorrect password or the correct password leaving me with the "spawn" button. When I do click "spawn" I get spawned in Blueberry with the CJ skin.

Let me give you a concrete example of the problem:
I restart the server and go on the server. I enter an incorrect password and the dialog disappears leaving me with only the "Spawn" button available. Let's say for an instance that I click the "spawn" button, I get spawned in Blueberry in CJ skin.

I have to delete my Bible.ini (Player file) and make the account again to make it work properly again.
OnPlayerConnect:
pawn Код:
if(fexist(UserPath(pID)) || gPlayerRegistered[pID] == 1)
    {
        INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
        ShowPlayerDialog(pID, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back to {00FF26}SERVER NAME!{FFFFFF}\n\nThat name is registered. Please enter your password below.","Login","Quit"); //login
    }
    else
    {
        format(string, sizeof(string), "{FFFFFF}Welcome %s to {00FF00}SERVER NAME!{FFFFFF}\n\nThe registration process will be as following:\n\nStep 1: Agreement on server rules.\nStep 2: Password selection.\nStep 3: Age selection.\nStep 4: A roleplay test that consists out of 5 random questions.\n\nGood luck!\n Kind regards, the SERVER's community!", GetName(pID));
        ShowPlayerDialog(pID, DIALOG_REGISTER, DIALOG_STYLE_MSGBOX, "SERVER NAME",string, "Continue", "Quit");
    }
LOGIN_DIALOG:
pawn Код:
if(dialogid == DIALOG_LOGIN) // login
            {
                if(!response) return SetTimerEx("kickbugfix", 1000, false, "i", pID);
                if(response)
                {
                    if(udb_hash(inputtext) == PlayerInfo[pID][pPass])
                    {
                        INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
                        SetSpawnInfo(pID, 0, PlayerInfo[pID][pSkin], PlayerInfo[pID][pLastX], PlayerInfo[pID][pLastY], PlayerInfo[pID][pLastZ], PlayerInfo[pID][pFacingAngle], 0, 0, 0, 0, 0, 0);
                        SpawnPlayer(pID);
                        GivePlayerCash(pID, PlayerInfo[pID][pCash]);
                        SetPlayerScore(pID, PlayerInfo[pID][pLevel]);
                        SetPlayerHealth(pID, PlayerInfo[pID][pHealth]);
                        SetPlayerArmour(pID, PlayerInfo[pID][pArmour]);
                        SetPlayerInterior(pID, PlayerInfo[pID][pInt]);
                        SetPlayerVirtualWorld(pID, PlayerInfo[pID][pVW]);
                        format(tmp2, sizeof(tmp2), "~g~Welcome ~n~~w~   %s", GetName(pID));
                        GameTextForPlayer(pID, tmp2, 5000, 1);
                        TogglePlayerSpectating(pID, 0);
                        SetPlayerColor(pID, TRANSPARENT_WHITE);
                        gPlayerLogged[pID] = 1;
                        return 1;
                    }
                    else
                    {
                        ShowPlayerDialog(pID, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back to {00FF26}SERVER!{FFFFFF}\n\nThat name is registered. Please enter your password below.\n\n{FF0000} You have entered an incorrect password!","Login","Quit"); //login
                        gPlayerLogged[pID] = 0;
                        return 1;
                    }
                }
            }
Reply
#2

try to delete the ongamemodeexit.
Reply
#3

I added the OnGameModeExit after the bug occurred.
I doubt that it's the problem.
Reply
#4

well i don't think that it have nothing to do with that bug, but anyways can you check if it's working after adding the ongamemodeexit? if there still a bug then try to delete ongamemodeexit if it's still occured then maybe there is a problem in login dialog.
Reply
#5

I removed it as you suggested. The problem still occurs.
If it is my LOGIN_DIALOG then what am I doing wrong? I can't find the problem.
Reply
#6

can you try to delete if(!response) delete this line then try again.
Reply
#7

The if(!response) line is for when players click the "Quit" button in the dialog. Anyway, I've done what you suggested and it's still not working.
Reply
#8

pawn Код:
if(dialogid == DIALOG_LOGIN) // login
            {
                if(response)
                {
                    if(udb_hash(inputtext) == PlayerInfo[pID][pPass])
                    {
                        INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
                        SetSpawnInfo(pID, 0, PlayerInfo[pID][pSkin], PlayerInfo[pID][pLastX], PlayerInfo[pID][pLastY], PlayerInfo[pID][pLastZ], PlayerInfo[pID][pFacingAngle], 0, 0, 0, 0, 0, 0);
                        SpawnPlayer(pID);
                        GivePlayerCash(pID, PlayerInfo[pID][pCash]);
                        SetPlayerScore(pID, PlayerInfo[pID][pLevel]);
                        SetPlayerHealth(pID, PlayerInfo[pID][pHealth]);
                        SetPlayerArmour(pID, PlayerInfo[pID][pArmour]);
                        SetPlayerInterior(pID, PlayerInfo[pID][pInt]);
                        SetPlayerVirtualWorld(pID, PlayerInfo[pID][pVW]);
                        format(tmp2, sizeof(tmp2), "~g~Welcome ~n~~w~   %s", GetName(pID));
                        GameTextForPlayer(pID, tmp2, 5000, 1);
                        TogglePlayerSpectating(pID, 0);
                        SetPlayerColor(pID, TRANSPARENT_WHITE);
                        gPlayerLogged[pID] = 1;
                    }
                    else
                    {
                        ShowPlayerDialog(pID, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back to {00FF26}SERVER!{FFFFFF}\n\nThat name is registered. Please enter your password below.\n\n{FF0000} You have entered an incorrect password!","Login","Quit"); //login
                        gPlayerLogged[pID] = 0;
                    }
                }
               if(!response)
               {
               SetTimerEx("kickbugfix", 1000, false, "i", pID);
            }
           }
try this, mine don't have the return 1; (i don't need it)
btw why are you doing : public onplayerconnect(pID) instead of public onplayerconnect(playerid) ? maybe it's causing a problem
Reply
#9

pID is defined as playerid, that doesn't cause problems.

I'll just re-do the whole OnDialogResponse. Maybe I did something wrong there.
Thanks for the time and help. +rep
Reply
#10

show me the saveplayer.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)