new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows) {
for(new i = 0; i < rows; i++) {
new modelStr[5], posXStr[20], posYStr[20], posZStr[20], rotXStr[20], rotYStr[20], rotZStr[20];
new model, Float:posX, Float:posY, Float:posZ, Float:rotX, Float:rotY, Float:rotZ;
cache_get_field_content(i, "model", modelStr);
cache_get_field_content(i, "posX", posXStr);
cache_get_field_content(i, "posY", posYStr);
cache_get_field_content(i, "posZ", posZStr);
cache_get_field_content(i, "rotX", rotXStr);
cache_get_field_content(i, "rotY", rotYStr);
cache_get_field_content(i, "rotZ", rotZStr);
model = strval(modelStr);
posX = floatstr(posXStr);
posY = floatstr(posYStr);
posZ = floatstr(posZStr);
rotX = floatstr(rotXStr);
rotY = floatstr(rotYStr);
rotZ = floatstr(rotZStr);
Objects[i] = CreateDynamicObject(model, posX, posY, posZ, rotX, rotY, rotZ, worldID, 0, -1);
objectsLoaded++;
}
printf("[DD] LOAD: Successfully Loaded all Pickups!\n");
loadStep++;
onMapLoadMetaRequest(mapID);
}
Objects[i] = CreateDynamicObject
(
cache_get_field_content_int(i, "model"),
cache_get_field_content_float(i, "posX"),
cache_get_field_content_float(i, "posY"),
cache_get_field_content_float(i, "posZ"),
cache_get_field_content_float(i, "rotX"),
cache_get_field_content_float(i, "rotY"),
cache_get_field_content_float(i, "rotZ"),
worldID,
0,
-1
);
You can feed the loading directly into CreateDynamicObject. This saves you a bunch of variables and it overall looks cleaner. This IS a threaded query right?
e.g. pawn Код:
|
mysql_format(mysql, queryString, sizeof(queryString), "SELECT `model`, `posX`, `posY`, `posZ`, `rotX`, `rotY`, `rotZ`, `description` FROM `Table_Name` WHERE `mid` = %d", mapID);
mysql_tquery(mysql, queryString, "onMapLoadMeta", "i", mapID);