Saving all server vehicles MYSQL
#1

Код:
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.
Reply
#2

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);
		}
}
Reply
#3

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
Reply
#4

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).
Reply
#5

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)
Reply
#6

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.
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

Quote:
Originally Posted by _rAped
Посмотреть сообщение
I call that a noob statement.
Quote:

In need of attention.

Explains it all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)