Save vehicles in DB
#1

Hello.

I spawn on my server full of vehicles, and I save them in DB (not / save).

So I have a FS where I included mysql, connected to the DB, .. and I have this command:

Code:
if (strcmp("/vdebug", cmdtext, true, 10) == 0)
	{
		SendClientMessageToAll(ERROR, "Start save");
		new Float:x, Float:y, Float:z, Float:angle, query[400];
		new compteur_add = 0;
		new compteur_update = 0;
		for(new i = 0; i < MAX_VEHICLES; i++) {
		    GetVehiclePos(i, x, y, z);
		    if(x > 10 && y > 10) {
				format(query, 400, "SELECT * FROM `ab_vehicles` WHERE id_ingame = %d", i);
				mysql_query(query);
				mysql_store_result();
				if(mysql_num_rows() == 1) {
				    compteur_update++;
				    format(query, 400, "UPDATE `ab_vehicles` SET spawn_x = %f, spawn_y = %f, spawn_z = %f, spawn_angle = %f WHERE id_ingame = %d", x, y, z, angle, i);
				    mysql_query(query);
				} else {
				    compteur_add++;
				    format(query, 400, "INSERT INTO `ab_vehicles`(id_ingame, modele, prix, etat, spawn_x, spawn_y, spawn_z, spawn_angle, plaque) VALUES(%d, %d, 9999, 0, %f, %f, %f, %f, \"[USA] BETA TEST\")", i, GetVehicleModel(i), x, y, z, angle);
					mysql_query(query);
				}
				mysql_free_result();
		    }
		}
		SendClientMessageToAll(ERROR, "End save");
		new result[100];
		format(result, 100, "Vehicles insered: %d ; Vйhicles updated: %d", compteur_add, compteur_update);
		SendClientMessageToAll(ERROR, result);
		return 1;
	}
I am a first time / vdebug, the backup was instant, I marked "inserted 5 vehicles." The second was longer, and I had the same result. But nothing in the DB.

I use
if (x> 10 & & y> 10)
to ensure that the vehicle exists.

In short, how to run this script?

mysql_debug is one and I have no error in the. ... exe

Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)