24.05.2011, 08:17
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.
And this is the code for loading player vehicles when he logs.
Pls.. Help me!
The problem is that the code print all vehicles and didn't recognise the player vehicle ones...
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(); }
Код:
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 } }
The problem is that the code print all vehicles and didn't recognise the player vehicle ones...