Weird bug
#1

So, I decided to create a scratch gamemode and things were going pretty well until I started doing the saving/loading system. I tried scripting it with y_ini, SII, dini and they all showed the same problem.

When I login, and I type in the password, somehow it seems that I am getting kicked without being kicked.

Let me explain it, it means it doesn't say "Server closed connection." nor anything, just no commands working - nothing going like the AntiSpawn kill message for example, tried removing any kind of loading/saving system worked pretty good.

I suppose the bug is in the loading part, as for registering, I can register, functions are working pretty good, nothing wierd happens.

So, here you go...

On player connect part:
pawn Код:
new str[150], file[70];
    format(file, sizeof(file), "users/%s.ini", BFN(playerid));
    if(!dini_Exists(file))
    {
        format(str, sizeof(str), "Welcome back %s to BattleField Deathmatch!\n Please enter your password below to login.", BFN(playerid));
        ShowPlayerDialog(playerid, logd, DIALOG_STYLE_PASSWORD,"Welcome back!", str, "Okay", "Quit");
    }
OnDialogResponse part:
pawn Код:
if(dialogid == logd)
    {
        new str[150];
        if(response)
        {
            if(strlen(inputtext) < 3)
            {
                format(str, sizeof(str), "Welcome back %s to BattleField Deathmatch!\n Please enter your password below to login.", BFN(playerid));
                ShowPlayerDialog(playerid, logd, DIALOG_STYLE_PASSWORD,"Password too short!", str, "Okay", "Quit");
                return 1;
            }
            if(sscanf(inputtext, "s[51]", inputtext))
            {
                format(str, sizeof(str), "Welcome back %s to BattleField Deathmatch!\n Please enter your password below to login.", BFN(playerid));
                ShowPlayerDialog(playerid, logd, DIALOG_STYLE_PASSWORD,"Password too short!", str, "Okay", "Quit");
                return 1;
            }
            new file[64], password[51];
            format(file, sizeof(file), "users/%s.ini", BFN(playerid));
            format(password, sizeof(password), "%s", dini_Get(file, "Password"));
            if(strcmp(inputtext, password, false) == 0)
            {
                LoadAccount(playerid);
            }
            else
            {
                format(str, sizeof(str), "Welcome back %s to BattleField Deathmatch!\n Please enter your password below to login.", BFN(playerid));
                ShowPlayerDialog(playerid, logd, DIALOG_STYLE_PASSWORD,"Wrong Password!", str, "Okay", "Quit");
                return 1;
            }
        }
        else
        {
        SendClientMessage(playerid, red, "You have decided to quit the server.");
        Kick(playerid);
        return 1;
        }
    }
LoadAccount part:
pawn Код:
stock LoadAccount(playerid)
{
    new file[64];
    format(file, sizeof(file), "users/%s.ini", BFN(playerid));
    PInfo[playerid][Admin] = dini_Int(file, "Admin");
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, dini_Int(file, "Money"));
    SetPlayerScore(playerid, dini_Int(file, "Score"));
    PInfo[playerid][Kills] = dini_Int(file, "Kills");
    PInfo[playerid][Death] = dini_Int(file, "Death");
    PInfo[playerid][Rank] = dini_Int(file, "Rank");
    return 1;
}
If anything else is needed, I am ready to post.
Reply
#2

Код:
if(!dini_Exists(file))
This code means "If this file does NOT exist".
You are logging into an account that does not exist.

Replace it with
Код:
if(dini_Exists(file))
Reply
#3

Yeah ! this mean if something is not... but if you remove ! than it mean if something is...
Reply
#4

@Shetch, thanks for your reply and I did try it, but the main bug still not fixed... (But thanks for notifying me with that)

However, just a side note which might come in handy I suppose, I started the gamemode from Line 1 and some 'publics' like OnPlayerEnterVehicle, do not exist, I currently have only

Код:
OnGameModeInit
OnGameModeExit
OnDialogResponse
OnPlayerRequestClass
OnPlayerSpawn
OnPlayerRequestSpawn
So my question is, do I really need all the main 'publics' in my .pwn, like is it the reason the bug is going on? Or it's not of a big deal?

Thanks in advance.

EDIT:@Legena, thanks for your reply too.
Reply
#5

I only add the ones I use to my gamemode, and no it's not a big deal, it's actually common practice.
Reply
#6

Show us your BFN(playerid) function, please.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)