Yini Loading problem +REP
#1

why when i sometimes login i lose all my stats except the password?

pawn Код:
case 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][Registered] = 1;
                    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;
            }
        }
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Score",LPinfo[playerid][Score]);
    INI_Int("Drugs",LPinfo[playerid][Drugs]);
    INI_Int("Adrenaline",LPinfo[playerid][Adre]);
    INI_Int("Registered",Info[playerid][Registered]);
    INI_Int("Logged",Info[playerid][Logged]);
    INI_Int("VIPLevel",Info[playerid][VIPLevel]);
    INI_Int("FavouriteSkin",Info[playerid][Favouriteskin]);
    INI_Int("FavouriteSong",Favouritesong[playerid]);
    INI_Int("BankMoney",BankMoney[playerid]);
    INI_Int("Daysalive",Daysalive[playerid]);
    INI_Int("Banned",Info[playerid][Banned]);
    INI_Int("MissionsCompleted",Info[playerid][MissionsCompleted]);
    INI_Int("MissionsFailed",Info[playerid][MissionsFailed]);
    INI_Int("Robbed",Info[playerid][Robbed]);
    INI_Int("MaximumRobbed",Info[playerid][MaximumRobbed]);
    INI_Int("Muted",Info[playerid][Muted]);
    INI_Int("Jailed",Info[playerid][Jailed]);
    INI_Int("MuteWarnings",Info[playerid][MuteWarnings]);
    INI_Int("MaxMuteWarnings",Info[playerid][MaxMuteWarnings]);
    INI_Int("Warnings",Info[playerid][Warnings]);
    INI_Int("TimesKicked",Info[playerid][TimesKicked]);
    INI_Int("EventsWon",Info[playerid][EventsWon]);
    INI_Int("EventsLost",Info[playerid][EventsLost]);
    return 1;
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
Under onplayerconnect:
pawn Код:
PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pKills] = 0;
    PlayerInfo[playerid][pDeaths] = 0;
    LPinfo[playerid][Drugs] = 0;
    LPinfo[playerid][Adre] = 0;
    Info[playerid][VIPLevel] = 0;
    Info[playerid][Favouriteskin] = -1;
    BankMoney[playerid] = 0;
    Daysalive[playerid] = 0;
    Info[playerid][MissionsCompleted] = 0;
    Info[playerid][MissionsFailed] = 0;
    Info[playerid][Robbed] = 0;
    Info[playerid][MaximumRobbed] = 0;
    Info[playerid][Muted] = 0;
    Info[playerid][Jailed] = 0;
    Info[playerid][MuteWarnings] = 0;
    Info[playerid][MaxMuteWarnings] = 0;
    Info[playerid][Warnings] = 0;
    Info[playerid][TimesKicked] = 0;
    Info[playerid][EventsWon] = 0;
    Info[playerid][EventsLost] = 0;
under onplayerdisconnect:
pawn Код:
if(fexist(UserPath(playerid)))
    {
    if(Info[playerid][Logged] == 1)
    {
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Drugs",LPinfo[playerid][Drugs]);
    INI_WriteInt(File,"Adrenaline",LPinfo[playerid][Adre]);
    INI_WriteInt(File,"Registered",1);
    INI_WriteInt(File,"Logged",0);
    INI_WriteInt(File,"VIPLevel",Info[playerid][VIPLevel]);
    INI_WriteInt(File,"FavouriteSkin",Info[playerid][Favouriteskin]);
    INI_WriteInt(File,"FavouriteSong",Favouritesong[playerid]);
    INI_WriteInt(File,"BankMoney",BankMoney[playerid]);
    INI_WriteInt(File,"Daysalive",Daysalive[playerid]);
    INI_WriteInt(File,"Banned",Info[playerid][Banned]);
    INI_WriteInt(File,"MissionsCompleted",Info[playerid][MissionsCompleted]);
    INI_WriteInt(File,"MissionsFailed",Info[playerid][MissionsFailed]);
    INI_WriteInt(File,"Robbed",Info[playerid][Robbed]);
    INI_WriteInt(File,"MaximumRobbed",Info[playerid][MaximumRobbed]);
    INI_WriteInt(File,"Muted",Info[playerid][Muted]);
    INI_WriteInt(File,"Jailed",Info[playerid][Jailed]);
    INI_WriteInt(File,"MuteWarnings",Info[playerid][MuteWarnings]);
    INI_WriteInt(File,"MaxMuteWarnings",Info[playerid][MaxMuteWarnings]);
    INI_WriteInt(File,"Warnings",Info[playerid][Warnings]);
    INI_WriteInt(File,"TimesKicked",Info[playerid][TimesKicked]);
    INI_WriteInt(File,"EventsWon",Info[playerid][EventsWon]);
    INI_WriteInt(File,"EventsLost",Info[playerid][EventsLost]);
    INI_Close(File);
    }
    }
please help..
Reply
#2

bump
Reply
#3

anyone please?
Reply
#4

when saving first check if
pawn Код:
PlayerAlreadyLoggedIn[playerid] == 1
then save
Reply
#5

still does not correctly load the stats, please anyone help for REP?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)