06.01.2019, 20:09
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;
}
PHP Code:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
loadvehs(vehicleid);
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
savevehs(vehicleid);
return 1;
}
--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;
}
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