SQL Issues
#3

Quote:
Originally Posted by Calisthenics
View Post
You don't find it relevant but it IS relevant. Post the whole query.
Will do;

Code:
SQL_SaveCharacter(playerid)
{
	if (!SQL_IsLogged(playerid))
		return 0;

	new
	    query[2048];

	if (GetPlayerState(playerid) != PLAYER_STATE_SPECTATING && PlayerData[playerid][pTimeout] || PlayerData[playerid][pInjured] || PlayerData[playerid][pJailed])
	{
	    PlayerData[playerid][pInterior] = GetPlayerInterior(playerid);
	    PlayerData[playerid][pWorld] = GetPlayerVirtualWorld(playerid);

	    GetPlayerPos(playerid, PlayerData[playerid][pPos][0], PlayerData[playerid][pPos][1], PlayerData[playerid][pPos][2]);
	    GetPlayerFacingAngle(playerid, PlayerData[playerid][pPos][3]);

		format(query, sizeof(query), "UPDATE `characters` SET `OnDuty` = '%d', `PosX` = '%.4f', `PosY` = '%.4f', `PosZ` = '%.4f', `PosA` = '%.4f', `Interior` = '%d', `World` = '%d', `Local` = '%d'",
		PlayerData[playerid][pOnDuty],
		PlayerData[playerid][pPos][0],
		PlayerData[playerid][pPos][1],
		PlayerData[playerid][pPos][2],
		PlayerData[playerid][pPos][3],
		PlayerData[playerid][pInterior],
		PlayerData[playerid][pWorld],
		PlayerData[playerid][pLocal]
		);

        if(GetPVarInt(playerid, "WeaponSlot2")) {
            PlayerData[playerid][pGuns][2] = 24;
            PlayerData[playerid][pAmmo][2] = GetPVarInt(playerid, "WeaponSlot2");
            DeletePVar(playerid, "WeaponSlot2");
        }
        
		for (new i = 0; i < 13; i ++) {
			format(query, sizeof(query), "%s, `WpGun%d` = '%d', `WpAmmo%d` = '%d'", query, i + 1, PlayerData[playerid][pGuns][i], i + 1, PlayerData[playerid][pAmmo][i]);
		}

		format(query, sizeof(query), "%s WHERE `ID` = '%d'",
		    query,
			PlayerData[playerid][pID]
		);
		mysql_query(dbCon, query);
	}
	if(PlayerData[playerid][pOOCMask] && !PlayerData[playerid][pDonateRank]) PlayerData[playerid][pOOCMask] = 0;

   	GetPlayerArmour(playerid, PlayerData[playerid][pArmour]);
  	//GetPlayerHealth(playerid, PlayerData[playerid][pHealth]);
	
	format(query, sizeof(query), "UPDATE `characters` SET `Character` = '%s'",
		PlayerData[playerid][pName]
	);

	format(query, sizeof(query), "UPDATE `characters` SET `Created` = '%d', `Gender` = '%d', `Birthdate` = '%d', `Origin` = '%s', `Model` = '%d', `Char` = '%d', `PhoneNumbr` = '%d', `PhoneModel` = '%d', `SpawnPoint` = '%d', `SpawnType` = '%d', `Admin` = '%d', `Level` = '%d', `Exp` = '%d', `PayDay` = '%d', `PayDayHad` = '%d', `PayCheck` = '%d', `ChequeCash` = '%d', `Injured` = '%d', `playerTimeout` = '%d', `MedicBill` = '%d', `Armour` = '%f', `Health` = '%f', `Hunger` = '%f', `FightStyle` = '%d'",
		PlayerData[playerid][pCreated],
		PlayerData[playerid][pGender],
		PlayerData[playerid][pBirthdate],
		PlayerData[playerid][pOrigin],
		PlayerData[playerid][pModel],
		PlayerData[playerid][pChar],
		PlayerData[playerid][pPnumber],
		PlayerData[playerid][pPmodel],
		PlayerData[playerid][pSpawnPoint],
		PlayerData[playerid][pSpawnType],
		PlayerData[playerid][pAdmin],
		PlayerData[playerid][pLevel],
		PlayerData[playerid][pExp],
		PlayerData[playerid][pPayDay],
		PlayerData[playerid][pPayDayHad],
		PlayerData[playerid][pPayCheck],
		PlayerData[playerid][pChequeCash],
		PlayerData[playerid][pInjured],
		PlayerData[playerid][pTimeout],
		MedicBill[playerid],
 		PlayerData[playerid][pArmour],
		PlayerData[playerid][pHealth],
		PlayerData[playerid][pHunger],
		PlayerData[playerid][pFightStyle]
	);


	format(query, sizeof(query), "%s, `BankAccount` = '%d, `Cash` = '%d', `Savings` = '%d', `PlayingHours` = '%d', `plaUpgrade` = '%d', `DonateRank` = '%d', `AlcoholPerk` = '%d', `DrugPerk` = '%d', `MiserPerk` = '%d', `PainPerk` = '%d', `TraderPerk` = '%d', `SpawnHealth` = '%f', `PhoneSilent` = '%d', `PhoneAir` = '%d', `PhoneRingtone` = '%d', `PhoneTextRingtone` = '%d', `Faction` = '%d', `FactionRank` = '%d', `Gun1` = '%d', `Gun2` = '%d', `Gun3` = '%d', `Ammo1` = '%d', `Ammo2` = '%d', `Ammo3` = '%d'",
	    query,
		PlayerData[playerid][pAccount],
		PlayerData[playerid][pCash],
		PlayerData[playerid][pSavings],
		PlayerData[playerid][pPlayingHours],
		PlayerData[playerid][pPUpgrade],
		PlayerData[playerid][pDonateRank],
		PlayerData[playerid][pAlcoholPerk],
		PlayerData[playerid][pDrugPerk],
		PlayerData[playerid][pMiserPerk],
		PlayerData[playerid][pPainPerk],
		PlayerData[playerid][pTraderPerk],
		PlayerData[playerid][pSHealth],
		// ================== [ PHONE SYSTEM ] ============================ , `PhoneSilent` = '%d', `PhoneAir` = '%d', `PhoneRingtone` = '%d'
		ph_silentmode[playerid],
		ph_airmode[playerid],
		ph_CallTone[playerid],
		ph_TextTone[playerid],
		// ================== [ PHONE SYSTEM ] ============================
		PlayerData[playerid][pFactionID],
		PlayerData[playerid][pFactionRank],
		PlayerData[playerid][pGun1],
		PlayerData[playerid][pGun2],
        PlayerData[playerid][pGun3],
        PlayerData[playerid][pAmmo1],
        PlayerData[playerid][pAmmo2],
        PlayerData[playerid][pAmmo3]
	);

	format(query, sizeof(query), "%s, `Radio` = '%d', `RadioChannel` = '%d', `RadioSlot` = '%d', `RadioAuth` = '%s', `playerJob` = '%d', `playerSideJob` = '%d', `playerJobRank` = '%d', `playerCareer` = '%d', `playerHouseKey` = '%d', `PlayerBusinessKey` = '%d', `PlayerCarkey` = '%d', `Checkpoint_Type` = '%d', `Checkpoint_X` = '%f', `Checkpoint_Y` = '%f', `Checkpoint_Z` = '%f', `Fishes` = '%d', `SavingsCollect` = '%d', `ContractTime` = '%d', `OOCMask` = '%d',`Jailed` = %d, `Jailtime` = %d, `CarLic` = %d",
	    query,
	    PlayerData[playerid][pRadio],
	    PlayerData[playerid][pRChannel],
	    PlayerData[playerid][pRSlot],
	    PlayerData[playerid][pRAuth],
	    PlayerData[playerid][pJob],
	    PlayerData[playerid][pSideJob],
	    PlayerData[playerid][pJobRank],
	    PlayerData[playerid][pCareer],
	    PlayerData[playerid][pHouseKey],
	    PlayerData[playerid][pPbiskey],
	    PlayerData[playerid][pPCarkey],
	  	PlayerData[playerid][pCP_Type],
	    PlayerData[playerid][pCP_X],
	    PlayerData[playerid][pCP_Y],
	    PlayerData[playerid][pCP_Z],
	    PlayerData[playerid][pFishes],
	    PlayerData[playerid][pSavingsCollect],
		PlayerData[playerid][pContractTime],
		PlayerData[playerid][pOOCMask],
 		PlayerData[playerid][pJailed],
		PlayerData[playerid][pJailTime],
		PlayerData[playerid][pCarLic]
	);

	format(query, sizeof(query), "%s, `Jailtime2` = %d, `ADPoint` = '%d', `WepLic` = '%d', `PrimaryLicense` = '%d', `SecondaryLicense` = '%d', `CCWLicense` = '%d', `playerSWAT` = '%d',`Tester` = '%d'",
	    query,
	    PlayerData[playerid][pJailTime2],
	    PlayerData[playerid][pADPoint],
	    PlayerData[playerid][pWepLic],
	 	PlayerData[playerid][pPLicense],
		PlayerData[playerid][pSLicense],
		PlayerData[playerid][pCCWLic],
		PlayerData[playerid][pSwat],
		PlayerData[playerid][pTester]
	);


	format(query, sizeof(query), "%s WHERE `ID` = '%d'",
	    query,
		PlayerData[playerid][pID]
	);
	mysql_query(dbCon, query);
	printf("Save Player ID %d: %d", playerid, strlen(query));

	for (new x = 0; x < MAX_SMS; x ++)
	{
		if(SmsData[playerid][x][smsExist])
		{
			format(query, sizeof(query), "UPDATE `phone_sms` SET `Archive` = %d,`ReadSMS` = %d WHERE `id` = %d", SmsData[playerid][x][smsArchive], SmsData[playerid][x][smsRead], SmsData[playerid][x][smsID]);
			mysql_query(dbCon, query);
		}
	}

	for (new id = 0; id < MAX_CLOTHES; id ++)
	{
	    if(ClothingData[playerid][id][cl_object])
	    {
		 	format(query,sizeof(query),"UPDATE clothing SET object = '%d', bone = '%d', slot = '%d', equip = '%d', name = '%s' WHERE id = '%d' AND owner = '%d' LIMIT 1",
		    ClothingData[playerid][id][cl_object],
		    ClothingData[playerid][id][cl_bone],
		    ClothingData[playerid][id][cl_slot],
			ClothingData[playerid][id][cl_equip],
			ClothingData[playerid][id][cl_name],
			ClothingData[playerid][id][cl_sid],
			PlayerData[playerid][pID]);
			mysql_query(dbCon, query);
		}
	}

	/*new housekey = PlayerData[playerid][pHouseKey];
	if(housekey != -1) UpdateHouseInfo(housekey);*/
	//printf("%d",strlen(query));
	return 1;
}
Reply


Messages In This Thread
SQL Issues - by BabyBauer - 15.07.2018, 16:37
Re: SQL Issues - by Calisthenics - 15.07.2018, 16:50
Re: SQL Issues - by BabyBauer - 16.07.2018, 03:52
Re: SQL Issues - by Calisthenics - 16.07.2018, 07:38
Re: SQL Issues - by BabyBauer - 16.07.2018, 12:27

Forum Jump:


Users browsing this thread: 3 Guest(s)