Server stats problem
#1

Basically, when a new player joins the server they get the stats of a previous registered player - so if a registered player has admin level 4, when a new player registers they end up getting admin level 4 too (it happens for nearly everything in stats except for age + skin and maybe a few other things but things like - Position, job, level, admin, are from a previous user)
Here is my OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(GetPVarInt(playerid, "gpsonoff") == 1) TextDrawDestroy(GPS[playerid]);
    if(HaveGPS[playerid])
    {
        KillTimer(GPSTimer[playerid]);
        HaveGPS[playerid] = false;
        GPSTimer[playerid] = 0;
    }
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerPos(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);
    SaveAccountStats(playerid);
    switch(reason) {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
        }
    ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    return 1;
}
"SaveAccountStats" function:
pawn Код:
function SaveAccountStats(playerid)
{
if(Logged[playerid] == 1){
    new
        INI:File = INI_Open(UserPath(playerid))
    ;
    INI_SetTag(File,"data");

    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][pCash] = GetPlayerCash(playerid);
    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
    PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
    new Float:health;
    PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,health);
    new Float:armour;
    PlayerInfo[playerid][pArmor] = GetPlayerArmour(playerid,armour);
    new
        Float:x,
        Float:y,
        Float:z
    ;
    GetPlayerPos(playerid,x,y,z);
    PlayerInfo[playerid][pPos_x] = x;
    PlayerInfo[playerid][pPos_y] = y;
    PlayerInfo[playerid][pPos_z] = z;
    GetPlayerPos(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);

    INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Experience",PlayerInfo[playerid][pExp]);
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    INI_WriteInt(File,"Job",PlayerInfo[playerid][pJobID]);
    INI_WriteInt(File,"Weapon",PlayerInfo[playerid][pWeapon]);
    INI_WriteInt(File,"Weapon2",PlayerInfo[playerid][pWeapon2]);
    INI_WriteInt(File,"Weapon3",PlayerInfo[playerid][pWeapon3]);
    INI_WriteInt(File,"Weapon4",PlayerInfo[playerid][pWeapon4]);
    INI_WriteInt(File,"Weapon5",PlayerInfo[playerid][pWeapon5]);
    INI_WriteInt(File,"Weapon6",PlayerInfo[playerid][pWeapon6]);
    INI_WriteInt(File,"Weapon7",PlayerInfo[playerid][pWeapon7]);
    INI_WriteInt(File,"Weapon8",PlayerInfo[playerid][pWeapon8]);
    INI_WriteInt(File,"Weapon9",PlayerInfo[playerid][pWeapon9]);
    INI_WriteInt(File,"Weapon10",PlayerInfo[playerid][pWeapon10]);
    INI_WriteInt(File,"Weapon11",PlayerInfo[playerid][pWeapon11]);
    INI_WriteInt(File,"Weapon12",PlayerInfo[playerid][pWeapon12]);
    INI_WriteInt(File,"GPS",PlayerInfo[playerid][pGPS]);
    INI_WriteInt(File,"Deposit",PlayerInfo[playerid][pDeposit]);
    INI_WriteInt(File,"Materials",PlayerInfo[playerid][pMaterials]);
    INI_WriteInt(File,"Packages",PlayerInfo[playerid][pPackages]);
    INI_WriteInt(File,"Cocaine",PlayerInfo[playerid][pCocaine]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Faction",PlayerInfo[playerid][pFaction]);
    INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
    INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
    INI_WriteInt(File,"Duty",PlayerInfo[playerid][pDuty]);
    INI_WriteInt(File,"VW",PlayerInfo[playerid][pVW]);
    INI_WriteInt(File,"INT",PlayerInfo[playerid][pINT]);
    INI_WriteInt(File,"Health",PlayerInfo[playerid][pHealth]);
    INI_WriteInt(File,"Armor",PlayerInfo[playerid][pArmor]);
    INI_Close(File);
    }
return 1;
}
OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
    SPEEDOS[playerid] = TextDrawCreate(10.0,200.0," ");
    TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);
    gOoc[playerid] = 0;
   
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Legendary Generation Roleplay","Type your password below to login:","Login","Quit");
        SpawnPlayer(playerid);
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Legendary Generation","Type your password below to register a new account:","Register","Quit");
        GPSTimer[playerid] = 0;
        PlayerInfo[playerid][pDeaths] = 0;
        HaveGPS[playerid] = true;
        SpawnPlayer(playerid);
    }
    Logged[playerid] = 0;
    return 1;
}
Dialog - Register:
pawn Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                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,"Level",0);
                INI_WriteInt(File,"Experience",0);
                INI_WriteInt(File,"Sex",0);
                INI_WriteInt(File,"Age",0);
                INI_WriteInt(File,"Job",0);
                INI_WriteFloat(File,"Pos_x",0);
                INI_WriteFloat(File,"Pos_y",0);
                INI_WriteFloat(File,"Pos_z",0);
                INI_WriteInt(File,"Skin",0);
                INI_WriteInt(File,"Team",0);
                INI_WriteInt(File,"Accent",0);
                INI_WriteInt(File,"pWeapon",0);
                INI_WriteInt(File,"pWeapon2",0);
                INI_WriteInt(File,"pWeapon3",0);
                INI_WriteInt(File,"pWeapon4",0);
                INI_WriteInt(File,"pWeapon5",0);
                INI_WriteInt(File,"pWeapon6",0);
                INI_WriteInt(File,"pWeapon7",0);
                INI_WriteInt(File,"pWeapon8",0);
                INI_WriteInt(File,"pWeapon9",0);
                INI_WriteInt(File,"pWeapon10",0);
                INI_WriteInt(File,"pWeapon11",0);
                INI_WriteInt(File,"pWeapon12",0);
                INI_WriteInt(File,"pGPS",0);
                INI_WriteInt(File,"pDeposit",0);
                INI_WriteInt(File,"pMaterials",0);
                INI_WriteInt(File,"pPackages",0);
                INI_WriteInt(File,"pCocaine",0);
                INI_WriteInt(File,"pDeaths",0);
                INI_WriteInt(File,"pFaction",0);
                INI_WriteInt(File,"pRank",0);
                INI_WriteInt(File,"pLeader",0);
                INI_WriteInt(File,"pDuty",0);
                INI_WriteInt(File,"pVW",0);
                INI_WriteInt(File,"pINT",0);
                INI_WriteInt(File,"pHealth",0);
                INI_WriteInt(File,"pArmor",0);
                INI_Close(File);
               
                ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "-: Sex :-","What gender are you?","Male","Female");
            }
        }
And the final thing I think you would need( LoadUser function):
pawn Код:
function LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);
    INI_Int("Experience",PlayerInfo[playerid][pExp]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Sex",PlayerInfo[playerid][pSex]);
    INI_Int("Age",PlayerInfo[playerid][pAge]);
    INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Team",PlayerInfo[playerid][pTeam]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Job",PlayerInfo[playerid][pJobID]);
    INI_Int("Weapon",PlayerInfo[playerid][pWeapon]);
    INI_Int("Weapon2",PlayerInfo[playerid][pWeapon2]);
    INI_Int("Weapon3",PlayerInfo[playerid][pWeapon3]);
    INI_Int("Weapon4",PlayerInfo[playerid][pWeapon4]);
    INI_Int("Weapon5",PlayerInfo[playerid][pWeapon5]);
    INI_Int("Weapon6",PlayerInfo[playerid][pWeapon6]);
    INI_Int("Weapon7",PlayerInfo[playerid][pWeapon7]);
    INI_Int("Weapon8",PlayerInfo[playerid][pWeapon8]);
    INI_Int("Weapon9",PlayerInfo[playerid][pWeapon9]);
    INI_Int("Weapon10",PlayerInfo[playerid][pWeapon10]);
    INI_Int("Weapon11",PlayerInfo[playerid][pWeapon11]);
    INI_Int("Weapon12",PlayerInfo[playerid][pWeapon12]);
    INI_Int("GPS",PlayerInfo[playerid][pGPS]);
    INI_Int("Deposit",PlayerInfo[playerid][pDeposit]);
    INI_Int("Materials",PlayerInfo[playerid][pMaterials]);
    INI_Int("Packages",PlayerInfo[playerid][pPackages]);
    INI_Int("Cocaine",PlayerInfo[playerid][pCocaine]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Faction",PlayerInfo[playerid][pFaction]);
    INI_Int("Rank",PlayerInfo[playerid][pRank]);
    INI_Int("Leader",PlayerInfo[playerid][pLeader]);
    INI_Int("Duty",PlayerInfo[playerid][pDuty]);
    INI_Int("VW",PlayerInfo[playerid][pVW]);
    INI_Int("INT",PlayerInfo[playerid][pINT]);
    INI_Int("Health",PlayerInfo[playerid][pHealth]);
    INI_Int("Armor",PlayerInfo[playerid][pArmor]);
    print("Loaded Player Information (Name, Age, Job...)");
    return 1;
}
If you require any more information just reply, please help me!
Reply
#2

Bump ( I may of bumped early but I really need this fixed, fast )
Reply
#3

On "OnPlayerConnect()", reset all important variables to 0, such admin level.

From what i can see, when you login, PlayerInfo varibles are set when a player logs in based on their ini, but are not unset when they leave.
Reply
#4

yep but make sure you reset it after saving.
Reply
#5

Hmm, I'm not 100percent sure what you mean, could you create the script for OnPlayerConnect? ( Im new to scripting, started 1 - 2 weeks ago )
Reply
#6

Great works, I kinda had the idea just didn't know how to put it, thanks so much!
Reply
#7

EDIT: You should use a SetTimer to update your stats if you want.
Reply
#8

Wow, I'm glad to see that someone has started using my GameMode
Sorry my bad.
pawn Код:
public OnPlayerConnect(playerid);
{
         PlayerInfo[ playerid ][ pCash ] = 0;
// And etc enums just like this DONT ADD PASSWORD VARIABLE 0 Because then password gonna reset and you cant login more...

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)