doesn't save 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: doesn't save vehicles mysql (
/showthread.php?tid=662615)
doesn't save vehicles mysql -
Kevinas100 - 06.01.2019
PHP Code:
stock loadvehs(vehicleid)
{
new
Query[ 500 ],
Float:mPos[3];
format(Query,sizeof(Query), "SELECT `ID` FROM `masinos` WHERE `ID` = '%i'", GetVehicleID(vehicleid));
mysql_query(Query);
if(mysql_num_rows() > 0)
{
format(Query,sizeof(Query), "INSERT INTO `masinos` (masinosid) VALUES ('%s')", GetVehicleName(vehicleid));
mysql_query(Query);
}
else
{
new result[200];
format(Query,sizeof(Query), "SELECT * FROM `masinos` WHERE `ID` = '%s'", GetVehicleID(vehicleid));
mysql_query(Query);
mysql_store_result();
mysql_retrieve_row();
mysql_fetch_field_row(result, "mxPos");
mPos[ 0 ] = floatstr(result);
mysql_fetch_field_row(result, "myPos");
mPos[ 1 ] = floatstr(result);
mysql_fetch_field_row(result, "mzPos");
mPos[ 2 ] = floatstr(result);
SetVehiclePos(vehicleid, mPos[0], mPos[1], mPos[2]);
mysql_fetch_field_row(result, "degalai");
masina.degalai[vehicleid] = strval(result);
mysql_fetch_field_row(result, "rida");
masina.rida[vehicleid] = floatstr(result);
}
return 1;
}
stock savevehs(vehicleid)
{
new Query[ 500 ], Float:mPos[ 3 ];
GetVehiclePos(vehicleid, mPos[0], mPos[1], mPos[2]);
format(Query,sizeof(Query), "UPDATE `masinos` SET \
\
mxPos = %f, \
myPos = %f, \
mzPos = %f, \
degalai = %.1f, \
rida = %.1f, \
WHERE `ID` = '%s'",
mPos[ 0 ],
mPos[ 1 ],
mPos[ 2 ],
masina.degalai[vehicleid],
masina.rida[vehicleid],
GetVehicleID(vehicleid));
mysql_query(Query);
return 1;
}
there are my save functions
PHP Code:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
loadvehs(vehicleid);
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
savevehs(vehicleid);
return 1;
}
I put them here, mysql debug doesn't give an error or anything, i don't get it
--EDIT--
I made getvehicleid to
PHP Code:
stock GetVehicleID(vehicleid)
{
new Query[ 500 ];
format(Query,sizeof(Query), "SELECT `masinosid` FROM `masinos` WHERE `masinosid` = '%s'", GetVehicleName(vehicleid));
return 1;
}
now it gives
CMySQLHandler::Query(INSERT INTO `masinos` (masinosid) VALUES ('Sentinel')) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
this error
Re: doesn't save vehicles mysql -
saffierr - 06.01.2019
Check your savevehs(); function.
You save
PHP Code:
GetVehicleID(vehicleid);
as a string, use