MySQL Player Vehicles.
#1

Hi all, i am doing a script which load player vehicles when he/she logs in.
But I've a problem, it doesn't work... This is the script for loading vehicles at server start.
Код:
stock initiatePVehicleSpawns() {
	new sql[164],row[255],result[1024],bool: success = true;
	format(sql, sizeof(sql), "SELECT COUNT(*) FROM playervehicles");
	mysql_query(sql);
	mysql_store_result();
	mysql_fetch_row(row);
	totalcars = strvalEx(row);
	mysql_free_result();
    for (new i=0; i<=totalcars; i++)
	{
	                format(sql, sizeof(sql), "SELECT * FROM playervehicles WHERE ID = %d", i);
    				mysql_query(sql);

				    mysql_get_field("vOwner", pVehicleInfo[i][vOwner]);

					mysql_get_field("vModel", result);
					pVehicleInfo[i][vModel] = strval(result);

					mysql_get_field("vX", result);
					pVehicleInfo[i][vVehiclePosition][0] = floatstr(result);

					mysql_get_field("vY", result);
					pVehicleInfo[i][vVehiclePosition][1] = floatstr(result);

					mysql_get_field("vZ", result);
					pVehicleInfo[i][vVehiclePosition][2] = floatstr(result);

					mysql_get_field("vA", result);
					pVehicleInfo[i][vVehicleRotation] = floatstr(result);

					mysql_get_field("vColor1", result);
					pVehicleInfo[i][vColor][0] = strval(result);

					mysql_get_field("vColor2", result);
					pVehicleInfo[i][vColor][1] = strval(result);

					mysql_get_field("vPaintjob", result);
					pVehicleInfo[i][vPaintjob] = strval(result);

					vPuzz[i] = 1;

					systemVariables[vehicleCounts][0]++;
				}
    if(success) printf("[script] %d vehicles loaded.", systemVariables[vehicleCounts][0]);
	mysql_free_result();
	}
And this is the code for loading player vehicles when he logs.
Код:
forward LoadPlayerVehicles(playerid);
public LoadPlayerVehicles(playerid){
GetPlayerName(playerid, pname, sizeof (pname));
new sql[256],row[253];
format(sql, sizeof(sql), "SELECT COUNT(*) FROM playervehicles");
mysql_query(sql);
mysql_store_result();
mysql_fetch_row(row);
totalcars = strvalEx(row);
mysql_free_result();
for (new i=0; i<=totalcars; i++)
	{
 	if(!strcmp(pVehicleInfo[i][vOwner],pname)) print("I recognised a player vehicle"); //If it prints there will be recognised a file with a player vehicle
 	}
	}
Pls.. Help me!

The problem is that the code print all vehicles and didn't recognise the player vehicle ones...
Reply


Messages In This Thread
MySQL Player Vehicles. - by Feli97 - 24.05.2011, 08:17
Re: MySQL Player Vehicles. - by Feli97 - 24.05.2011, 09:48
Re: MySQL Player Vehicles. - by Feli97 - 24.05.2011, 10:47
Re: MySQL Player Vehicles. - by dannyk0ed - 24.05.2011, 10:49
Re: MySQL Player Vehicles. - by Feli97 - 24.05.2011, 11:15
Re: MySQL Player Vehicles. - by Feli97 - 24.05.2011, 17:30
Re: MySQL Player Vehicles. - by Feli97 - 24.05.2011, 17:56
Re: MySQL Player Vehicles. - by GamingTurf - 24.05.2011, 18:13
Re: MySQL Player Vehicles. - by Feli97 - 24.05.2011, 18:15
Re: MySQL Player Vehicles. - by GamingTurf - 24.05.2011, 18:20

Forum Jump:


Users browsing this thread: 6 Guest(s)