Get id of the vehicle to save position (MySQL)
#1

- I have three vehicle loaded with MySQL:


Image in-game: http://i.imgur.com/SsF02KC.jpg


- And I go to one of the vehicles, (for example NRG) and use the command to save the position
Image in-game: http://i.imgur.com/9VqjHEa.jpg


- When I restart the server, the vehicles are in the same position
Image in-game: http://i.imgur.com/uQkfjud.jpg



The command:

Код:
CMD:aparcaradmin(playerid, params[])
{
    new vehicleid;
    
    if(IsPlayerInAnyVehicle(playerid)) vehicleid = GetPlayerVehicleID(playerid);
    else vehicleid = JugadorCercaVehiculo(playerid);

	new Float:Pos[4];
    GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
    GetVehicleZAngle(vehicleid, Pos[3]);

	Vehiculo[vehicleid][vX] = Pos[0]; Vehiculo[vehicleid][vY] = Pos[1]; Vehiculo[vehicleid][vZ] = Pos[2]; Vehiculo[vehicleid][vA] = Pos[3];
  	
  	new query[128];
	format(query, 128, "UPDATE `vehiculos` SET `PosVehX` = %f, `PosVehY` = %f, `PosVehZ` = %f, `PosVehA` = %f WHERE `IDveh` = %d", Vehiculo[vehicleid][vX], Vehiculo[vehicleid][vY], Vehiculo[vehicleid][vZ], Vehiculo[vehicleid][vA], vehicleid);
	mysql_query(mysql, query);
}
Thanks.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)