SA-MP Forums Archive
Car load problem - 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: Car load problem (/showthread.php?tid=533717)



Car load problem - Porgand - 26.08.2014

Hi there
I've been having a big problem of loading player car.

Код:
funktsioon LoadCar(z)
{
    new result[128], sql[256];
	format(sql, sizeof(sql), "SELECT * FROM `cars` WHERE `CarId` = '%d'", z);
	mysql_query(sql);
	mysql_store_result();
	if(mysql_fetch_row_format(sql,"|"))
	{
		mysql_fetch_field_row(result,"Owned"); CarInfo[z][cOwned] = strval(result);
		mysql_fetch_field_row(result,"Owner"); CarInfo[z][cOwner] = strval(result);
		mysql_fetch_field_row(result,"Description"); strmid(CarInfo[z][cDescription], result, 0, strlen(result), 255);//
		mysql_fetch_field_row(result,"Model"); CarInfo[z][cModel] = strval(result);
		mysql_fetch_field_row(result,"Value"); CarInfo[z][cValue] = strval(result);
		mysql_fetch_field_row(result,"Lock"); CarInfo[z][cLock] = strval(result);
		mysql_fetch_field_row(result,"Locationx"); CarInfo[z][cLocationx] = floatstr(result);
		mysql_fetch_field_row(result,"Locationy"); CarInfo[z][cLocationy] = floatstr(result);
		mysql_fetch_field_row(result,"Locationz"); CarInfo[z][cLocationz] = floatstr(result);
		mysql_fetch_field_row(result,"Angle"); CarInfo[z][cAngle] = floatstr(result);
		mysql_fetch_field_row(result,"Parked"); CarInfo[z][cParked] = strval(result);
		mysql_fetch_field_row(result,"ParkLocationx"); CarInfo[z][cParkLocationx] = floatstr(result);
		mysql_fetch_field_row(result,"ParkLocationy"); CarInfo[z][cParkLocationy] = floatstr(result);
		mysql_fetch_field_row(result,"ParkLocationz"); CarInfo[z][cParkLocationz] = floatstr(result);
		mysql_fetch_field_row(result,"ParkAngle"); CarInfo[z][cParkAngle] = floatstr(result);
		mysql_fetch_field_row(result,"Cocain"); CarInfo[z][cCocain] = strval(result);
		mysql_fetch_field_row(result,"AMaterjale"); CarInfo[z][cMaterjale][0] = strval(result);
		mysql_fetch_field_row(result,"BMaterjale"); CarInfo[z][cMaterjale][1] = strval(result);
		mysql_fetch_field_row(result,"CMaterjale"); CarInfo[z][cMaterjale][2] = strval(result);
		mysql_fetch_field_row(result,"Nitro"); CarInfo[z][cNitro] = strval(result);
		mysql_fetch_field_row(result,"Odometer"); CarInfo[z][cOdometer] = strval(result);
		mysql_fetch_field_row(result,"GPS"); CarInfo[z][cGPS] = strval(result);
		mysql_fetch_field_row(result,"Radio"); CarInfo[z][cRadio] = strval(result);
		mysql_fetch_field_row(result,"Comp1"); CarInfo[z][cComp1] = strval(result);
		mysql_fetch_field_row(result,"Comp2"); CarInfo[z][cComp2] = strval(result);
		mysql_fetch_field_row(result,"Comp3"); CarInfo[z][cComp3] = strval(result);
		mysql_fetch_field_row(result,"Comp4"); CarInfo[z][cComp4] = strval(result);
		mysql_fetch_field_row(result,"Comp5"); CarInfo[z][cComp5] = strval(result);
		mysql_fetch_field_row(result,"Comp6"); CarInfo[z][cComp6] = strval(result);
		mysql_fetch_field_row(result,"Comp7"); CarInfo[z][cComp7] = strval(result);
		mysql_fetch_field_row(result,"Comp8"); CarInfo[z][cComp8] = strval(result);
		mysql_fetch_field_row(result,"Comp9"); CarInfo[z][cComp9] = strval(result);
		mysql_fetch_field_row(result,"Comp10"); CarInfo[z][cComp10] = strval(result);
		mysql_fetch_field_row(result,"Color1"); CarInfo[z][cColor1] = strval(result);
		mysql_fetch_field_row(result,"Color2"); CarInfo[z][cColor2] = strval(result);
		mysql_fetch_field_row(result,"Stock"); CarInfo[z][cStock] = strval(result);
		mysql_fetch_field_row(result,"CarKeyGiven"); CarInfo[z][cCarKeyGiven] = strval(result);
		//mysql_fetch_field_row(result,"Number"); CarInfo[z][cRegistration] = result;

		Car[z] = AddStaticVehicleEx(CarInfo[z][cModel],CarInfo[z][cLocationx],CarInfo[z][cLocationy],CarInfo[z][cLocationz]+0.1, CarInfo[z][cAngle],CarInfo[z][cColor1],CarInfo[z][cColor2],60000);
		OnCarUpdate(z);
	}
	mysql_free_result();
}
But now that the loaded car and trying to drive a person to run the server says that it is not your car. But by doing restart the server loads the data correctly.

Example:
Buy car
Enter vehicle
type /engine
server says: "That's not your car."
Logout
I open the panel and do restart the server
login to server
Enter vehicle
type /engine
the engine start

There is some kind of MySQL error, or something else?


Re: Car load problem - Aerotactics - 26.08.2014

That can also happen outside of MySQL, What you want to do is set spawn variables for the car into their MySQL file, then, load the car from MySQL. Currently, you're giving them an empty car, instead of their saved car.