SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/04/2016, 07:05 PM   #1
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 567
Reputation: 71
Default Saving Systems help (+REP)

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
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;
Code:
[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;
Code:
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
iKevin is offline   Reply With Quote
Old 17/04/2016, 08:26 PM   #2
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 567
Reputation: 71
Default

I really need help on this.

Anyone?

Last edited by dugi; 18/04/2016 at 04:40 PM.
iKevin is offline   Reply With Quote
Old 18/04/2016, 06:00 AM   #3
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,278
Reputation: 366
Default Re: Saving Systems help (+REP)

You're trying to add the columns again while they are already exist
jlalt is offline   Reply With Quote
Old 18/04/2016, 11:53 AM   #4
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 567
Reputation: 71
Default Re: Saving Systems help (+REP)

Quote:
Originally Posted by jlalt View Post
You're trying to add the columns again while they are already exist
So what do I do? Where do I remove them?
iKevin is offline   Reply With Quote
Old 18/04/2016, 12:01 PM   #5
introzen
Gangsta
 
introzen's Avatar
 
Join Date: Aug 2008
Posts: 789
Reputation: 34
Default Re: Saving Systems help (+REP)

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.
__________________
"No problem can be solved from the same level of consciousness that created it." - Albert Einstein
introzen is offline   Reply With Quote
Old 19/04/2016, 02:14 PM   #6
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 567
Reputation: 71
Default Re: Saving Systems help (+REP)

Quote:
Originally Posted by introzen View Post
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?
iKevin is offline   Reply With Quote
Old 19/04/2016, 03:31 PM   #7
DarkLored
High-roller
 
DarkLored's Avatar
 
Join Date: Oct 2013
Location: U.S. New York
Posts: 1,047
Reputation: 61
Default Re: Saving Systems help (+REP)

Quote:
Originally Posted by KevinExec View Post
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.
__________________
deviantArt

Taking my time on focusing on Education and learning how to draw.

Quote:
Originally Posted by KevinExec View Post
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?

P.S.: I offer .ini scripting services.

- Quoted by not other than KevinExec, the "master" of PAWN language
Quote:
Originally Posted by iMTube™ View Post
don't act OP coz u will never be Op
Rest in Pieces iMTube™, you won't be missed coz you are Op
DarkLored is offline   Reply With Quote
Old 19/04/2016, 04:03 PM   #8
introzen
Gangsta
 
introzen's Avatar
 
Join Date: Aug 2008
Posts: 789
Reputation: 34
Default Re: Saving Systems help (+REP)

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.
__________________
"No problem can be solved from the same level of consciousness that created it." - Albert Einstein
introzen is offline   Reply With Quote
Old 19/04/2016, 04:40 PM   #9
Ritzy2K
High-roller
 
Ritzy2K's Avatar
 
Join Date: Jun 2014
Location: India
Posts: 1,552
Reputation: 170
Default Re: Saving Systems help (+REP)

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.
__________________
Ritzy2K is offline   Reply With Quote
Old 19/04/2016, 05:21 PM   #10
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 567
Reputation: 71
Default Re: Saving Systems help (+REP)

Quote:
Originally Posted by DarkLored View Post
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 View Post
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. View Post
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.
iKevin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is it possible to run two saving systems at the same time tboysamp Scripting Help 3 03/05/2015 02:58 AM
Saving Systems JaKe Elite Everything and Nothing 12 25/10/2014 03:48 PM
Data Saving Systems Ryan_Obeles Scripting Help 14 21/04/2013 04:54 AM
[Tutorial] Optimising saving systems Misiur Tutorials 1 26/02/2013 04:21 PM
using multiple saving systems milanosie Scripting Help 9 18/02/2012 01:18 PM


All times are GMT. The time now is 01:38 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.