No coordinates are saved
#1

Attempt to save the coordinates when get off the car. Are saved but when I restart the server the cars appear disorderly, where is the error?

Sorry for my English


Код:
OnPlayerExitVehicle(playerid,vehicleid)
{
  new idcoche;
  idcoche = GetPlayerVehicle (playerid);
  new Float:x,Float:y,Float:z, Float:angulo;
  GetVehiclePos(idcoche, x, y, z);
  GetVehicleZAngle(idcoche, angulo);
  CarInfo[idcoche][cLocationx]=x;
  CarInfo[idcoche][cLocationy]=y;
  CarInfo[idcoche][cLocationz]=z;
  CarInfo[idcoche][cAngle] = angulo;					
  GuardarCoordenadasCoche(idcoche);
}
GuardarCoordenadasCoche(idx)
{
	//new tmp[128];
	
    new sql[2048];
	format(sql, sizeof(sql), "UPDATE cars SET X=%f,Y=%f,Z=%f,A=%f WHERE `id`=%d",
        CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cSQLID]);
	mysql_query(sql);
	return 1;
}
Reply
#2

Lool man use ****** translate!
If i get you right than:
You are trying to save vehicle coordinates so you can load them after restart
With that code you just get vehicle coordinates and store them to variable but you dont save them
To save them you need to use DINI or DJSON or MYSQL or some other ini file system
Reply
#3

Sorry, I've used ****** translate but it seems sometimes needs correction XD
Look at the post, just edit it to add the function that saves the variables in the database ^ ^ I forgot to put it!
Reply
#4

Nobody knows where is the problem?
Reply
#5

use 'vehicleid' instead of 'idcoche'.
Reply
#6

try:

pawn Код:
public OnPlayerExitVehicle(playerid,vehicleid)
{
    new sql[2048];
    new Float:x,Float:y,Float:z, Float:angulo;
    GetVehiclePos(vehicleid, x, y, z);
    GetVehicleZAngle(vehicleid, angulo);
    CarInfo[vehicleid][cLocationx] = x;
    CarInfo[vehicleid][cLocationy] = y;
    CarInfo[vehicleid][cLocationz] = z;
    CarInfo[vehicleid][cAngle] = angulo;                   

 
    format(sql, sizeof(sql), "UPDATE cars SET X=%f,Y=%f,Z=%f,A=%f WHERE `id`=%d", x, y, z, angulo, CarInfo[vehicleid][cSQLID]);
    mysql_query(sql);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)