05.11.2012, 21:59
Olб, estou tentando carregar objetos .map por meio deste script, sу que estou enfrentando sйrios problemas pois o loop estб girando e estб printando apenas debug1 (10k de vezes), sendo que em um exemplo quase igual que um colega me passou funcionou tranquilo.. gostaria de saber por que nгo estб carregando..
Quero carregar a XYZ em ob@pd[ll@cou][0], ob@pd[ll@cou][1], ob@pd[ll@cou][2] e RXRYRZ em ob@pd[ll@cou][3], ob@pd[ll@cou][4] e ob@pd[ll@cou][5]... sendo que ll@cou й a var do giro do loop e ob@pd[3][10000] й uma float .-.
PS: Nunca mechi com fread/fwrite do SA-MP, nem com sscanf dessa maneira .-.
PSІ: Nгo quero code, quero entender o que ta errado '-'
PSі: O code do sscanf foi copiado da include do mick88, abaixo:
pawn Код:
LoadMap(map[])
{
if(ob@created > 10000) return er_2(), 0;
if(!fexist(map)) return er_3(), 0;
new interior, world;
new ll@cou, string[400];
new File:l@map=fopen(map);
while(fread(l@map, string))
{
print("debug1");
if(!sscanf(string, "p<\">'object''model='d'interior='d'dimension='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f", ob@modelid[ll@cou], interior, world, ob@pd[0][ll@cou], ob@pd[1][ll@cou], ob@pd[2][ll@cou], ob@pd[3][ll@cou], ob@pd[4][ll@cou], ob@pd[5][ll@cou]))
{
dt@cr_ob ++;
printf("-- DEBUG: OBJETO %d >>", dt@cr_ob);
}
++ll@cou; // ddsddffff
}
fclose(l@map);
//dt@cr_ob = ll@cou;
return 1;
}
PS: Nunca mechi com fread/fwrite do SA-MP, nem com sscanf dessa maneira .-.
PSІ: Nгo quero code, quero entender o que ta errado '-'
PSі: O code do sscanf foi copiado da include do mick88, abaixo:
pawn Код:
stock LoadMtaMap(file[], convert03c=false)
{
if (!fexist(file) || MinElementID == MAX_LOADED_ELEMENTS)
{
printf("Map %s cannot be loaded", file);
return 0;
}
new File:MapFile=fopen(file),
n, string[400], numberplate[MAX_NUMBERPLATE],
Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz,
modelid, paintjob, interior, world,
t = GetTickCount();
while(fread(MapFile, string))
{
if (!sscanf(string, "p<\">'object''model='d'interior='d'dimension='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f", modelid, interior, world, x, y, z, rx, ry, rz))
{
printf("DEBUG OBJECT %d", n);
/*if (convert03c)
{
switch(modelid)
{
case 14383..14483: modelid += 4248;
case 14770..14856: modelid += 4063;
case 14858..14871: modelid += 4062;
case 18000..18036: modelid += 934;
case 18038..18101: modelid += 933;
case 14872..14883: modelid += 4163;
case 14885..14891: modelid += 4162;
case 13590..13667: modelid += 5142;
case 14500..14522: modelid += 4310;
case 12835..12944: modelid -= 6219;
case 14892: modelid += 5009;
}
} */
//modelid x y z rx ry rz interior world
new objectid = ADD_OBJECT(modelid, x, y, z, rx, ry, rz);
if (objectid == INVALID_OBJECT_ID) printf("Error, object could not be created. Make sure you don't exceed max number of objects. Use stramer if you need to create more than %d objects!", MAX_OBJECTS);
else
{
#if defined _streamer_included
Streamer_SetFloatData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_DRAW_DISTANCE, MAP_STREAM_DISTANCE);
#endif
MapElements[MinElementID][eElementType] = ELEMENT_TYPE_OBJECT;
MapElements[MinElementID][eElementID] = objectid;
strcp(file, MapElements[MinElementID][eElementSource]);
//MapElements[MinElementID][eElementSource] = file;
n++;
//printf("Object %d loaded into slot %d", objectid, MinElementID);
if (!NextElementID())
{
fclose(MapFile);
return n;
}
}
}
else if (!sscanf(string, "p<\">'vehicle''paintjob='d'model='d'plate='s["#MAX_NUMBERPLATE"]'interior='d'dimension='d'posX='f'posY='f'posZ='f'rotZ='f", paintjob, modelid, numberplate, interior, world, x, y, z, rz))
{
printf("DEBUG VEHICLE %d", n);
new col1, col2, colors[20], mods[80], mod[MAX_MODS];
sscanf(string, "p<\">'color='s[20] ", colors);
sscanf(string, "p<\">'upgrades='s[80] ", mods);
sscanf(colors, "p<,>dd", col1, col2);
sscanf(mods, "p<,>A<d>(0)["#MAX_MODS"]", mod);
//modelid x y z rz col1 col2 paintjob interior world
new vehicleid = CreateVehicle(modelid, x, y, z, rz, col1, col2, VEHICLE_RESPAWN_DELAY);
if (vehicleid == INVALID_VEHICLE_ID) print("Vehicle failed to load! Check if you exceeded maximum of 2000 vehicles");
else
{
SetVehicleNumberPlate(vehicleid, numberplate);
SetVehicleToRespawn(vehicleid);
for (new i; i < MAX_MODS; i++) if (mod[i]) AddVehicleComponent(vehicleid, mod[i]);
ChangeVehiclePaintjob(vehicleid, paintjob);
LinkVehicleToInterior(vehicleid, interior);
SetVehicleVirtualWorld(vehicleid, world);
MapElements[MinElementID][eElementType] = ELEMENT_TYPE_VEHICLE;
MapElements[MinElementID][eElementID] = vehicleid;
strcp(file, MapElements[MinElementID][eElementSource]);
//MapElements[MinElementID][eElementSource] = file;
n++;
//printf("Vehicle %d loaded into slot %d", vehicleid, MinElementID);
if (!NextElementID())
{
fclose(MapFile);
return n;
}
}
}
}
fclose(MapFile);
printf("%d items loaded from '%s' in %dms", n, file, GetTickCount()-t);
return n;
}