SA-MP Forums Archive
SaveVehicle - Crashes the server - 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: SaveVehicle - Crashes the server (/showthread.php?tid=445811)



SaveVehicle - Crashes the server - Slaykler - 23.06.2013

Simples the title says it all.

When it does this function server goes bye bye!!!!

Код:
FUNCTION:SaveVehicleChecker(vehid)
{
    new Float:PosX, Float:PosY, Float:PosZ, Float:Angle, Model;
	GetVehiclePos(vehid,PosX,PosY,PosZ);
	GetVehicleZAngle(vehid, Angle);
	Model = GetVehicleModel(vehid);
	
	new mainstring[256];
    new rows, fields;
    cache_get_data(rows, fields);
    if(rows)
    {
		mysql_format(dbHandle, mainstring,sizeof(mainstring),"UPDATE `vehicles` SET Model=%d,PosX=%f,PosY=%f,PosZ=%f,Angle=%f,World=%d,Interior=%d,Color1=%d,Color2=%d,Faction=%d WHERE ID = '%d'",Model,PosX,PosY,PosZ,Angle,VehicleInfo[vehid][cWorld],VehicleInfo[vehid][cInterior],VehicleInfo[vehid][cColor1],VehicleInfo[vehid][cColor2],VehicleInfo[vehid][cFaction],vehid);
	    mysql_tquery(dbHandle, mainstring, "", ""); 
	}
	else
	{
	    mysql_format(dbHandle, mainstring,sizeof(mainstring),"INSERT INTO `vehicles` (id,Model,PosX,PosY,PosZ,Angle) VALUES (%d,%d,'%f','%f','%f','%f')",
		vehid,Model,PosX,PosY,PosZ,Angle);
	    mysql_tquery(dbHandle, mainstring, "", ""); 
	}
	VehicleInfo[vehid][cPosX] = PosX;
	VehicleInfo[vehid][cPosY] = PosY;
	VehicleInfo[vehid][cPosZ] = PosZ;
	VehicleInfo[vehid][cAngle] = Angle;
	return 1;
}

FUNCTION:SaveVehicle(vehid)
{
	new mainstring[256];
    mysql_format(dbHandle, mainstring,sizeof(mainstring),"SELECT * FROM `vehicles` WHERE ID = %d",vehid);
    mysql_tquery(dbHandle, mainstring, "SaveVehicleChecker", "d", vehid);
	return 1;
}