stock LoadStreamedObjectsFromFile(const filename[]){new File:file_ptr;new line[256];new var_from_line[64];new modelid;new Float:x;new Float:y;new Float:z;new Float:rx;new Float:ry;new Float:rz; new virtualworld; new interior;new index;new objects_loaded;file_ptr = fopen(filename,filemode:io_read);if(!file_ptr) return 0;objects_loaded = 0;while(fread(file_ptr,line,256) > 0){ index = 0; // modelid index = token_by_delim(line,var_from_line,\',\',index); if(index == (-1)) continue; modelid = strval(var_from_line); // Read X, Y, Z, Rotation index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; x = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; y = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; z = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; rx = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; ry = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; rz = floatstr(var_from_line); // Read virtualworld, interior index = token_by_delim(line,var_from_line,\',\',index+1); if(index == (-1)) continue; virtualworld = strval(var_from_line); index = token_by_delim(line,var_from_line,\';\',index+1); interior = strval(var_from_line);CreateStreamedObject(modelid,x,y,z,rx,ry,rz,virtualworld,interior);objects_loaded++;}fclose(file_ptr);printf(\"Loaded %d objects from: %s\",objects_loaded,filename);return objects_loaded;}stock token_by_delim(const string[], return_str[], delim, start_index){new x=0;while(string[start_index] != EOS && string[start_index] != delim) { return_str
8040, -2189.376221, 840.451843, 683.941650, 0.0000, 0.0000, 0.0000 ;18450, -2123.002930, 842.802795, 653.202271, 0.0000, 48.1285, 0.0000 ;18450, -2069.900146, 842.822571, 594.839966, 0.0000, 47.2690, 0.0000 ;18450, -2014.798706, 842.846191, 537.821716, 0.0000, 44.6907, 0.0000 ;...
stock objectsFromFile(file[]){new total_from_file = 0;if(!fexist(file)) { return 0;}new File:tmp = fopen(file, filemode:io_read);new line[256];new index;new var_from_line[256];if(!tmp) { return 0;}new modelid;new Float:x;new Float:y;new Float:z;new Float:rx;new Float:ry;new Float:rz;while(fread(tmp, line, 256)) { index = 0; // // Formátum: X, Y, Z, rX, rY, rZ ; // index = token_by_delim(line,var_from_line,\',\',index); modelid = strval(var_from_line); index = token_by_delim(line,var_from_line,\',\',index); x = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index); y = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index); z = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index); rx = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index); ry = floatstr(var_from_line); index = token_by_delim(line,var_from_line,\',\',index); rz = floatstr(var_from_line);CreateDynamicObject(modelid, x, y, z, rx, ry, rz);total_from_file++;}fclose(tmp);return total_from_file;}
stock objectToFileFormat(objectid, file[]){new File:tmp = fopen(file, filemode:io_append);if(!tmp) { return 0;}new myString[512];new modelid;new Float:x;new Float:y;new Float:z;new Float:rx;new Float:ry;new Float:rz;modelid = Streamer_GetIntData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_MODEL_ID);GetDynamicObjectPos(objectid, x, y, z);GetDynamicObjectRot(objectid, rx, ry, rz);format(myString,sizeof(myString), \"%i, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f ;\\r\\n\", modelid, x, y, z, rx, ry, rz);fwrite(tmp, myString);fclose(tmp);return 1;}