07.07.2016, 21:39
I have this simple enum:
And this is how I load the vehicles.
Everything loads up fine, even the "printf("#2 %d | %s", countveh, vehStat[x][vOwnerName]);" displays the right values.
But when I go ingame and enter a vehicle, I should get this message: Aceasta %s este detinuta de %s. Foloseste /vehinfo pentru mai multe detalii.
This is the hook:
I get the message, but the second %s is not displaying anything. As I said, everything is loading correctly, and I'm at the right vehicle too.
Did I do something wrong?
Let's say I have 1 vehicle. If I enter it, the string doesn't display the variable.
But if I have 2 vehicles, then my first vehicle will send the message with the right variable, and the second vehicle won't.
This applies to every amount of cars. Only the last car doesn't display the variable.
Код:
enum uVeh { vID, vModelID, Float:vPosX, Float:vPosY, Float:vPosZ, Float:vPosR, vOwnerID, vOwnerName[MAX_PLAYER_NAME], vMod1, vMod2, vMod3, vMod4, vMod5, vMod6, vMod7, vMod8, vMod9, vMod10, vMod11, vMod12, vMod13, vMod14, vMod15, vColor1, vColor2, vCarPlate[256], vPurch[256] } new vehStat[MAX_VEHICLES][uVeh];
Код:
forward IniUserVeh(); public IniUserVeh() { new quer[128]; format(quer, sizeof(quer), "SELECT * FROM `uservehicles`"); new Cache: result4 = mysql_query(handle, quer); new x, count, countveh, c; for(new z = 0; z < MAX_VEHICLES; z++) { c = GetVehicleModel(z); if(c >= 400) { countveh++; printf("%d", countveh); } } for ( new i, j = cache_get_row_count ( ); i != j; ++i ) { x = countveh++; cache_get_field_content(i, "vehicleModelID", result); vehStat[x][vModelID] = strval(result); cache_get_field_content(i, "vehiclePosX", result); vehStat[x][vPosX] = floatstr(result); cache_get_field_content(i, "vehiclePosY", result); vehStat[x][vPosY] = floatstr(result); cache_get_field_content(i, "vehiclePosZ", result); vehStat[x][vPosZ] = floatstr(result); cache_get_field_content(i, "vehiclePosRot", result); vehStat[x][vPosR] = floatstr(result); cache_get_field_content(i, "vehicleOwner", result); vehStat[x][vOwnerID] = strval(result); cache_get_field_content(i, "vehicleOwnerName", result); format(vehStat[x][vOwnerName], MAX_PLAYER_NAME, "%s", result); cache_get_field_content(i, "vehicleMod1", result); vehStat[x][vMod1] = strval(result); cache_get_field_content(i, "vehicleMod2", result); vehStat[x][vMod2] = strval(result); cache_get_field_content(i, "vehicleMod3", result); vehStat[x][vMod3] = strval(result); cache_get_field_content(i, "vehicleMod4", result); vehStat[x][vMod4] = strval(result); cache_get_field_content(i, "vehicleMod5", result); vehStat[x][vMod5] = strval(result); cache_get_field_content(i, "vehicleMod6", result); vehStat[x][vMod6] = strval(result); cache_get_field_content(i, "vehicleMod7", result); vehStat[x][vMod7] = strval(result); cache_get_field_content(i, "vehicleMod8", result); vehStat[x][vMod8] = strval(result); cache_get_field_content(i, "vehicleMod9", result); vehStat[x][vMod9] = strval(result); cache_get_field_content(i, "vehicleMod10", result); vehStat[x][vMod10] = strval(result); cache_get_field_content(i, "vehicleMod11", result); vehStat[x][vMod11] = strval(result); cache_get_field_content(i, "vehicleMod12", result); vehStat[x][vMod12] = strval(result); cache_get_field_content(i, "vehicleMod13", result); vehStat[x][vMod13] = strval(result); cache_get_field_content(i, "vehicleMod14", result); vehStat[x][vMod14] = strval(result); cache_get_field_content(i, "vehicleMod15", result); vehStat[x][vMod15] = strval(result); cache_get_field_content(i, "vehicleColor1", result); vehStat[x][vColor1] = strval(result); cache_get_field_content(i, "vehicleColor2", result); vehStat[x][vColor2] = strval(result); cache_get_field_content(i, "vehicleCarPlate", result); format(vehStat[x][vCarPlate], 32, "%s", result); cache_get_field_content(i, "vehiclePurchaseDate", result); format(vehStat[x][vPurch], 32, "%s", result); count++; CreateVehicle(vehStat[x][vModelID], vehStat[x][vPosX], vehStat[x][vPosY], vehStat[x][vPosZ], vehStat[x][vPosR], vehStat[x][vColor1], vehStat[x][vColor2], -1); SetVehicleNumberPlate(x, vehStat[x][vCarPlate]); printf("#2 %d | %s", countveh, vehStat[x][vOwnerName]); } printf("[DEBUG] Loaded %d user vehicles.", count); cache_delete(result4); return 1; }
But when I go ingame and enter a vehicle, I should get this message: Aceasta %s este detinuta de %s. Foloseste /vehinfo pentru mai multe detalii.
This is the hook:
Код:
Hook:45_OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { new vehid = GetPlayerVehicleID(playerid); new string[256]; new veh = GetVehicleModel(vehid); new name[64]; format(name, sizeof(name), "%s", VehicleNames[veh - 400]); if(strfind(name, "a", true) != -1) { format(string, sizeof(string), "Aceasta %s este detinut de %s. Foloseste /vehinfo pentru mai multe detalii.", name, vehStat[vehid][vOwnerName]); } else { format(string, sizeof(string), "Acest %s este detinut de %s. Foloseste /vehinfo pentru mai multe detalii.", name, vehStat[vehid][vOwnerName]); } SCM(playerid, COOL_GREEN, string); } }
Did I do something wrong?
Let's say I have 1 vehicle. If I enter it, the string doesn't display the variable.
But if I have 2 vehicles, then my first vehicle will send the message with the right variable, and the second vehicle won't.
This applies to every amount of cars. Only the last car doesn't display the variable.