MySQL saving everything apart from playerdata
#1

I'm having trouble getting Player data to save in a gamemode I'm trying to edit, even though its using an old version of MySQL (R5) I cant figure out why it wont create players in the playerdata table when they /register.
Saving/loading houses works fine, but for some reason player data wont save.

Anybody have any ideas on how to fix this? I'm thinking its something minor I've missed as the house saving works fine

Ive been trying to solve this for days so would be very appreciative of any help or suggestions on how to solve it

When a player registers:
Код:
	new string[256],query[256],escpass[256],PIP[56],LastLogin[128];
				mysql_real_escape_string(inputtext, escpass);

				//mysql_real_escape_string(PlayerInfo[playerid][pName],PlayerInfo[playerid][pName]);
				//mysql_real_escape_string(inputtext,inputtext);

				format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP);
				mysql_query(query);

            	//format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES ('%s', md5('%s'), '%s')",PlayerInfo[playerid][pName], inputtext, PIP); //Insert string
				//mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET Registered = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]);
				mysql_query(query); //queries

				format(query,sizeof(query),"UPDATE playerdata SET LastLogin = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]);
				mysql_query(query); //queries

				mysql_free_result();

                PlayerInfo[playerid][pLogged] = 1;
                PlayerInfo[playerid][pRegistered] = 1;
                //SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "Registered And Logged In.");

				SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "New Account Created.  Your Are Now Logged In.  ");//Please Read The Registration Info.
				SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "Type /help  and  /commands  For Game Information, or visit "WEBSITE"");
SavePlayerStats
Код:
stock SavePlayerStats(playerid)
{
    if(!IsPlayerNPC(playerid) && PlayerInfo[playerid][pRegistered] == 1 && PlayerInfo[playerid][pLogged] == 1 && PlayerInfo[playerid][pSpawn] == 1) //Only saves if the player was logged in and spawned
    {
			new query[300],string[256],Float:Health,Float:Armour;

			if (PlayerInfo[playerid][pReturnWeapons] == 0)
			{
			for (new s=0; s<12; s++)
			{
			GetPlayerWeaponData(playerid, s, PlayerInfo[playerid][pWeapon][s],PlayerInfo[playerid][pAmmo][s]);
			}
			}

			PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
			PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);

			GetPlayerHealth(playerid, Health);
			format(string, sizeof(string), "%d",floatround(Health));
			PlayerInfo[playerid][pHealth] = strval(string);

			GetPlayerArmour(playerid, Armour);
			format(string, sizeof(string), "%d",floatround(Armour));
			PlayerInfo[playerid][pArmour] = strval(string);

   format(query,sizeof(query),"UPDATE playerdata SET ConnHour = '%d' ,ConnMinute = '%d' ,ConnSecond = '%d' ,ConnTime = '%s',Tutorial = '%d',Regular = '%d',Donator = '%d',Score = '%d'  WHERE UserName = '%s'",PlayerInfo[playerid][pConnHour],PlayerInfo[playerid][pConnMinute],PlayerInfo[playerid][pConnSecond],PlayerInfo[playerid][pConnTime],PlayerInfo[playerid][pTutorial],PlayerInfo[playerid][pRegular],PlayerInfo[playerid][pDonator],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pName]);
			mysql_query(query);


			switch (CURRENT_GAMEMODE)
			{

				case LOS_SANTOS:
				{

    format(query,sizeof(query),"UPDATE playerdata SET LsResume = '%d',LsClass = '%d',LsTeam = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pResume],PlayerInfo[playerid][pClass],PlayerInfo[playerid][pTeam],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsSkill = '%d',LsLevel = '%d',LsRank = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pSkill],PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pRank],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMoney = '%d',LsHealth = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pMoney],PlayerInfo[playerid][pHealth],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsArmour = '%d',LsFakeSkill = '%d',LsGender = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pArmour],PlayerInfo[playerid][pFakeSkill],PlayerInfo[playerid][pGender],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsWeapon1 = '%d',LsAmmo1 = '%d',LsWeapon2 = '%d',LsAmmo2 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pWeapon][1] ,PlayerInfo[playerid][pAmmo][1],PlayerInfo[playerid][pWeapon][2],PlayerInfo[playerid][pAmmo][2],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsWeapon3 = '%d',LsAmmo3 = '%d',LsWeapon4 = '%d',LsAmmo4 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pWeapon][3] ,PlayerInfo[playerid][pAmmo][3],PlayerInfo[playerid][pWeapon][4],PlayerInfo[playerid][pAmmo][4],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsWeapon5 = '%d',LsAmmo5 = '%d',LsWeapon6 = '%d',LsAmmo6 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pWeapon][5] ,PlayerInfo[playerid][pAmmo][5],PlayerInfo[playerid][pWeapon][6],PlayerInfo[playerid][pAmmo][6],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsWeapon7 = '%d',LsAmmo7 = '%d',LsWeapon8 = '%d',LsAmmo8 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pWeapon][7] ,PlayerInfo[playerid][pAmmo][7],PlayerInfo[playerid][pWeapon][8],PlayerInfo[playerid][pAmmo][8],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsWeapon9 = '%d',LsAmmo9 = '%d',LsWeapon10 = '%d',LsAmmo10 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pWeapon][9] ,PlayerInfo[playerid][pAmmo][9],PlayerInfo[playerid][pWeapon][10],PlayerInfo[playerid][pAmmo][10],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsWeapon11 = '%d',LsAmmo11 = '%d',LsWeapon12 = '%d',LsAmmo12 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pWeapon][11] ,PlayerInfo[playerid][pAmmo][11],PlayerInfo[playerid][pWeapon][12],PlayerInfo[playerid][pAmmo][12],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsCondom = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pCondom],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsStd1 = '%d',LsStd2 = '%d',LsStd3 = '%d',LsStd4 = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pStd][1] ,PlayerInfo[playerid][pStd][2],PlayerInfo[playerid][pStd][3],PlayerInfo[playerid][pStd][4],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsChastity = '%d',LsFightStyle = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pChastity],PlayerInfo[playerid][pFightStyle],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsAdrenaline = '%d',LsEarnings = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pAdrenaline],PlayerInfo[playerid][pEarnings],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsBank = '%d',LsInterest = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pBank],PlayerInfo[playerid][pInterest],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsTaxes = '%d',LsDebt = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pTaxes],PlayerInfo[playerid][pDebt],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsLifeInsurance = '%d',LsHealthInsurance = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pLifeInsurance],PlayerInfo[playerid][pHealthInsurance],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsBankInsurance = '%d',LsWantedLevel = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pBankInsurance],PlayerInfo[playerid][pWantedLevel],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsDaysAlive = '%d',LsDrugs = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pDaysAlive],PlayerInfo[playerid][pDrugs],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsDeaths = '%d',LsKills = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsHeals = '%d',LsHealed = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pHeals],PlayerInfo[playerid][pHealed],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsVehiclesStolen = '%d',LsVehiclesSold = '%d',LsCrimesCommitted = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pVehiclesStolen],PlayerInfo[playerid][pVehiclesSold],PlayerInfo[playerid][pCrimesCommitted],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsTicketsReceived = '%d',LsTicketsPaid = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pTicketsReceived],PlayerInfo[playerid][pTicketsPaid],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsTicketsIssued = '%d',LsTicketsCollected = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pTicketsIssued],PlayerInfo[playerid][pTicketsCollected],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsArrested = '%d',LsReported = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pArrested],PlayerInfo[playerid][pReported],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsArrests = '%d',LsReports = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pArrests],PlayerInfo[playerid][pReports],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsHitsReceived = '%d',LsHitsPlaced = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pHitsReceived],PlayerInfo[playerid][pHitsPlaced],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsRapes = '%d',LsRaped = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pRapes],PlayerInfo[playerid][pRaped],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsRobberies = '%d',LsRobbed = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pRobberies],PlayerInfo[playerid][pRobbed],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsBail = '%d',LsJailVisits = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pBail],PlayerInfo[playerid][pJailVisits],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsJailed = '%d',LsJailHour = '%d',LsJailMinute = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pJailed],PlayerInfo[playerid][pJailHour],PlayerInfo[playerid][pJailMinute],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsHouse = '%d',LsCar = '%d',LsGunLic = '%d' WHERE UserName = '%s'",PlayerInfo[playerid][pHouse],PlayerInfo[playerid][pCar],PlayerInfo[playerid][pGunLic],PlayerInfo[playerid][pName]);
				mysql_query(query);


				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_Items = '%d' WHERE UserName = '%s'",Menu_Items[playerid],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemName1 = '%s',LsMenu_ItemName2 = '%s',LsMenu_ItemName3 = '%s',LsMenu_ItemName4 = '%s',LsMenu_ItemName5 = '%s' WHERE UserName = '%s'",Menu_ItemName[playerid][1],Menu_ItemName[playerid][2],Menu_ItemName[playerid][3],Menu_ItemName[playerid][4],Menu_ItemName[playerid][5],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemName6 = '%s',LsMenu_ItemName7 = '%s',LsMenu_ItemName8 = '%s',LsMenu_ItemName9 = '%s',LsMenu_ItemName10 = '%s' WHERE UserName = '%s'",Menu_ItemName[playerid][6],Menu_ItemName[playerid][7],Menu_ItemName[playerid][8],Menu_ItemName[playerid][9],Menu_ItemName[playerid][10],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemPrice1 = '%d',LsMenu_ItemPrice2 = '%d',LsMenu_ItemPrice3 = '%d',LsMenu_ItemPrice4 = '%d',LsMenu_ItemPrice5 = '%d' WHERE UserName = '%s'",Menu_ItemPrice[playerid][1],Menu_ItemPrice[playerid][2],Menu_ItemPrice[playerid][3],Menu_ItemPrice[playerid][4],Menu_ItemPrice[playerid][5],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemPrice6 = '%d',LsMenu_ItemPrice7 = '%d',LsMenu_ItemPrice8 = '%d',LsMenu_ItemPrice9 = '%d',LsMenu_ItemPrice10 = '%d' WHERE UserName = '%s'",Menu_ItemPrice[playerid][6],Menu_ItemPrice[playerid][7],Menu_ItemPrice[playerid][8],Menu_ItemPrice[playerid][9],Menu_ItemPrice[playerid][10],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemMinPrice1 = '%d',LsMenu_ItemMinPrice2 = '%d',LsMenu_ItemMinPrice3 = '%d',LsMenu_ItemMinPrice4 = '%d',LsMenu_ItemMinPrice5 = '%d' WHERE UserName = '%s'",Menu_ItemMinPrice[playerid][1],Menu_ItemMinPrice[playerid][2],Menu_ItemMinPrice[playerid][3],Menu_ItemMinPrice[playerid][4],Menu_ItemMinPrice[playerid][5],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemMinPrice6 = '%d',LsMenu_ItemMinPrice7 = '%d',LsMenu_ItemMinPrice8 = '%d',LsMenu_ItemMinPrice9 = '%d',LsMenu_ItemMinPrice10 = '%d' WHERE UserName = '%s'",Menu_ItemMinPrice[playerid][6],Menu_ItemMinPrice[playerid][7],Menu_ItemMinPrice[playerid][8],Menu_ItemMinPrice[playerid][9],Menu_ItemMinPrice[playerid][10],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemMaxPrice1 = '%d',LsMenu_ItemMaxPrice2 = '%d',LsMenu_ItemMaxPrice3 = '%d',LsMenu_ItemMaxPrice4 = '%d',LsMenu_ItemMaxPrice5 = '%d' WHERE UserName = '%s'",Menu_ItemMaxPrice[playerid][1],Menu_ItemMaxPrice[playerid][2],Menu_ItemMaxPrice[playerid][3],Menu_ItemMaxPrice[playerid][4],Menu_ItemMaxPrice[playerid][5],PlayerInfo[playerid][pName]);
				mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET LsMenu_ItemMaxPrice6 = '%d',LsMenu_ItemMaxPrice7 = '%d',LsMenu_ItemMaxPrice8 = '%d',LsMenu_ItemMaxPrice9 = '%d',LsMenu_ItemMaxPrice10 = '%d' WHERE UserName = '%s'",Menu_ItemMaxPrice[playerid][6],Menu_ItemMaxPrice[playerid][7],Menu_ItemMaxPrice[playerid][8],Menu_ItemMaxPrice[playerid][9],Menu_ItemMaxPrice[playerid][10],PlayerInfo[playerid][pName]);
				mysql_query(query);


				}


			mysql_free_result(); //Frees the result


    }

}
HouseData (Saves and Loads fine):
Код:
stock SaveProperty(Houseid)
{
	new query[300];

	switch (CURRENT_GAMEMODE)
	{

		case LOS_SANTOS:
		{
		format(query, sizeof(query), "SELECT * FROM lshousedata WHERE Houseid = '%d'", Houseid);
		mysql_query(query); //Queries the result
		mysql_store_result(); //Store a result because it's a SELECT statement.

		if(mysql_num_rows() == 0) //If the houseid is not found
		{

		if (CREATE_PLAYER_DATABASE == 1)
		{

		format(query, sizeof(query), "INSERT INTO lshousedata (Houseid) VALUES ('%d')",Houseid); //Insert string
		mysql_query(query);

		}else{

		mysql_query("ALTER TABLE lshousedata ADD OwnerName VARCHAR(128) NOT NULL default 'The Bank'");
		mysql_query("ALTER TABLE lshousedata ADD OwnerID INT(11) NOT NULL default -1");
		mysql_query("ALTER TABLE lshousedata ADD RenterName VARCHAR(128) NOT NULL default 'None'");
		mysql_query("ALTER TABLE lshousedata ADD RenterID INT(11) NOT NULL default -1");
		mysql_query("ALTER TABLE lshousedata ADD HouseName VARCHAR(128) NOT NULL default 'House'");
		mysql_query("ALTER TABLE lshousedata ADD Value INT(11) NOT NULL default 200000");
		mysql_query("ALTER TABLE lshousedata ADD Rent INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD ForSale INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Alarm INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Lock INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Money INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Drugs INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Condoms INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Flowers INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Robberies INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Breakins INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD OwnerVisits INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD OtherVisits INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Purchasers INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Rented INT(11) NOT NULL default 0");

		}


		}else{


		format(query, sizeof(query), "UPDATE lshousedata SET OwnerName = '%s' WHERE Houseid = '%d'",HouseData[Houseid][h_OwnerName],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET OwnerID = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_OwnerID],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET RenterName = '%s' WHERE Houseid = '%d'",HouseData[Houseid][h_RenterName],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET RenterID = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_RenterID],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET HouseName = '%s' WHERE Houseid = '%s'",HouseInfo[Houseid][h_HouseIntName],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Value = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Value],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Rent = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Rent],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET ForSale = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_ForSale],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Alarm = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Alarm],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Lock = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Lock],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Money = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Money],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Drugs = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Drugs],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Condoms = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Condoms],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Flowers = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Flowers],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Robberies = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Robberies],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Breakins = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Breakins],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET OwnerVisits = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_OwnerVisits],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET OtherVisits = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_OtherVisits],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Purchasers = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Purchasers],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Rented = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Rented],Houseid);
		mysql_query(query);

		}

		}
playerdata table in SQL database:
Reply
#2

Is there any error logs?
And also i suggest you to add primary key in your table.
Reply
#3

Quote:
Originally Posted by X337
Посмотреть сообщение
Is there any error logs?
And also i suggest you to add primary key in your table.
No errors being produced, the server connects to the database fine when starting up (and will also read data from the playadata table if I manually add a user to it and then try joining the server with that name)

Debug file:
Код:
 [03:14:13] >> mysql_connect( )

[03:14:13] CMySQLHandler::CMySQLHandler() - constructor called.

[03:14:13] CMySQLHandler::CMySQLHandler() - Connecting to "127.0.0.1" | DB: "server" | Username: "root" ...

[03:14:13] CMySQLHandler::Connect() - Connection was successful.

[03:14:13] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[03:14:13] >> mysql_ping( Connection handle: 1 )

[03:14:13] CMySQLHandler::Ping() - Connection is still alive.
Reply
#4

Why the username is 128 long, the max name length in-game is 20
Why is the IP 128 long, the max ipv2 length is 16
Why register and lastlogin are varchars and not int
Why are all the int's so huge.
Why you don't nave a primary key
Why do you save conntime like this? use the return of gettime(), it increases by 1 every 1 second, you can record the time player spent in-game from playerspawn

OnPlayerSpawn
startOfGameplay=gettime();

And then on player disconnect

OnPlayerDisconnect
totalPlaytime+=gettime() - startOfGameplay;

And just add it to the number you already have in the database.
Reply
#5

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
Why the username is 128 long, the max name length in-game is 20
Why is the IP 128 long, the max ipv2 length is 16
Why register and lastlogin are varchars and not int
Why are all the int's so huge.
Why you don't nave a primary key
Why do you save conntime like this? use the return of gettime(), it increases by 1 every 1 second, you can record the time player spent in-game from playerspawn

OnPlayerSpawn
startOfGameplay=gettime();

And then on player disconnect

OnPlayerDisconnect
totalPlaytime+=gettime() - startOfGameplay;

And just add it to the number you already have in the database.
Thanks for the advice but if I cant get the data to save there's no point in me optimizing it. Ive asked around on other help forums and so far nobody seems to know what the problem is, so its starting to look like a dead end unless any genius's on here can come through and be able to see what the problem is
Reply
#6

I haven't looked at the content, only at the picture.

But is pretty expected to not work.

You don't have default values for the field `ConnTime` (notice the default `None`) and so it cannot insert the line.


Either give default value using phpMyAdmin or expend your INSERT INTO query to insert default value to all fields.

I'd suggest to use phpMyAdmin > go to the table > tab "SQL" > press at the bottom "INSERT INTO", it will give you a ready query and just insert in the VALUES () appropriately.

You can also use this tab to test queries by inserting random expecting values.

Try to launch the query
INSERT INTO `playerdata` (`UserName`, `Password`, `IP`, `ConnTime`) VALUES('Ducati', SHA1('password'), '192.168.0.1', 0);

Another thing, I am unsure about the fields with "blank" as default (never tried or read about it), recommend to use 0 instead of blank and/or NULL.

To what I know, 0 is either faster or space efficient than NULL.
Reply
#7

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
I haven't looked at the content, only at the picture.

But is pretty expected to not work.

You don't have default values for the field `ConnTime` (notice the default `None`) and so it cannot insert the line.


Either give default value using phpMyAdmin or expend your INSERT INTO query to insert default value to all fields.

I'd suggest to use phpMyAdmin > go to the table > tab "SQL" > press at the bottom "INSERT INTO", it will give you a ready query and just insert in the VALUES () appropriately.

You can also use this tab to test queries by inserting random expecting values.

Try to launch the query
INSERT INTO `playerdata` (`UserName`, `Password`, `IP`, `ConnTime`) VALUES('Ducati', SHA1('password'), '192.168.0.1', 0);

Another thing, I am unsure about the fields with "blank" as default (never tried or read about it), recommend to use 0 instead of blank and/or NULL.

To what I know, 0 is either faster or space efficient than NULL.
Thank you! Ive managed to get it working now, I set the 'None' fields to 0 which then allowed the query you provided to insert data into the table.

Then I edited the query in the script under the register dialog response from this:
Код:
format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP);
To this: (the format from the query to told me to run in phpmyadmin)
Код:
format(query, sizeof(query), "INSERT INTO `playerdata` (`UserName`, `Password`, `IP`) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP);
(adding the symbols around the field names and table name and now its properly inserting to the table when a player registers)


I am very grateful for your help, i'd been struggling with this for so long!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)