Saving Systems help (+REP)
#1

Код:
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'SpawnPos', callback: , query: ALTER TABLE `players` ADD `SpawnPos` INT NOT NULL DEFAULT '0';, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'LogUnix', callback: , query: ALTER TABLE `players` ADD `LogUnix` INT NOT NULL DEFAULT '0';, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'HelperReports', callback: , query: ALTER TABLE `players` ADD `HelperReports` INT NOT NULL DEFAULT '0';, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'family', callback: , query: ALTER TABLE `vehicles` ADD `family` INT(2) NOT NULL DEFAULT 0;, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'lockfeature', callback: , query: ALTER TABLE `vehicles` ADD `lockfeature` INT(2) NOT NULL DEFAULT 0;, connectionHandle: 1
I'm getting these errors in my server_log.txt. Any idea what's wrong? Or tell me what to post here so you can see what's wrong please.

Then I'm getting this;
Код:
[11:33:50] SavePlayerCars(1) > Car 0 couldn't open file (ID: 1)
It simply doesn't load players' vehicles - I buy a car, then I relog and my car is listed in my stats as None, but it's still in /myvehs, also as None. I know it's there, it's just bugged and put as id 0. I tried /goincar 0 and it teleported me to 0, 0, 0 coordinates.

My stock SavePlayerCars;
Код:
stock SavePlayerCars(playerid, bool:destroy)
{
	for(new slot = 0; slot < 2; slot++)
	{
		if(PlayerInfo[playerid][pCarID][slot] > 0)
		{
			if(IsValidVehicle(PlayerCars[playerid][slot][c_ID]))
			{
		    	GetVehiclePos(PlayerCars[playerid][slot][c_ID], PlayerCars[playerid][slot][c_LastPos][0], PlayerCars[playerid][slot][c_LastPos][1], PlayerCars[playerid][slot][c_LastPos][2]);
		    	GetVehicleZAngle(PlayerCars[playerid][slot][c_ID], PlayerCars[playerid][slot][c_LastPos][3]);
		    	for(new comp = 0; comp < 14; comp++) PlayerCars[playerid][slot][c_Component][comp] = GetVehicleComponentInSlot(PlayerCars[playerid][slot][c_ID], comp);
		    	PlayerCars[playerid][slot][c_VW] = GetVehicleVirtualWorld(PlayerCars[playerid][slot][c_ID]);
		    	PlayerCars[playerid][slot][c_Trunk] = TrunkInfo[PlayerCars[playerid][slot][c_ID]][cTrunkOpened];
		    	PlayerCars[playerid][slot][c_Gun][0] = TrunkInfo[PlayerCars[playerid][slot][c_ID]][cGun1];
		    	PlayerCars[playerid][slot][c_Gun][1] = TrunkInfo[PlayerCars[playerid][slot][c_ID]][cGun2];
		    	PlayerCars[playerid][slot][c_Pot] = TrunkInfo[PlayerCars[playerid][slot][c_ID]][cPot];
		    	PlayerCars[playerid][slot][c_Crack] = TrunkInfo[PlayerCars[playerid][slot][c_ID]][cCrack];
		    	PlayerCars[playerid][slot][c_Armor] = TrunkInfo[PlayerCars[playerid][slot][c_ID]][cArmor];
			}

			new strFile[48];
			format(strFile, sizeof(strFile), "cars/%d.ini", PlayerInfo[playerid][pCarID][slot]);
			new File:fCar = fopen(strFile, io_write);
			if(!fCar) return printf("SavePlayerCars(%d) > Car %d couldn't open file (ID: %d)", playerid, slot, PlayerInfo[playerid][pCarID][slot]);

			new strData[64];
			format(strData, sizeof(strData), "Model=%d\n", PlayerCars[playerid][slot][c_Model]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "X=%f\n", PlayerCars[playerid][slot][c_ParkPos][0]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "Y=%f\n", PlayerCars[playerid][slot][c_ParkPos][1]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "Z=%f\n", PlayerCars[playerid][slot][c_ParkPos][2]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "A=%f\n", PlayerCars[playerid][slot][c_ParkPos][3]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "LX=%f\n", PlayerCars[playerid][slot][c_LastPos][0]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "LY=%f\n", PlayerCars[playerid][slot][c_LastPos][1]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "LZ=%f\n", PlayerCars[playerid][slot][c_LastPos][2]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "LA=%f\n", PlayerCars[playerid][slot][c_LastPos][3]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "C1=%d\n", PlayerCars[playerid][slot][c_Color][0]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "C2=%d\n", PlayerCars[playerid][slot][c_Color][1]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "PJ=%d\n", PlayerCars[playerid][slot][c_PaintJob]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp0=%d\n", PlayerCars[playerid][slot][c_Component][0]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp1=%d\n", PlayerCars[playerid][slot][c_Component][1]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp2=%d\n", PlayerCars[playerid][slot][c_Component][2]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp3=%d\n", PlayerCars[playerid][slot][c_Component][3]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp4=%d\n", PlayerCars[playerid][slot][c_Component][4]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp5=%d\n", PlayerCars[playerid][slot][c_Component][5]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp6=%d\n", PlayerCars[playerid][slot][c_Component][6]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp7=%d\n", PlayerCars[playerid][slot][c_Component][7]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp8=%d\n", PlayerCars[playerid][slot][c_Component][8]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp9=%d\n", PlayerCars[playerid][slot][c_Component][9]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp10=%d\n", PlayerCars[playerid][slot][c_Component][10]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp11=%d\n", PlayerCars[playerid][slot][c_Component][11]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp12=%d\n", PlayerCars[playerid][slot][c_Component][12]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "comp13=%d\n", PlayerCars[playerid][slot][c_Component][13]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "alarm=%d\n", PlayerCars[playerid][slot][c_Alarm]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "ins=%d\n", PlayerCars[playerid][slot][c_Insurance]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "plate=%s\n", PlayerCars[playerid][slot][c_Plate]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "gps=%d\n", PlayerCars[playerid][slot][c_GPS]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "tow=%d\n", PlayerCars[playerid][slot][c_Tow]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "keys=%d\n", PlayerCars[playerid][slot][c_Keys]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "lock=%d\n", PlayerCars[playerid][slot][c_Lock]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "price=%d\n", PlayerCars[playerid][slot][c_Price]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "virtualworld=%d\n", PlayerCars[playerid][slot][c_VW]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "trunk_opened=%d\n", PlayerCars[playerid][slot][c_Trunk]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "trunk_gun1=%d\n", PlayerCars[playerid][slot][c_Gun][0]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "trunk_gun2=%d\n", PlayerCars[playerid][slot][c_Gun][1]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "trunk_pot=%d\n", PlayerCars[playerid][slot][c_Pot]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "trunk_crack=%d\n", PlayerCars[playerid][slot][c_Crack]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "trunk_armor=%f\n", PlayerCars[playerid][slot][c_Armor]);
			fwrite(fCar, strData);
			format(strData, sizeof(strData), "impounded=%d\n", PlayerCars[playerid][slot][c_Impounded]);
			fwrite(fCar, strData);
			fclose(fCar);

			if(destroy)
			{
				DestroyVehicle(PlayerCars[playerid][slot][c_ID]);
			    PlayerCars[playerid][slot][c_ID] = 0;
			}
		}
	}
	return 1;
}
Please help me as soon as possible.
+REP for the helpers.

~Kevin
Thanks in advance
Reply
#2

I really need help on this.

Anyone?
Reply
#3

You're trying to add the columns again while they are already exist
Reply
#4

Quote:
Originally Posted by jlalt
Посмотреть сообщение
You're trying to add the columns again while they are already exist
So what do I do? Where do I remove them?
Reply
#5

The errors you're getting are associated to a MySQL query. The function above writes to a local file, so please show us the query instead.

What you have to do to get rid of the error is to first check if the columns are created.
Reply
#6

Quote:
Originally Posted by introzen
Посмотреть сообщение
The errors you're getting are associated to a MySQL query. The function above writes to a local file, so please show us the query instead.

What you have to do to get rid of the error is to first check if the columns are created.
Alright, but how? I'm a noob in MySQL. Could you help me out a bit with some steps or so?
Reply
#7

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Alright, but how? I'm a noob in MySQL. Could you help me out a bit with some steps or so?
How exactly are we suppose to help you if you don't show us the query that creates the problem?

Also you could have used all this time doing research and try to figure out where is the problem instead of waiting for answers and doing nothing.
Reply
#8

Do not use MySQL if you are a "noob" on it. Start with learning the basics in side scripts outside your gamemode, then start developing the real gamemode using mysql.
Reply
#9

Yes jlat told it already that should solve your problem.
Without any code. I can merely guess.
Yes, you're creating duplicate columns each time you save a player's vehicle. This is wrong.
If the player has already purchased the vehicle and does some modification or changes in it, use UPDATE statement. Or if there's new entry in the table. that is - a player which has no vehicle purchased a vehicle, use INSERT INTO.
Reply
#10

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
How exactly are we suppose to help you if you don't show us the query that creates the problem?

Also you could have used all this time doing research and try to figure out where is the problem instead of waiting for answers and doing nothing.
That's what I'm talking about. I'm asking if you could tell me where so I can do it and how to do it, but I get answers like this and you're accusing me of not doing anything. Try to put yourself in my skin. I don't know shit, you're an expert, telling me what to do and how noobish I am, do you think I get you?

Quote:
Originally Posted by introzen
Посмотреть сообщение
Do not use MySQL if you are a "noob" on it. Start with learning the basics in side scripts outside your gamemode, then start developing the real gamemode using mysql.
I have not created the gamemode. I have gotten it myself and developed on it, but I barely used MySQL so I didn't study it.

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
Yes jlat told it already that should solve your problem.
Without any code. I can merely guess.
Yes, you're creating duplicate columns each time you save a player's vehicle. This is wrong.
If the player has already purchased the vehicle and does some modification or changes in it, use UPDATE statement. Or if there's new entry in the table. that is - a player which has no vehicle purchased a vehicle, use INSERT INTO.
I don't mean to sound rude, but, could you please read the above replies? I don't get you guys, you keep posting same shit after I told two times at least if you can give me steps, WHERE, WHAT and HOW do I insert these things and WHERE can I check for these COLUMNS. As I said, I have no idea about it at all.
Reply
#11

Okay, okay. Calm listen, can you show us the query? In which you save the data for car?
Reply
#12

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
Okay, okay. Calm listen, can you show us the query? In which you save the data for car?
You mean on the MySQL database or where bud, can you explain?
Reply
#13

The problem is that we do not know at all what lines you have in your gamemode. If you do not know that yourself, create a new gamemode from scratch.

You need to post the MySQL query in order for us to give you the correct code.
Reply
#14

Okay, look. You wrote the queries for mysql to save data?

Inside the pawn script? Can I have a look at them please.
If you're still not sure search for relevant terms maybe.

"mysql_query" etc.
Reply
#15

Of course you can, but tell me what do I paste here, mysql_query from where bud?
Reply
#16

The query which executes when ever a player buys a car.

Or according to your car saving system.
Reply
#17

Oh wait, listen. Go to phpmyadmin open the database in the table "players" you must have columns which repeat themself.

My bad. I read the reply and got confused. I read the whole thread again. It's actually not related to car issues or any query.

Edit -
sorry for double post. Moreover this is what I'm talking about.

Code:
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'SpawnPos', callback: , query: ALTER TABLE `players` ADD `SpawnPos` INT NOT NULL DEFAULT '0';, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'LogUnix', callback: , query: ALTER TABLE `players` ADD `LogUnix` INT NOT NULL DEFAULT '0';, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'HelperReports', callback: , query: ALTER TABLE `players` ADD `HelperReports` INT NOT NULL DEFAULT '0';, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'family', callback: , query: ALTER TABLE `vehicles` ADD `family` INT(2) NOT NULL DEFAULT 0;, connectionHandle: 1
[15:17:55] OnQueryError: errorid: 1060, error: Duplicate column name 'lockfeature', callback: , query: ALTER TABLE `vehicles` ADD `lockfeature` INT(2) NOT NULL DEFAULT 0;, connectionHandle: 1
Reply
#18

I can't fucking connect to the phpMyAdmin, but I can show you the .sql, because the host is fucked and they're fixing some errors.
Reply
#19

Aww. I'm on phone I'm afraid I can't open the .SQL now.
Reply
#20

Ohh alright, my friend has helped me. Wait for me to reply please for a bit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)