New players get other player's stats (occasionally)
#1

This is to my knowledge, my entire system that saves the player's stats on register/disconnect. Why would a player be getting another player's stats on their first registration? This is a serious bug and I need to fix this immediately, as players are getting admin stats on occasion.

Код:
#define dregister 2011
#define dlogin 2012
#define UserPath "Users/%s.ini"

native WP_Hash(buffer[],len,const str[]);

new gTeam[MAX_PLAYERS];

enum PlayerInfo
{
    Pass[129],
    Adminlevel,
    VIPlevel,
    Testerlevel,
    Money,
    Scores,
    Kills,
    Deaths,
    pBanned,
    BannedIP[22]
}
new pInfo[MAX_PLAYERS][PlayerInfo];

stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath,name);
    return str;
}

forward loadaccount_user(playerid, name[], value[]);

public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][Pass],129);
    INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
    INI_Int("VIPlevel",pInfo[playerid][VIPlevel]);
    INI_Int("Testerlevel",pInfo[playerid][Testerlevel]);
    INI_Int("Money",pInfo[playerid][Money]); 
    INI_Int("Scores",pInfo[playerid][Scores]);
    INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    INI_Int("pBanned",pInfo[playerid][pBanned]);
    INI_Int("BannedIP",pInfo[playerid][BannedIP]);
    return 1;
}

forward LoadIP_data(playerid, name[], value[]);
public LoadIP_data(playerid, name[], value[])
{
	INI_String("Ip", pInfo[ playerid ][ BannedIP ], 33);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new IP[22];
	GetPlayerIp(playerid, IP, sizeof(IP));
	new INI:file = INI_Open(Path(playerid));
	INI_SetTag(file,"Player's Data");
	INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
	INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
	INI_WriteInt(file,"Testerlevel",pInfo[playerid][Testerlevel]);
	INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
	INI_WriteString(file, "Ip", IP);
	INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
	INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
	INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
	INI_Close(file);
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == dregister)
	{
	    if(!response) return Kick(playerid);
		if(response)
		{
			if(!strlen(inputtext))
			{
		   		ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_PASSWORD,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
				return 1;
			}
			new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file,"Player's Data");
			INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file,"AdminLevel",0);
			INI_WriteInt(file,"VIPLevel",0);
			INI_WriteInt(file,"Testerlevel",0);
			INI_WriteInt(file,"Money",0);
			INI_WriteInt(file,"Scores",0);
			INI_WriteInt(file,"Kills",0);
			INI_WriteInt(file,"Deaths",0);
			INI_Close(file);
			SendClientMessage(playerid,-1,"You have been successfully registered");
			return 1;
		}
	}
	if(dialogid == dlogin)
	{
	    if(!response) return Kick(playerid);
		if(response)
		{
			new hashpass[129];
			WP_Hash(hashpass,sizeof(hashpass),inputtext);
			if(!strcmp(hashpass, pInfo[playerid][Pass], false))
			{
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
				SetPlayerScore(playerid,pInfo[playerid][Scores]);
				GivePlayerMoney(playerid,pInfo[playerid][Money]);
			    SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
			}
			else
			{
				ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
                return 1;
			}
		}
	}
	return 1;
}
Reply


Messages In This Thread
New players get other player's stats (occasionally) - by Sebz - 19.12.2015, 14:48
Re: New players get other player's stats (occasionally) - by jlalt - 19.12.2015, 14:53
Re: New players get other player's stats (occasionally) - by Patrick - 19.12.2015, 15:28

Forum Jump:


Users browsing this thread: 2 Guest(s)