Problem with saving kill/deaths
#1

When someone registers it gives that player kills and deaths of the player who left before him

onplayerconnect

Код:
	new INI:file = INI_Open(Path(playerid));
 	INI_SetTag(file,"Player's Data");
 	INI_WriteInt(file,"AdminLevel",PInfo[playerid][Level]);
	INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
	INI_WriteInt(file,"Score",GetPlayerScore(playerid));
	INI_WriteInt(file,"Kill",PInfo[playerid][Kill]);
	INI_WriteInt(file,"Death",PInfo[playerid][Death]);
	INI_WriteInt(file,"Mute",MutedTimer[playerid]);
	INI_WriteInt(file,"Jail",JailedTimer[playerid]);
	INI_WriteInt(file,"CMDMuted",CMDMutedTimer[playerid]);
	INI_WriteInt(file,"Crash",PInfo[playerid][Crashed]);
	INI_Close(file);
Onplayedeath

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[128],pName[24],pName1[24];
	SendDeathMessage(killerid,playerid,reason);
	PInfo[playerid][Score]++;
 	PInfo[playerid][Death]++;
 	PInfo[killerid][Kill]++;
 	format(string,sizeof(string),"%d",PInfo[playerid][Death]);
	PlayerTextDrawSetString(playerid,Deaths[playerid],string);
	PlayerTextDrawHide(playerid,Deaths[playerid]);
	PlayerTextDrawShow(playerid,Deaths[playerid]);
	format(string,sizeof(string),"%d",PInfo[playerid][Kill]);
	PlayerTextDrawSetString(playerid,Kills[playerid],string);
	PlayerTextDrawHide(playerid,Kills[playerid]);
	PlayerTextDrawShow(playerid,Kills[playerid]);
}
Register

Код:
if(dialogid == DIALOG_REGISTER)
	{
	    if(!response) return Kick(playerid); 
		if(response) 
		{
			if(!strlen(inputtext)) 
			{
		   		ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"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,"Money",0);
			INI_WriteInt(file,"Score",0);
			INI_WriteInt(file,"Kill",0);
			INI_WriteInt(file,"Death",0);
			INI_WriteInt(file,"Mute",0);
			INI_WriteInt(file,"Jail",0);
			INI_WriteInt(file,"CMDMuted",0);
			INI_WriteInt(file,"Crashed",0);
			INI_Close(file);
			SendClientMessage(playerid,COLOR_GREEN,"You have been successfully registered");
			PInfo[playerid][Logged] = 1;
			TextDrawShowForPlayer(playerid,Loading);
			ShowCustomClassSelection(playerid);
		}
	}
Reply
#2

show me ur enum
Reply
#3

Add:
pawn Код:
PlayerInfo[playerid][Kill] = 0;
PlayerInfo[playerid][Death] = 0;
inside OnPlayerDisconnect (but, before saving the player's stats)
Reply
#4

Quote:
Originally Posted by biker122
Посмотреть сообщение
Add:
pawn Код:
PlayerInfo[playerid][Kill] = 0;
PlayerInfo[playerid][Death] = 0;
inside OnPlayerDisconnect (but, before saving the player's stats)
And that is good for what?
Reply
#5

Once you reset the variables with that playerid, the value comes to 0. It's recommended to reset the variables when a player quits.
Reply
#6

they will be reseted anyways if he loads another Player

if id 0 has 8 deaths and disconnects it stays at 8, but if someone else connects and he has 6 deaths the variable will be set to 6
Reply
#7

Thanks it worked,i saved player stats then setted kills and death to 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)