Problem tutorial retaking or update account stats
#1

If i register and loging, then im retaking to tutorial. If tutorial over, then i log out. (Saving account stats to mySQL)
Then i go server and logging, now retaking tutorial. Wtf? I did just over tutorial...?

OnPlayerUpdate
pawn Код:
public OnPlayerUpdate(playerid) // by Luk0r v1.2
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
        {
            MySQLCheckConnection();
            new query[MAX_STRING];
            format(query, MAX_STRING, "UPDATE players SET ");
            MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pKey]);
            PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "PlayerLevel", PlayerInfo[playerid][pLevel]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "AdminLevel", PlayerInfo[playerid][pAdmin]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "DonateRank", PlayerInfo[playerid][pDonateRank]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "UpgradePoints", PlayerInfo[playerid][gPupgrade]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "ConnectedTime", PlayerInfo[playerid][pConnectTime]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Registered", PlayerInfo[playerid][pReg]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Sex", PlayerInfo[playerid][pSex]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Age", PlayerInfo[playerid][pAge]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Origin", PlayerInfo[playerid][pOrigin]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "CK", PlayerInfo[playerid][pCK]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Muted", PlayerInfo[playerid][pMuted]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Respect", PlayerInfo[playerid][pExp]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Money", PlayerInfo[playerid][pCash]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Bank", PlayerInfo[playerid][pAccount]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Crimes", PlayerInfo[playerid][pCrimes]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Kills", PlayerInfo[playerid][pKills]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Deaths", PlayerInfo[playerid][pDeaths]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Arrested", PlayerInfo[playerid][pArrested]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "WantedDeaths", PlayerInfo[playerid][pWantedDeaths]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Phonebook", PlayerInfo[playerid][pPhoneBook]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "LottoNr", PlayerInfo[playerid][pLottoNr]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Fishes", PlayerInfo[playerid][pFishes]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "BiggestFish", PlayerInfo[playerid][pBiggestFish]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Job", PlayerInfo[playerid][pJob]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Paycheck", PlayerInfo[playerid][pPayCheck]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "HeadValue", PlayerInfo[playerid][pHeadValue]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Jailed", PlayerInfo[playerid][pJailed]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "JailTime", PlayerInfo[playerid][pJailTime]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Materials", PlayerInfo[playerid][pMats]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Drugs", PlayerInfo[playerid][pDrugs]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Leader", PlayerInfo[playerid][pLeader]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Member", PlayerInfo[playerid][pMember]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "FMember", PlayerInfo[playerid][pFMember]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Rank", PlayerInfo[playerid][pRank]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Chara", PlayerInfo[playerid][pChar]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "ContractTime", PlayerInfo[playerid][pContractTime]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "DetSkill", PlayerInfo[playerid][pDetSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "SexSkill", PlayerInfo[playerid][pSexSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "BoxSkill", PlayerInfo[playerid][pBoxSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "LawSkill", PlayerInfo[playerid][pLawSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "MechSkill", PlayerInfo[playerid][pMechSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "JackSkill", PlayerInfo[playerid][pJackSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "CarSkill", PlayerInfo[playerid][pCarSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "NewsSkill", PlayerInfo[playerid][pNewsSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "DrugsSkill", PlayerInfo[playerid][pDrugsSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "CookSkill", PlayerInfo[playerid][pCookSkill]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "FishSkill", PlayerInfo[playerid][pFishSkill]);
            MySQLUpdatePlayerFlo(query, PlayerInfo[playerid][pSQLID], "pSHealth", PlayerInfo[playerid][pSHealth]);
            GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
            MySQLUpdatePlayerFlo(query, PlayerInfo[playerid][pSQLID], "pHealth", PlayerInfo[playerid][pHealth]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Inte", PlayerInfo[playerid][pInt]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Local", PlayerInfo[playerid][pLocal]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Team", PlayerInfo[playerid][pTeam]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Model", PlayerInfo[playerid][pModel]);
            //MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Model", GetPlayerSkin(playerid));
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "PhoneNr", PlayerInfo[playerid][pPnumber]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "House", PlayerInfo[playerid][pPhousekey]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Car", PlayerInfo[playerid][pPcarkey]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Bizz", PlayerInfo[playerid][pPbiskey]);
            if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0))
            {
                PlayerInfo[playerid][pPos_x] = 1684.9;
                PlayerInfo[playerid][pPos_y] = -2244.5;
                PlayerInfo[playerid][pPos_z] = 13.5;
            }
            if(Spectate[playerid] != 255)
            {
                PlayerInfo[playerid][pPos_x] = Unspec[playerid][sPx];
                PlayerInfo[playerid][pPos_y] = Unspec[playerid][sPy];
                PlayerInfo[playerid][pPos_z] = Unspec[playerid][sPz];
                PlayerInfo[playerid][pInt] = Unspec[playerid][sPint];
                PlayerInfo[playerid][pLocal] = Unspec[playerid][sLocal];
            }
            new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid,x,y,z);
            PlayerInfo[playerid][pPos_x] = x;
            PlayerInfo[playerid][pPos_y] = y;
            PlayerInfo[playerid][pPos_z] = z;
            MySQLUpdatePlayerFlo(query, PlayerInfo[playerid][pSQLID], "Pos_x", PlayerInfo[playerid][pPos_x]);
            MySQLUpdatePlayerFlo(query, PlayerInfo[playerid][pSQLID], "Pos_y", PlayerInfo[playerid][pPos_y]);
            MySQLUpdatePlayerFlo(query, PlayerInfo[playerid][pSQLID], "Pos_z", PlayerInfo[playerid][pPos_z]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "CarLic", PlayerInfo[playerid][pCarLic]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "FlyLic", PlayerInfo[playerid][pFlyLic]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "BoatLic", PlayerInfo[playerid][pBoatLic]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "FishLic", PlayerInfo[playerid][pFishLic]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "GunLic", PlayerInfo[playerid][pGunLic]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Gun1", PlayerInfo[playerid][pGun1]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Gun2", PlayerInfo[playerid][pGun2]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Gun3", PlayerInfo[playerid][pGun3]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Gun4", PlayerInfo[playerid][pGun4]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Ammo1", PlayerInfo[playerid][pAmmo1]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Ammo2", PlayerInfo[playerid][pAmmo2]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Ammo3", PlayerInfo[playerid][pAmmo3]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Ammo4", PlayerInfo[playerid][pAmmo4]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "CarTime", PlayerInfo[playerid][pCarTime]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "PayDay", PlayerInfo[playerid][pPayDay]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "PayDayHad", PlayerInfo[playerid][pPayDayHad]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Watch", PlayerInfo[playerid][pWatch]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Crashed", PlayerInfo[playerid][pCrashed]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Wins", PlayerInfo[playerid][pWins]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Loses", PlayerInfo[playerid][pLoses]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "AlcoholPerk", PlayerInfo[playerid][pAlcoholPerk]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "DrugPerk", PlayerInfo[playerid][pDrugPerk]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "MiserPerk", PlayerInfo[playerid][pMiserPerk]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "PainPerk", PlayerInfo[playerid][pPainPerk]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "TraderPerk", PlayerInfo[playerid][pTraderPerk]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Tutorial", PlayerInfo[playerid][pTut]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Mission", PlayerInfo[playerid][pMissionNr]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Warnings", PlayerInfo[playerid][pWarns]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "VirWorld", PlayerInfo[playerid][pVirWorld]);
            if(PlayerInfo[playerid][pDonateRank] < 1) { PlayerInfo[playerid][pFuel] = 0; }
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Fuel", PlayerInfo[playerid][pFuel]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Married", PlayerInfo[playerid][pMarried]);
            MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "MarriedTo", PlayerInfo[playerid][pMarriedTo]);
            MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Locked", PlayerInfo[playerid][pLocked]);
            MySQLUpdateFinish(query, PlayerInfo[playerid][pSQLID]);
        }
    }
    return 1;
}
Im not using MTRP or anything script's.
Reply
#2

this is only the saving code, it just save what is stored, no connection with the tutorial itself

and try to move this code from OnPlayerUpdate to a 1 sec timer (way more effective) actually you only need a 1 min timer or none, just save it at disconnect
Reply
#3

Quote:
Originally Posted by ♣ ⓐⓢⓢ
this is only the saving code, it just save what is stored, no connection with the tutorial itself

and try to move this code from OnPlayerUpdate to a 1 sec timer (way more effective) actually you only need a 1 min timer or none, just save it at disconnect
What you mean? There's OnPlayerUpdate(playerid); in OnPlayerDisconnect...
Reply
#4

OnPlayerUpdate is a samp callback, not a custom function and its called waaay more times then you'll ever need to have it called
http://forum.sa-mp.com/index.php?topic=115828.0

Your problem lies either that the player data doesn't get loaded in OnPlayerConnect or that you have something mixed up in OnPlayerSpawn or where ever you have your tutorial code
Reply
#5

Teh,how i do fix that problem? :S

SetPlayerSpawn
pawn Код:
if(PlayerInfo[playerid][pTut] == 0)
      {
            gOoc[playerid] = 1; gNews[playerid] = 1; gFam[playerid] = 1;
            SetPlayerInterior(playerid, 3);
            PlayerInfo[playerid][pInt] = 3;
            SetPlayerPos(playerid, 330.6825,163.6688,1014.1875);
            SetPlayerFacingAngle(playerid, 280);
            TogglePlayerControllable(playerid, 0);
            RegistrationStep[playerid] = 1;
            SendClientMessage(playerid, COLOR_YELLOW, "Tere tulemast Rollimдngu. Sind viiakse Immigratsiooni.");
            SendClientMessage(playerid, COLOR_LIGHTRED, "Esimene kьsimus: Kas sa oled Mees vхi Naine ?");
            return 1;
}
OnPlayerConnect
http://pawn.pastebin.com/m518d6228
Reply
#6

Quote:
Originally Posted by Mechscape
Teh,how i do fix that problem? :S
Quote:
Originally Posted by dice7
Your problem lies either that the player data doesn't get loaded in OnPlayerConnect or that you have something mixed up in OnPlayerSpawn or where ever you have your tutorial code
Also the loading code or the tutorial code!
Reply
#7

Do i add that code's:
Код:
if(PlayerInfo[playerid][pTut] == 0)
	  {
			gOoc[playerid] = 1; gNews[playerid] = 1; gFam[playerid] = 1;
			SetPlayerInterior(playerid, 3);
			PlayerInfo[playerid][pInt] = 3;
			SetPlayerPos(playerid, 330.6825,163.6688,1014.1875);
			SetPlayerFacingAngle(playerid, 280);
			TogglePlayerControllable(playerid, 0);
			RegistrationStep[playerid] = 1;
			SendClientMessage(playerid, COLOR_YELLOW, "Tere tulemast Rollimдngu. Sind viiakse Immigratsiooni.");
			SendClientMessage(playerid, COLOR_LIGHTRED, "Esimene kьsimus: Kas sa oled Mees vхi Naine ?");
			return 1;
	  }
into OnPlayerConnect?

Or what code is, like loading player stats?
Reply
#8

this code shows us what will happens if the player didnt do the tutorial
he gets asked if he is male or female, after the last messages should be "PlayerInfo[playerid][pTut] = 1" somewhere
Reply
#9

Half-code:
Код:
if(RegistrationStep[playerid] > 0)
	{
	  if(RegistrationStep[playerid] == 1)
	  {
	    new idx;
	  	tmp = strtok(text, idx);
		  if((strcmp("mees", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("Mees")))
			{
			  PlayerInfo[playerid][pSex] = 1;
			  SendClientMessage(playerid, COLOR_YELLOW2, "Olgu, sa oled mees.");
			  SendClientMessage(playerid, COLOR_LIGHTRED, "Sind viiakse nььd хpetusele.");
			  new maleskin;
			  maleskin = random(sizeof(CivMalePeds));
			  SetPlayerSkin(playerid, maleskin);
			  PlayerInfo[playerid][pChar] = maleskin;
			  RegistrationStep[playerid] = 0;
			  TutTime[playerid] = 1;
			  return 0;
			}
			else if((strcmp("naine", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("Naine")))
			{
			  PlayerInfo[playerid][pSex] = 2;
			  SendClientMessage(playerid, COLOR_YELLOW2, "Olgu, sa oled naine.");
			  SendClientMessage(playerid, COLOR_LIGHTRED, "Sind viiakse nььd хpetusele.");
			  new femaleskin;
			  femaleskin = random(sizeof(CivFemalePeds));
			  SetPlayerSkin(playerid, femaleskin);
			  SetPlayerSkin(playerid, femaleskin);
			  PlayerInfo[playerid][pChar] = femaleskin;
			  RegistrationStep[playerid] = 0;
			  TutTime[playerid] = 1;
			  return 0;
			}
			else
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "Kas sa oled Mees vхi Naine?");
			}
			return 0;
		}
		return 0;
	}
Should i do add "PlayerInfo[playerid][pTut] = 1"?
Reply
#10

so much I understood this code says what you typed in (male or female)
and if it ends here, we need to put "PlayerInfo[playerid][pTut] = 1" there

pawn Код:
if(RegistrationStep[playerid] > 0)
    {
        if(RegistrationStep[playerid] == 1)
        {
            if(strcmp("mees", text, true) == 0)
            {
                SendClientMessage(playerid, COLOR_YELLOW2, "Olgu, sa oled mees.");
                SendClientMessage(playerid, COLOR_LIGHTRED, "Sind viiakse nььd хpetusele.");
                PlayerInfo[playerid][pChar] = random(sizeof(CivMalePeds));
                SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]);
                PlayerInfo[playerid][pSex] = 1;
                PlayerInfo[playerid][pTut] = 1;
                RegistrationStep[playerid] = 0;
                TutTime[playerid] = 1;
            }
            else if(strcmp("naine", text, true) == 0)
            {
                SendClientMessage(playerid, COLOR_YELLOW2, "Olgu, sa oled naine.");
                SendClientMessage(playerid, COLOR_LIGHTRED, "Sind viiakse nььd хpetusele.");
                PlayerInfo[playerid][pChar] = random(sizeof(CivFemalePeds));
                SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]);
                PlayerInfo[playerid][pSex] = 2;
                PlayerInfo[playerid][pTut] = 1;
                RegistrationStep[playerid] = 0;
                TutTime[playerid] = 1;
            }
            else    SendClientMessage(playerid, COLOR_LIGHTRED, "Kas sa oled Mees vхi Naine?");
        }
        return 0;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)