Dialog Problem +REP
#1

Why When I Log In In The Login Dialog, Sometimes It Resets Account To 0 Value, Does Like The Register Dialog, Means That Makes My Account Recreated Again With 0 Value.

Code Of Dialogs:
pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
            if (!response) return Kick(playerid);
            if(response)
            {
                new ip[16];
                GetPlayerIp(playerid, ip, sizeof(ip));
                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");
                PlayerInfo[playerid][pPass] = udb_hash(inputtext);
                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,"Score",0);
                INI_WriteInt(File,"Drugs",0);
                INI_WriteInt(File,"Adrenaline",0);
                INI_WriteInt(File,"Registered",1);
                INI_WriteInt(File,"Logged",1);
                INI_WriteInt(File,"VIPLevel",0);
                INI_WriteInt(File,"FavouriteSkin",-1);
                INI_WriteInt(File,"FavouriteSong",0);
                INI_WriteInt(File,"BankMoney",0);
                INI_WriteInt(File,"Daysalive",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteString(File,"IP",ip);
                INI_WriteInt(File,"MissionsCompleted",0);
                INI_WriteInt(File,"MissionsFailed",0);
                INI_WriteInt(File,"Robbed",0);
                INI_WriteInt(File,"MaximumRobbed",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Jailed",0);
                INI_WriteInt(File,"MuteWarnings",0);
                INI_WriteInt(File,"MaxMuteWarnings",0);
                INI_WriteInt(File,"Warnings",0);
                INI_WriteInt(File,"TimesKicked",0);
                INI_WriteInt(File,"EventsWon",0);
                INI_WriteInt(File,"EventsLost",0);
                INI_WriteInt(File,"StartingMusic",0);
                INI_Close(File);
                PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                PlayerAlreadyRegisteredIn[playerid] = 1;
                Info[playerid][Logged] = 1;
                Info[playerid][Registered] = 1;
                Info[playerid][Favouriteskin] = -1;
                UserTimer[playerid] = SetTimerEx("UserSaver", 180000, false, "d", playerid);
                PlayerDays[playerid] = SetTimerEx("DaysAlive", 1380000, true, "d", playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Successfully Registered An Account!","Ok","");
            }
    }

    if(dialogid == DIALOG_LOGIN)
    {
            new LoginAttempts[MAX_PLAYERS];
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new ip[16], Message3[128];
                GetPlayerIp(playerid, ip, sizeof(ip));
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    SetPlayerScore(playerid, LPinfo[playerid][Score]);
                    Info[playerid][Logged] = 1;
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

                    new INI:File = INI_Open(UserPath(playerid));
                    INI_SetTag(File,"data");
                    INI_WriteInt(File,"Logged",1);
                    INI_WriteString(File,"IP",ip);
                    INI_Close(File);
                    if(PlayerInfo[playerid][pAdmin] == 0 && Info[playerid][VIPLevel] == 0)
                    {
                    format(Message3, sizeof(Message3), "You Have Logged In As A {00FFFB}Registered Player{FFF700}."), SendClientMessage(playerid, 0xFFF700FF, Message3);
                    }
                    if(PlayerInfo[playerid][pAdmin] > 0)
                    {
                       switch(PlayerInfo[playerid][pAdmin])
                       {
                       case 1: AdmRank = "Trial Moderator";
                       case 2: AdmRank = "Moderator";
                       case 3: AdmRank = "Master Moderator";
                       case 4: AdmRank = "Trial Administrator";
                       case 5: AdmRank = "Administrator";
                       case 6: AdmRank = "Master Administrator";
                       case 7: AdmRank = "Head Administrator";
                       case 8: AdmRank = "Trusted Administrator";
                       case 9: AdmRank = "Co-Owner";
                       case 10: AdmRank = "Owner";
                       }
                       if(Info[playerid][VIPLevel] > 0)
                       {
                           switch(Info[playerid][VIPLevel])
                           {
                           case 1: AccType = "Bronze";
                           case 2: AccType = "Silver";
                           case 3: AccType = "Gold";
                           }
                           format(Message3, sizeof(Message3), "You Have Logged In As A(n) {00FFFB}%s Level %d{FFF700} With A {FF00EA}%s{FFF700} Account.", AdmRank, PlayerInfo[playerid][pAdmin], AccType), SendClientMessage(playerid, 0xFFF700FF, Message3);
                           VIPReward[playerid] = SetTimerEx("VIPMoney", 1380000, true, "d", playerid);
                           SendClientMessage(playerid, 0xFFF700FF, "You Will Be Given Some VIP Money While Living Whole Gameday.");
                           if(Info[playerid][VIPLevel] >= 1)
                           {
                           if(Info[playerid][Favouriteskin] < -1 || Info[playerid][Favouriteskin] > 299)
                           {
                             Autouseskin[playerid] = 1;
                           }
                           }
                       }
                       else
                       {
                           format(Message3, sizeof(Message3), "You Have Logged In As A(n) {00FFFB}%s Level %d{FFF700}.", AdmRank, PlayerInfo[playerid][pAdmin]), SendClientMessage(playerid, 0xFFF700FF, Message3);
                           OnDuty[playerid] = 0;
                       }
                    }
                    else if(Info[playerid][VIPLevel] > 0)
                    {
                       switch(Info[playerid][VIPLevel])
                       {
                       case 1: AccType = "Bronze";
                       case 2: AccType = "Silver";
                       case 3: AccType = "Gold";
                       }
                       format(Message3, sizeof(Message3), "You Have Logged In As A {FF00EA}%s{FFF700} Account.", AccType), SendClientMessage(playerid, 0xFFF700FF, Message3);
                       VIPReward[playerid] = SetTimerEx("VIPMoney", 1380000, true, "d", playerid);
                       SendClientMessage(playerid, 0xFFF700FF, "You Will Be Given Some VIP Money While Living Whole Gameday.");
                       if(Info[playerid][VIPLevel] >= 1)
                       {
                       if(Info[playerid][Favouriteskin] < -1 || Info[playerid][Favouriteskin] > 299)
                       {
                         Autouseskin[playerid] = 1;
                       }
                       }
                       }
                    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                    PlayerAlreadyLoggedIn[playerid] = 1;
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, LPinfo[playerid][Score]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    UserTimer[playerid] = SetTimerEx("UserSaver", 180000, false, "d", playerid);
                    PlayerDays[playerid] = SetTimerEx("DaysAlive", 1380000, true, "d", 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");
                    LoginAttempts[playerid] ++;
                }
                if(LoginAttempts[playerid] == MAX_LOGINS)
                {
                    LoginKickWithMessage(playerid, 0xFF0004FF, "You MUST Login In To Play Here.");
                    Info[playerid][TimesKicked] += 1;
                }
                return 1;
            }
    }
Dialogs Codes When Showed Under OnPlayerRequestClass:
pawn Код:
if(fexist(UserPath(playerid)))
    {
      if(PlayerAlreadyLoggedIn[playerid] == 0)
      {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
      }
    }
    else
    {
      if(PlayerAlreadyRegisteredIn[playerid] == 0)
      {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Type your password below to register a new account.","Register","Quit");
      }
    }
Please Help.
Reply
#2

what I can already tell you is, that creating
pawn Код:
new LoginAttempts[MAX_PLAYERS];
at the point you did it (OnDialogResponse - even at the if(dialogid == ..... part) does not make any sense
the LOCAL variable is recreated each time you reenter the password, which sets it to 0 each time.
You need to create it as a GLOBAL variable (outside of any callback)


I'm not familar with the INI useage, but I suspect the failure in this
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
line... but as I said, it can be completely correct, as I don't know at all what INI_ParseFile does and what the syntax of it is


EDIT: ah yea and where are you getting your infos like "PlayerInfo[playerid][pPass]" from inbefore?
pawn Код:
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
that's where you use it, but where do you get it?
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
what I can already tell you is, that creating
pawn Код:
new LoginAttempts[MAX_PLAYERS];
at the point you did it (OnDialogResponse - even at the if(dialogid == ..... part) does not make any sense
the LOCAL variable is recreated each time you reenter the password, which sets it to 0 each time.
You need to create it as a GLOBAL variable (outside of any callback)
This.

Plus,
I don't see a reason for using "PlayerAlreadyLoggedIn" and "PlayerAlreadyRegisteredIn", actually useless.
Quote:
Originally Posted by Youssef214
Посмотреть сообщение
pawn Код:
if(fexist(UserPath(playerid)))
    {
      if(PlayerAlreadyLoggedIn[playerid] == 0)
      {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
      }
    }
    else
    {
      if(PlayerAlreadyRegisteredIn[playerid] == 0)
      {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Type your password below to register a new account.","Register","Quit");
      }
    }
Please Help.
I advise you of showing these dialogs OnPlayerConnect instead of OnPlayerRequestClass.
Reply
#4

I am confused, whats the solution??
Reply
#5

Quote:
Originally Posted by iFiras
Quote:
Originally Posted by Sascha
Посмотреть сообщение
what I can already tell you is, that creating
pawn Код:
new LoginAttempts[MAX_PLAYERS];
at the point you did it (OnDialogResponse - even at the if(dialogid == ..... part) does not make any sense
the LOCAL variable is recreated each time you reenter the password, which sets it to 0 each time.
You need to create it as a GLOBAL variable (outside of any callback)
This.

Plus,
I don't see a reason for using "PlayerAlreadyLoggedIn" and "PlayerAlreadyRegisteredIn", actually useless.
Quote:
Originally Posted by Youssef214
Посмотреть сообщение
pawn Код:
if(fexist(UserPath(playerid)))
    {
      if(PlayerAlreadyLoggedIn[playerid] == 0)
      {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
      }
    }
    else
    {
      if(PlayerAlreadyRegisteredIn[playerid] == 0)
      {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Type your password below to register a new account.","Register","Quit");
      }
    }
Please Help.
I advise you of showing these dialogs OnPlayerConnect instead of OnPlayerRequestClass.
....
Reply
#6

Nevermind Fixed the problem, I forgot to put Return 1 At the last codes of DIALOG_REGISTER
Reply
#7

Still the problem exists
Reply
#8

please put it onplayerconnect not onplayerrequestclass
pawn Код:
if(fexist(UserPath(playerid)))
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
    }
    else
    {

    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Type your password below to register a new account.","Register","Quit");
      }
Reply
#9

Quote:
Originally Posted by Eth
Посмотреть сообщение
please put it onplayerconnect not onplayerrequestclass
pawn Код:
if(fexist(UserPath(playerid)))
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
    }
    else
    {

    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Type your password below to register a new account.","Register","Quit");
      }
its not the problem the problem is saving on leaving are u checking that he is logged in or not before saving ?
Reply
#10

ooh show me onplayerdisconnect then
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)