21.01.2018, 22:51
Hi,
I'm in the process of upgrading my old game mode to use the latest version of the BlueG MySQL plugin and I am looking for some advise on converting the 'mysql_function_query' and cache functions.
Existing code:
So the first bits going ok
But the cache functions have now changed and im hoping someone may have some example code using the new cache functions, any help is appreciated.
The cache_get_value_name function looks a good start but I can't seem to find example code for looping through the results row by row.
Grim
I'm in the process of upgrading my old game mode to use the latest version of the BlueG MySQL plugin and I am looking for some advise on converting the 'mysql_function_query' and cache functions.
Existing code:
Код:
mysql_function_query(mysql, "SELECT * FROM server_vehicles", true, "mysql_loadServerVehicles", "i", 1);
Код:
PUBLIC:mysql_loadServerVehicles(num) { print("mysql_loadServerVehicles"); new svCars, fields; cache_get_data(svCars, fields); new rowstring[20]; if(svCars > 0) { for (new svCar=0;svCar<svCars;svCar++){ new temp_faction, vModel, Float:vPos[4], vColour1, vColour2, plateSet[30], plate[10]; cache_get_field_content(svCar, "vModel",rowstring, mysql); vModel = int:strval(rowstring); cache_get_field_content(svCar, "vPosX",rowstring, mysql); vPos[0] = floatstr(rowstring); cache_get_field_content(svCar, "vPosY",rowstring, mysql); vPos[1] = floatstr(rowstring); cache_get_field_content(svCar, "vPosZ",rowstring, mysql); vPos[2] = floatstr(rowstring); cache_get_field_content(svCar, "vPosR",rowstring, mysql); vPos[3] = floatstr(rowstring); cache_get_field_content(svCar, "vColour1",rowstring, mysql); vColour1 = int:strval(rowstring); cache_get_field_content(svCar, "vColour2",rowstring, mysql); vColour2 = int:strval(rowstring); cache_get_field_content(svCar, "vFaction",rowstring, mysql); temp_faction = int:strval(rowstring); // Vehicle Creation } } return 1; }
Код:
mysql_tquery(mysql, "SELECT * FROM server_vehicles", "mysql_loadServerVehicles", "i", 1);
The cache_get_value_name function looks a good start but I can't seem to find example code for looping through the results row by row.
Grim