Why new users get stats of other players?(ini)
#6

Quote:
Originally Posted by admigo
Посмотреть сообщение
Код:
//dialog of register
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                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");
                new INI:File = INI_Open(UserPath(playerid));
                new plrIP[16];
				GetPlayerIp(playerid, plrIP, sizeof(plrIP));
				new name[MAX_PLAYER_NAME];
    			GetPlayerName(playerid, name, sizeof(name));
                INI_SetTag(File,"AccountData");
                INI_WriteString(File,"Name",name);
				INI_WriteInt(File,"Password",udb_hash(inputtext));
				INI_WriteString(File,"Ip",plrIP);
 				INI_WriteInt(File,"Registered",1);
  				INI_WriteInt(File,"LoggedIn",1);
		    	INI_WriteInt(File,"Banned",0);
    			INI_WriteInt(File,"Ping",0);
			    INI_WriteInt(File,"PlayersLoggedIn",playersloggedin);
    			INI_WriteInt(File,"PlayersRegistered",playersregistered);
                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,"Rank",0);
    			INI_WriteInt(File,"Captures",0);
    			PlayerInfo[playerid][pPlayersregistered]++;
                INI_Close(File);

                //new listitems1[] = "{FFFF00}Europe Alliance:0{FFFF00}\n{33CCFF}United States Of America:0{33CCFF}\n{00FF00}Sovjet Union:0{00FF00}\n{660000}Japan:0{660000}\n{FF8040}Asian Empire:0{FF8040}\n{FF00FF}Russia:0{FF00FF}\n{800080}Australiл:0{800080}\n{FFFFFF}Afghanistan:0{FFFFFF}";
				//ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"**Select Your Team!**:",listitems1,"Select","");
				//SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                //SpawnPlayer(playerid);
                //ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
			}
        }
Код:
//onplayerdisconnect
public OnPlayerDisconnect(playerid, reason)
{
	new
        string[64],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    switch(reason)
    {
        case 0: format(string,sizeof string,"%s left the server. (Timed out)",name);
        case 1: format(string,sizeof string,"%s left the server. (Leaving)",name);
        case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name);
    }
    pCount[playerid] = 0;
    playersloggedin--;
    SendClientMessageToAll(COLOR_GREY,string);
	new INI:File = INI_Open(UserPath(playerid));
	new plrIP[16];
    INI_SetTag(File,"AccountData");
    SetTimerEx("CheckSpawnPosition", 8000, false, "i", playerid); //time is in milliseconds (8000 Milliseconds = 8 Seconds)
	GetPlayerName(playerid, name, sizeof(name));
  	INI_WriteString(File,"Name",name);
	INI_WriteString(File,"Ip",plrIP);
 	INI_WriteInt(File,"Registered",fexist(UserPath(playerid)));
    INI_WriteInt(File,"LoggedIn",IsPlayerConnected(playerid));
    INI_WriteInt(File,"LoggedIn",0);
    INI_WriteInt(File,"Warnings",PlayerInfo[playerid][Warnings]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][banned]);
	INI_WriteInt(File,"Ping",GetPlayerPing(playerid));
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",0);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Rank",ranklvl[playerid]);
    INI_WriteInt(File,"Captures",capturedzones[playerid]);
    INI_WriteInt(File,"PlayersLoggedIn",playersloggedin);
    INI_WriteInt(File,"PlayersRegistered",playersregistered);
	Delete3DTextLabel(label[playerid]);
	GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    INI_Close(File);
	return 1;
}
I've seperated you code. 'playersloggedin and playersregistered' explain to me what they are.

Try defining everything other than what your writing outside of the code (though i doubt it will affect it), it just seems to be neater in particular.

Other than that, nothing seems to be wrong.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)