I need a function for saving vehicles (MySQL)
#1

Hello,

I have a command that creates vehicles, works perfectly and saves it to the database but now I need a function to load the vehicle when the server starts

Variables:

Код:
enum Vehiculos
{
	IDveh, // ID
	Modelo, // Model
	Float:PosVehX, // Position X
	Float:PosVehY, // Position Y
	Float:PosVehZ, // Position Z
	Color1,
	Color2,
	TiempoRespawn, // Respawn time
	Sirena // Siren
};
new Vehiculo[MAX_VEHICLES][Vehiculos];
Command to create vehicles:

Код:
CMD:crearcoche(playerid, params[]) // Administrador
{
		new modelo, color1, color2;
	    new Float:pos[3];
		GetPlayerPos(playerid, pos[0], pos[1], pos[2]);

		new VehiculoCreado = CreateVehicle(modelo, pos[0], pos[1]+5, pos[2], color1, color2, 30000, 0);

		new query[512];
		format(query, 512, "INSERT INTO vehiculos (Modelo, PosVehX, PosVehY, PosVehZ, Color1, Color2, TiempoRespawn) VALUES (%d, %f, %f, %f, %d, %d, 30000)", modelo, pos[0], pos[1], pos[2], color1, color2);
		mysql_tquery(mysql, query, "", "");

		Vehiculo[VehiculoCreado][IDveh] = cache_insert_id();
		Vehiculo[VehiculoCreado][Modelo] = modelo;
		Vehiculo[VehiculoCreado][PosVehX] = pos[0];
		Vehiculo[VehiculoCreado][PosVehY] = pos[1];
	 	Vehiculo[VehiculoCreado][PosVehZ] = pos[2];
		Vehiculo[VehiculoCreado][Color1] = color1;
		Vehiculo[VehiculoCreado][Color2] = color2;
		return 1;
 }
I think it is a while loop and AddStaticVehicle function but not sure and do not know how I can do it. Sorry for bad English.

Thanks!
Reply
#2

For Example - http://pastebin.com/mVQcJSjZ
Reply
#3

Edit: I was confused, it's all good and it worked. Thank you so much days!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)