Szerző Téma: Mapok filebol  (Megtekintve 839 alkalommal)

Nem elérhető hpeter94

  • 1450
  • Fórum fenntartó
    • Profil megtekintése
Mapok filebol
« Dátum: 2010. március 31. - 18:17:04 »
0 Show voters
hy! egy olyan script kéne ami filebol tölti be a mapokat (xstreamert használok) próbáltam hogy átírom az alap vehicle loadost de nem jelennek meg az objectek....
 

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
  • = string[start_index];

    x++;
    start_index++;
}
return_str
  • = EOS;

if(string[start_index] == EOS) start_index = (-1);
return start_index;
}
new total_objects_from_files=0;
public OnGameModeInit()
{
total_objects_from_files += LoadStreamedObjectsFromFile(\"objects/skroad2.txt\");
printf(\"Total objects from files: %d\",total_objects_from_files);
return 1;
}

 
a file meg így nézz ki:
 

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 ;
...

 
elore is köszönök minden segítséget

Mapok filebol
« Válasz #1 Dátum: 2010. március 31. - 18:43:51 »
0 Show voters
Ha a fájlt létrehozza akkor csak(gondolom van) az enumból az infókat...ennyi :)

De én pl. a file-s mentést meg ezeket nem szeressem inkább dini-t javaslom...egyszerubb és sztem jobb is :)

Mapok filebol
« Válasz #2 Dátum: 2010. április 02. - 23:03:44 »
0 Show voters
xStreamer régi, rossz, használd ezt: http://forum.sa-mp.com/index.php?topic=127905.0
 
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;
}
« Utoljára szerkesztve: 2010. április 03. - 09:20:22 írta Gamestar »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal