whats wrong with saving / loading?..
#1

Hello.. Im have a problem, with player stats saving / loading.. When u disconnect

Код:
public LoadPlayerData(playerid)
{
    new name[MAX_PLAYER_NAME],file[128];
	GetPlayerName(playerid,name,sizeof(name));
	format(file,sizeof(file),"saves/user/%s.ini",name);
	if(!fexist(file)) return;
	
	new tmpxp = dini_Int(file,"Xp");
	
	if(!tmpxp) return;
	

    SetPlayerScore(playerid,tmpxp);
	SetPlayerPos(playerid,dini_Float(file,"Pozicija_X"),dini_Float(file,"Pozicija_Y"),dini_Float(file,"Pozicija_Z"));
    SetPlayerInterior(playerid,dini_Int(file,"Interioras"));
    SetPlayerWantedLevel(playerid,dini_Int(file,"Ieskomumas"));
    ResetPlayerMoneyA(playerid);
    GivePlayerMoneyA(playerid,dini_Int(file,"Pinigai.Rankose"));
	SetPlayerVirtualWorld(playerid,dini_Int(file,"Virtualus.Pasaulis"));
	SetPVarInt(playerid, "Pinigai.Banke", dini_Int(file, "Pinigai.Banke"));
	playerDB[playerid][mobsas] = dini_Int(file,"Mobilus");
	SetPVarInt(playerid, "Narkotikai", dini_Int(file, "Narkotikai"));
	SetPVarInt(playerid, "Lytis", dini_Int(file, "Lytis"));
	SetPVarInt(playerid, "Drabuziai", dini_Int(file,"Drabuziai"));
	SetPVarInt(playerid, "Teises", dini_Int(file,"Teises"));
	SetPVarInt(playerid, "Naujokas", dini_Int(file,"Naujokas"));
	SetPVarInt(playerid, "Ginklas", dini_Int(file,"Ginklas"));
	SetPVarInt(playerid, "Ispejimai", dini_Int(file,"Ispejimai"));
	SetPVarInt(playerid, "Uniforma", dini_Int(file,"Uniforma"));
	SetPVarInt(playerid, "Uniformd", dini_Int(file,"Uniformd"));
 	SetPVarInt(playerid, "Direktorius", dini_Int(file,"Direktorius"));
 	SetPVarInt(playerid,"Kalejimo.Laikas", dini_Int(file,"Kalejimo.Laikas"));
 	SetPVarInt(playerid, "Specialybe", dini_Int(file, "Darbas"));
 	SetPVarInt(playerid, "Pastatas", dini_Int(file, "Pastatas"));
	
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas0"),dini_Int(file,"Ammo0"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas1"),dini_Int(file,"Ammo1"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas2"),dini_Int(file,"Ammo2"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas3"),dini_Int(file,"Ammo3"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas4"),dini_Int(file,"Ammo4"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas5"),dini_Int(file,"Ammo5"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas6"),dini_Int(file,"Ammo6"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas7"),dini_Int(file,"Ammo7"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas8"),dini_Int(file,"Ammo8"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas9"),dini_Int(file,"Ammo9"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas10"),dini_Int(file,"Ammo10"));
	GivePlayerWeapon(playerid,dini_Int(file,"Ginklas11"),dini_Int(file,"Ammo11"));

	//Checks that prevent lots of bandwith
 	if(gSession==dini_Int(file,"Paskutine.Sesija"))
	{
		playerDB[playerid][pcar] = dini_Int(file,"Masina");
		if(playerDB[playerid][pcar] != -1)
		{
			if(strcmp(name,vehicleDB[playerDB[playerid][pcar]][owner_name],true) || !vehicleDB[playerDB[playerid][pcar]][locked]) playerDB[playerid][pcar]=-1;
		}
 	}else{
        playerDB[playerid][pcar]=-1;
	}

    if(GetPVarInt(playerid, "Kalejimo.Laikas") > 0)
	{
	    SetTimerEx("UnjailPlayer",GetPVarInt(playerid, "Kalejimo.Laikas")*1000,0,"iffffi",playerid,-1597.6338,716.4904,11.7759,341.3682,0);
		SetPVarInt(playerid, "Ikalintas", 1);
	}
	
 if(GetPVarInt(playerid, "Uniformd") == 1)
	    SetPlayerSkin(playerid,GetPVarInt(playerid, "Uniforma"));
	else
	    SetPlayerSkin(playerid,GetPVarInt(playerid, "Drabuziai"));
	
	return;
}

public SavePlayerData(playerid,bool:simple)
{
	new name[MAX_PLAYER_NAME],file[128];
	GetPlayerName(playerid,name,sizeof(name));
	format(file,sizeof(file),"saves/user/%s.ini",name);
	if(!fexist(file)) return;
	new Float:coo[3],weps[2][12];
	
	dini_IntSet(file,"Pinigai.Rankose",GetPlayerMoneyA(playerid));
	dini_IntSet(file,"Pinigai.Banke",GetPVarInt(playerid, "Pinigai.Banke"));
	dini_IntSet(file,"Ieskomumas",GetPlayerWantedLevel(playerid));
	dini_IntSet(file,"Masina",playerDB[playerid][pcar]);
	dini_IntSet(file,"Paskutine.Sesija",gSession);
	dini_IntSet(file,"Direktorius",GetPVarInt(playerid, "Direktorius"));
	dini_IntSet(file,"Kalejimo.Laikas",GetPVarInt(playerid, "Kalejimo.Laikas"));
	
	for (new tmp=0; tmp<12; tmp++) GetPlayerWeaponData(playerid,tmp,weps[0][tmp],weps[1][tmp]);
	dini_IntSet(file,"Ginklas0",weps[0][0]); dini_IntSet(file,"Ammo0",weps[1][0]);
	dini_IntSet(file,"Ginklas1",weps[0][1]); dini_IntSet(file,"Ammo1",weps[1][1]);
	dini_IntSet(file,"Ginklas2",weps[0][2]); dini_IntSet(file,"Ammo2",weps[1][2]);
	dini_IntSet(file,"Ginklas3",weps[0][3]); dini_IntSet(file,"Ammo3",weps[1][3]);
	dini_IntSet(file,"Ginklas4",weps[0][4]); dini_IntSet(file,"Ammo4",weps[1][4]);
	dini_IntSet(file,"Ginklas5",weps[0][5]); dini_IntSet(file,"Ammo5",weps[1][5]);
	dini_IntSet(file,"Ginklas6",weps[0][6]); dini_IntSet(file,"Ammo6",weps[1][6]);
	dini_IntSet(file,"Ginklas7",weps[0][7]); dini_IntSet(file,"Ammo7",weps[1][7]);
	dini_IntSet(file,"Ginklas8",weps[0][8]); dini_IntSet(file,"Ammo8",weps[1][8]);
	dini_IntSet(file,"Ginklas9",weps[0][9]); dini_IntSet(file,"Ammo9",weps[1][9]);
	dini_IntSet(file,"Ginklas10",weps[0][10]); dini_IntSet(file,"Ammo10",weps[1][10]);
	dini_IntSet(file,"Ginklas11",weps[0][11]); dini_IntSet(file,"Ammo11",weps[1][11]);
	
	dini_IntSet(file, "Darbas", GetPVarInt(playerid, "Specialybe"));
	dini_IntSet(file, "Drabuziai", GetPVarInt(playerid, "Drabuziai"));
	dini_IntSet(file,"Uniforma",GetPVarInt(playerid, "Uniforma"));

	if(simple) return;
	
	GetPlayerPos(playerid,coo[0],coo[1],coo[2]);
    dini_IntSet(file,"Patirtis",GetPlayerScore(playerid));
	dini_IntSet(file,"Mobilus",playerDB[playerid][mobsas]);
	dini_IntSet(file, "Pastatas", GetPVarInt(playerid, "Pastatas"));
	dini_IntSet(file, "Naujokas", GetPVarInt(playerid, "Naujokas"));
	dini_IntSet(file, "Lytis", GetPVarInt(playerid, "Lytis"));
	dini_IntSet(file, "Uniformd", GetPVarInt(playerid, "Uniformd"));
	dini_IntSet(file, "Teises", GetPVarInt(playerid, "Teises"));
	dini_IntSet(file, "Ginklas", GetPVarInt(playerid, "Ginklas"));
	dini_IntSet(file, "Ispejimai", GetPVarInt(playerid, "Ispejimai"));
	dini_FloatSet(file,"Pozicija_X",coo[0]);	dini_FloatSet(file,"Pozicija_Y",coo[1]);	dini_FloatSet(file,"Pozicija_Z",coo[2]);
	dini_IntSet(file,"Interioras",GetPlayerInterior(playerid));
	
	dini_IntSet(file,"Narkotikai",GetPVarInt(playerid, "Narkotikai"));
	dini_IntSet(file,"Virtualus.Pasaulis",GetPlayerVirtualWorld(playerid));
	
 	SetPVarInt(playerid, "Statistika", 4);
}
and when player disconnect.(leave)
Код:
public OnPlayerDisconnect(playerid, reason)
{
new
	Stringas[69],
	ZaidejoVardas[MAX_PLAYER_NAME];
	GetPlayerName(playerid, ZaidejoVardas, MAX_PLAYER_NAME);
	switch(reason)
    {
        case 0:
        {
		SavePlayerData(playerid,false);
		format(Stringas,sizeof(Stringas),"Serveris: %s atsijungл. (Crash)",ZaidejoVardas);
		SendClientMessage(playerid,BALTA,Stringas);
		print(Stringas);
		}
        case 1:
		{
	 	SavePlayerData(playerid,false);
 		format(Stringas,sizeof(Stringas),"Serveris: %s atsijungл. (Atsijungл)",ZaidejoVardas);
		SendClientMessage(playerid,BALTA,Stringas);
		print(Stringas);
		}
        case 2:
		{
		SavePlayerData(playerid,false);
		format(Stringas,sizeof(Stringas),"Serveris: %s atsijungл. (Uюblokuotas/Iрmestas)",ZaidejoVardas);
		SendClientMessage(playerid,BALTA,Stringas);
		print(Stringas);
		}
		}
other shit
please help, thx.
Reply
#2

maybe because you dont save all the data on OnPlayerDisconnect? i mean.. when you connect, it loads, but when you log off, it doesn't save, does it?
Reply
#3

Quote:
Originally Posted by Gh0sT_
Посмотреть сообщение
Hello.. Im have a problem, with player stats saving / loading..
What problem?
Reply
#4

Ok, srry.. When i connect, get some XP, etc(saving ok), and do relog - all stats gone.
Reply
#5

Look in to the userfile, if it saves at all. If not you atleast know that the problem is in saving part.
Reply
#6

When i connect, and play ~3mins(to get some score) and log off. - All me get'ed score, etc saving OK. But, when i connect again ( after relog ) my stats are for newbie again ( 500score, etc. ) if u need, i will show u register, and login..
Reply
#7

GhosT_ tu esi tas pats Ghost_?
Reply
#8

PM tam skirta, 'english only there'
Reply
#9

ohhh PM i forgot
Reply
#10

bumbmbpypypy
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)