SA-MP Forums Archive
Vehicle Saving - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle Saving (/showthread.php?tid=586914)



Vehicle Saving - Zonoya - 26.08.2015

Right... Back again.

I have a vehicle system that works perfectly for the most part, vehicle creation and everything is fine, and it always works without issue, it fills in any missing ID's on the Mysql database to make it 'neater' and easier to work with for tunings and such when I get around to it, but then, this was coded in:

Код:
SavePlayerVehicles(playerid)
{
	new index = 0;
	for(new i = 0; i < MAX_VEHICLES; i++)
	{
	    if(vCreated[vInfo[i][vID])
	    {
			if(vInfo[i][vOwnerID] == pInfo[playerid][ID])
			{
				mysql_format(mysql, query, sizeof(query), "UPDATE `vehdata` SET `vX`=%f, `vY`=%f, `vZ`=%f, `vA`=%f, `vCol1`=%d, `vCol2`=%d WHERE \
				`vID`=%d", vInfo[i][vLoc][0], vInfo[i][vLoc][1], vInfo[i][vLoc][2], vInfo[i][vLoc][3], vInfo[i][vCol1], vInfo[i][vCol2], \
				vInfo[i][vID]);

				mysql_tquery(mysql, query);
				printf("Vehicle ID %d (%d) saved and unloaded!", vInfo[i][vID], i);
				DestroyVehicle(vInfo[i][vCarID]);
				vCreated[vInfo[i][vID] = false;
				index ++;
			}
		}
	}
	printf("%d", index);
}
Pardon any looks of bad indentation on there, that's just because I copy-pasted it in, it's indented fine in the editor.

The issue I'm having, is that it will save and unload every vehicle, except the first vehicle on the server, it never saves that one. I cannot figure out why, I'm doing everything right, since I'm testing with 3-10 vehicles all made in the same way, vehicle ID 2 through 10 are saved and destroyed when I log out since I own them, but vehicle ID 1 is never touched, and I can't figure out why.

Any help would be appreciated, thanks.


Re: Vehicle Saving - BKarner - 26.08.2015

Best thing to do, is to check out if the checks are being made. For example. Inside of where it's saving.. Debug what the "i" value is; see if it's going through the code correctly.


Re: Vehicle Saving - Zonoya - 26.08.2015

I fixed it in the end, it just doesn't like car ID 1 in the server for some odd reason, I just reasoned that because it's for owned cars, it'll never have to unload ID 1, since cars the server makes are going to be around that ID range, so... Fixed.