Saving all server vehicles MYSQL -
NewbBeginner - 09.01.2011
Код:
public OnGameModeExit()
{
for(new ServerVehicles; ServerVehicles < MAX_VEHICLES; ServerVehicles++)
{
new Float:PosnX;
new Float:PosY;
new Float:PosZ;
new Float:aAngle;
new aModel;
aModel = GetVehicleModel(GetPlayerVehicleID(ServerVehicles));
GetVehiclePos(ServerVehicles, PositsioonX, PositsioonY, PositsioonZ);
GetVehicleZAngle(GetPlayerVehicleID(ServerVehicles), aAngle);
format(Query, sizeof(Query), "UPDATE `cars` SET `PosX` = '%f', `PosY` = '%f', `PosZ` = '%f', `AutoAngle` = '%f' WHERE `CarID` = '%d'",
PosX,
PosY,
PosnZ,
aAngle,
aAngle,
aModel);
mysql_query(Query);
}
mysql_close();
return 1;
}
I have this code, and if I do GMX, then it is on it's old page, like I saved it into database.
Please help.
Re: Saving all server vehicles MYSQL -
NewbBeginner - 11.01.2011
I figured something out, I have now this code, but it doesn't update.
Код:
stock savecars()
{
for(new id; id < cars; id++)
{
new Float:pposX, Float:pposY, Float:pposZ,Float:AutoAngle;
GetVehiclePos(id, pposX, pposY, pposZ);
GetVehicleZAngle(id, AutoAngle);
format(Query, sizeof(Query), "UPDATE `cars` SET `PosX` = '%f', `PosY` = '%f', `PosZ` = '%f', `AutoAngle` = '%f' WHERE `carid` = '%d'",
pposX,
pposY,
pposZ,
AutoAngle,
id);
mysql_query(Query);
}
}
Re: Saving all server vehicles MYSQL -
JaTochNietDan - 11.01.2011
It's a strange way of using MySQL, and it's probably not going to work, there's simply far too many queries you'll need to execute in order to save all of that information. The server would probably crash before it gets anywhere near updating all of those rows.
You should re-think your way of saving all of the vehicles, possibly by a file system, because this is madness
Re: Saving all server vehicles MYSQL -
Sergei - 11.01.2011
1. Save vehicles before closing server.
2. Use threads.
3. Don't write in noob SQL language (e.g. puting '' for every possible values, etc).
Re: Saving all server vehicles MYSQL -
Scenario - 11.01.2011
Quote:
Originally Posted by Sergei
3. Don't write in noob SQL language (e.g. puting '' for every possible values, etc).
|
What do you mean "
putting " for every possible value"? Do you mean adding `'s around each variable place holder? (%s, %d, %f)
Re: Saving all server vehicles MYSQL -
Sergei - 11.01.2011
Quote:
Originally Posted by RealCop228
What do you mean "putting " for every possible value"? Do you mean adding `'s around each variable place holder? (%s, %d, %f)
|
' is not " and not `. ' is to be put around string values. I find it stupid when people ask basic questions about SQL and they have hundreas of ` and ' symbols in their query. I call that noob SQL language.
Re: Saving all server vehicles MYSQL -
_rAped - 11.01.2011
Quote:
Originally Posted by Sergei
' is not " and not `. ' is to be put around string values. I find it stupid when people ask basic questions about SQL and they have hundreas of ` and ' symbols in their query. I call that noob SQL language.
|
I call that a noob statement.
Re: Saving all server vehicles MYSQL -
DVDK - 11.01.2011
Quote:
Originally Posted by JaTochNietDan
It's a strange way of using MySQL, and it's probably not going to work, there's simply far too many queries you'll need to execute in order to save all of that information. The server would probably crash before it gets anywhere near updating all of those rows.
You should re-think your way of saving all of the vehicles, possibly by a file system, because this is madness
|
Nothing wrong with that, i had a house system with about 100 houses in a loop, and in every loop it had about 3 to 5 querys.
Re: Saving all server vehicles MYSQL -
NewbBeginner - 11.01.2011
Quote:
Originally Posted by DVDK
Nothing wrong with that, i had a house system with about 100 houses in a loop, and in every loop it had about 3 to 5 querys.
|
But I have something wrong with my code ? It just doesn't save.
Re: Saving all server vehicles MYSQL -
Sergei - 11.01.2011
Quote:
Originally Posted by _rAped
I call that a noob statement.
|
Explains it all.