Player Stats Don't Save When They Quit!
#1

Hello Guys, i got a problem hope you can help me, my last thread wasn't answered and now its on thrash..
When im joining my server and increase my score for example "50" and then i quit then rejoin again, my score backs to "0" . I know this is because of the gamemode, it doesn't save some stats.. Please Help me

this is all i found on my gamemode about stats

Код:
	//Saved Stats
	if(SavedWantedLevel[playerid] != 0)
	{
	    SetPlayerWantedLevel(playerid,SavedWantedLevel[playerid]);
	    SavedWantedLevel[playerid] =0;
	    SendClientMessage(playerid,COLOR_RED,"You have left the server while wanted. Wanted level restored.");
	}
	if(SavedJailTime[playerid] != 0)
	{
	    TextDrawShowForPlayer(playerid,JailTimer[playerid]);
	    
	    ResetPlayerWeapons(playerid);
	
        new rnd = random(sizeof(JailSpawnPoints));
		JailTime[playerid] =SavedJailTime[playerid];
		IsCuffed[playerid] =0;
		CuffTime[playerid] =0;
		TotalJailTime[playerid] =SavedJailTime[playerid];
		SetPlayerInterior(playerid,10);
		SetPlayerPos(playerid,JailSpawnPoints[rnd][0],JailSpawnPoints[rnd][1],JailSpawnPoints[rnd][2]);
		SetPlayerFacingAngle(playerid,JailSpawnPoints[rnd][3]);
		TogglePlayerControllable(playerid,1);
		StopLoopingAnim(playerid);
		SetPlayerWantedLevel(playerid,0);
		SetPlayerToTeamColour(playerid);
	    SavedJailTime[playerid] =0;
	    SendClientMessage(playerid,COLOR_RED,"You have left the server while in jail. You must finish your sentence.");

		format(string,sizeof(string),"[AUTO JAIL] %s(%d) has been auto jailed for leaving the server while in jail. He will finish his sentence.",PlayerName(playerid),playerid);
		SendClientMessageToAll(COLOR_ADMIN,string);
		
		format(string,sizeof(string),"9[AUTO JAIL] %s(%d) has been auto jailed for leaving the server while in jail. He will finish his sentence.",PlayerName(playerid),playerid);
		IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
	}
	
	//Set Variables
	IsSpawned[playerid] =1;
	return 1;
}
Код:
    if(dialogid == DIALOG_LOGIN)
    {
        if (response == 0)
	    {
	        SendClientMessage(playerid,COLOR_ERROR,"You must login before playing on this server.");
	        ShowLoginScreen(playerid);
	        return 1;
	    }
	    if (response == 1)
	    {
            if (strlen(inputtext) == 0)
			{
			    SendClientMessage(playerid,COLOR_ERROR,"Please enter your password for your account in the box below.");
				ShowLoginScreen(playerid);
				return 1;
			}
			if (udb_CheckLogin(PlayerName(playerid),inputtext))
			{
				BankCash[playerid] =dUserINT(PlayerName(playerid)).("Bankcash");
		   		GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("Money")-GetPlayerMoney(playerid));
		        SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("Score")-GetPlayerScore(playerid));
		        CanUseArmy[playerid] =dUserINT(PlayerName(playerid)).("Army");
		        CanUseCIA[playerid] =dUserINT(PlayerName(playerid)).("CIA");
		        AdminLevel[playerid] =dUserINT(PlayerName(playerid)).("Adminlevel");
		        IsRegularPlayer[playerid] =dUserINT(PlayerName(playerid)).("RegularPlayer");
		        NameBanned[playerid] =dUserINT(PlayerName(playerid)).("Nameban");
		        DrugHouseOwner[playerid] =dUserINT(PlayerName(playerid)).("DrugHouseOwner");
		        OttoOwner[playerid] =dUserINT(PlayerName(playerid)).("OttoOwner");
		        TerroristSkill[playerid] =dUserINT(PlayerName(playerid)).("TSkill");
		        RobSkill[playerid] =dUserINT(PlayerName(playerid)).("RobSkill");
		        HasPackC4[playerid] =dUserINT(PlayerName(playerid)).("HasPackC4");
		        HasPackRope[playerid] =dUserINT(PlayerName(playerid)).("HasPackRope");
		        HasPackMoney[playerid] =dUserINT(PlayerName(playerid)).("HasPackMoney");
		        SavedWantedLevel[playerid] =dUserINT(PlayerName(playerid)).("SavedWantedLevel");
		        SavedJailTime[playerid] =dUserINT(PlayerName(playerid)).("SavedJailTime");
		   		new pIp[16];
				GetPlayerIp(playerid, pIp, sizeof(pIp));
				dUserSet(PlayerName(playerid)).("IP", pIp);
	   			PLAYERLIST_authed[playerid]=true;
	      		return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have successfully logged in! Your previous stats have been restored.");
            }
            ShowLoginScreen(playerid);
			CheckPasswordAttempts(playerid);
        }
        return 1;
	}
this stats always giving me if i quit and rejoin.. i mean if i quit my money, score is gone, and join again this gives me, 5k bank cash and 7.5k hand cash

Код:
	if(dialogid == DIALOG_REGISTER)
    {
        if (response == 0)
	    {
	        SendClientMessage(playerid,COLOR_ERROR,"You must register before playing on this server.");
			ShowRegisterScreen(playerid);
			return 1;
	    }
	    if (response == 1)
	    {
            if (udb_Exists(PlayerName(playerid)))
            {
                SendClientMessage(playerid,COLOR_ERROR,"This account already exists, please choose a different player name.");
                return 1;
			}
            if (strlen(inputtext)==0)
			{
		        SendClientMessage(playerid,COLOR_ERROR,"Please enter your password in the box to register in this server.");
                ShowRegisterScreen(playerid);
				return 1;
			}
            if (udb_Create(PlayerName(playerid),inputtext))
			{
		        SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have registered, now please enter your password in the box to login.");
                ShowLoginScreen(playerid);
		        PLAYERLIST_authed[playerid]=true;
		        dUserSetINT(PlayerName(playerid)).("Money",7500);
			    dUserSetINT(PlayerName(playerid)).("Bankcash",5000);
				dUserSetINT(PlayerName(playerid)).("Score",0);
			    dUserSetINT(PlayerName(playerid)).("Adminlevel",0);
			    dUserSetINT(PlayerName(playerid)).("Nameban",0);
			    dUserSetINT(PlayerName(playerid)).("Army",0);
			    dUserSetINT(PlayerName(playerid)).("CIA",0);
			    dUserSetINT(PlayerName(playerid)).("RegularPlayer",0);
			    dUserSetINT(PlayerName(playerid)).("Nameban",0);
			    dUserSetINT(PlayerName(playerid)).("DrugHouseOwner",0);
			    dUserSetINT(PlayerName(playerid)).("OttoOwner",0);
			    dUserSetINT(PlayerName(playerid)).("TSkill",0);
			    dUserSetINT(PlayerName(playerid)).("RobSkill",0);
			    dUserSetINT(PlayerName(playerid)).("HasPackC4",0);
			    dUserSetINT(PlayerName(playerid)).("HasPackRope",0);
			    dUserSetINT(PlayerName(playerid)).("HasPackMoney",0);
		     	dUserSetINT(PlayerName(playerid)).("SavedJailTime",0);
			    dUserSetINT(PlayerName(playerid)).("SavedWantedLevel",0);
				new pIp[16];
				GetPlayerIp(playerid, pIp, sizeof(pIp));
				dUserSet(PlayerName(playerid)).("IP", pIp);
			}
           return true;
	   }
	    return 1;
    }
Reply
#2

where is your save function in onplayerdisconnect?
Reply
#3

Here it bro! hope you can help!

Код:
public OnPlayerDisconnect(playerid, reason)
{
	if(IsPlayerNPC(playerid))
	{
	    IsSpawned[playerid] =0;
	    return 1;
	}
    if(afktag[playerid] == 1)
	{
		new pname[16];
		GetPlayerName(playerid,pname,16);
		strdel(pname, strlen(pname)-5, strlen(pname));
		afktag[playerid] =0;
		SetPlayerName(playerid,pname);
	}
    new string[128];
	new pname[24];
	GetPlayerName(playerid,pname,sizeof(pname));

	//Save Wanted Level && Jailtime
	SavedWantedLevel[playerid] =GetPlayerWantedLevel(playerid);
	SavedJailTime[playerid] =JailTime[playerid];
	//SavePlayerScore[playerid] =GetPlayerScore(playerid);
	
    	if(PLAYERLIST_authed[playerid] == 1)
	{
		dUserSetINT(PlayerName(playerid)).("Bankcash",BankCash[playerid]);
		dUserSetINT(PlayerName(playerid)).("Cash",GetPlayerMoney(playerid));
		dUserSetINT(PlayerName(playerid)).("Score",GetPlayerScore(playerid));
	 	dUserSetINT(PlayerName(playerid)).("Adminlevel",AdminLevel[playerid]);
		dUserSetINT(PlayerName(playerid)).("Army",CanUseArmy[playerid]);
		dUserSetINT(PlayerName(playerid)).("CIA",CanUseCIA[playerid]);
		dUserSetINT(PlayerName(playerid)).("RegularPlayer",IsRegularPlayer[playerid]);
		dUserSetINT(PlayerName(playerid)).("DrugHouseOwner",DrugHouseOwner[playerid]);
		dUserSetINT(PlayerName(playerid)).("OttoOwner",OttoOwner[playerid]);
		dUserSetINT(PlayerName(playerid)).("TSkill",TerroristSkill[playerid]);
		dUserSetINT(PlayerName(playerid)).("RobSkill",RobSkill[playerid]);
		dUserSetINT(PlayerName(playerid)).("HasPackC4",HasPackC4[playerid]);
		dUserSetINT(PlayerName(playerid)).("HasPackRope",HasPackRope[playerid]);
		dUserSetINT(PlayerName(playerid)).("HasPackMoney",HasPackMoney[playerid]);
		dUserSetINT(PlayerName(playerid)).("SavedWantedLevel",SavedWantedLevel[playerid]);
		dUserSetINT(PlayerName(playerid)).("SavedJailTime",SavedJailTime[playerid]);
	}
	
	//Do things to the playerid
	//ResetVariables(playerid);
	TextDrawHideForPlayer(playerid,VersionTD);
	TextDrawHideForPlayer(playerid,WebsiteTD);
	TextDrawDestroy(MessageTD[playerid]);
	TextDrawDestroy(JailTimer[playerid]);
	TextDrawDestroy(LocationTD[playerid]);
	
	if (PlayerInfo[playerid][pRoadblock] != 0)
	{
		RemoveRoadblock(playerid);
	}
	for(new i = 0; i < sizeof(Objects); i++) ////Xobj
	{
		if(Player[playerid][view][i])
		{
			Player[playerid][view][i] = false;
			DestroyPlayerObject(playerid,Player[playerid][objid][i]);
		}
	}
	format(string,sizeof(string),"%s Has left the server! (%s)",pname,aDisconnectNames[reason]);
	SendClientMessageToAll(COLOR_VIOLETBLUE,string);
	format(string,sizeof(string),"1%s Has left the server! (%s)",pname,aDisconnectNames[reason]);
	IRC_Say(gGroupID,IRC_CHANNEL,string);
	return 1;
}
Reply
#4

anyone can help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)