I need a function for saving vehicles (MySQL) - 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: I need a function for saving vehicles (MySQL) (
/showthread.php?tid=594028)
I need a function for load vehicles (MySQL) -
Joake6 - 12.11.2015
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!
Re: I need a function for saving vehicles (MySQL) -
7days7 - 12.11.2015
For Example -
http://pastebin.com/mVQcJSjZ
Re: I need a function for saving vehicles (MySQL) -
Joake6 - 12.11.2015
Edit: I was confused, it's all good and it worked. Thank you so much days!