SA-MP Forums Archive
No coordinates are saved - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: No coordinates are saved (/showthread.php?tid=255533)



No coordinates are saved - Narxon - 16.05.2011

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;
}



Re: No coordinates are saved - DRIFT_HUNTER - 16.05.2011

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


Respuesta: No coordinates are saved - Narxon - 16.05.2011

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!


Respuesta: No coordinates are saved - Narxon - 16.05.2011

Nobody knows where is the problem?


Re: No coordinates are saved - xDeadlyBoy - 16.05.2011

use 'vehicleid' instead of 'idcoche'.


Re: No coordinates are saved - NRJ53 - 16.05.2011

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);
}