new string[] = "19392|2044.7829589844|1330.333984375|11.421999931335|0.0|0.0|0.0"; // Тут загружай из файла, я сделал так.
new id,Float:pos[6]; // Переменные на которые будем разделять строку.
sscanf(string,"p<|>iffffff",id,pos[0],pos[1],pos[2],pos[3],pos[4],pos[5]); // Разделяем строку string на переменные
CreateObject(id,pos[0],pos[1],pos[2],pos[3],pos[4],pos[5]); // Создаем обьект.
))) простите, торопился.. вот и написал))))
И так ребят, проблема такого масштаба: В общем у меня идёт загрузка с конфига(файла). А в это кофиге(файле) Лежит список объектов. В итоге я хочу благодаря sscanf выгрузить все эти объекты и создать. |
19392|2044.7829589844|1330.333984375|11.421999931335|0.0|0.0|0.0
хм мне нужно выгрузку)
Загрузку я примерно делаю так же Что-бы я мог, в любое время открыть карту ! |
format(string,sizeof(string),"%i|%f|%f|%f|%f|%f|%f\n",id,pos[0],pos[1],pos[2],pos[3],pos[4],pos[5]);
stock LoadDynamicobject(playerid,listitem)
{
new bigDialog[49];
new string[800];
format(bigDialog, sizeof bigDialog, "maps/%s", titleFiles[playerid][listitem]);
new RandomePos[8][64],FileStr[256],s[128],File: file = fopen(bigDialog, io_read); printf( "Прочитали названия 2 %s",bigDialog);
if (file)
{
printf( "читаем дальше 1 %s",file);
fread(file, FileStr);
split(FileStr, RandomePos, ',');
printf( "читаем дальше 2 %d",RandomePos);
CountObject = strval(RandomePos[0]);
for(new i; i<CountObject; i++)
{
printf( "CreateObject('%d''%f''%f'%f'%f''%f''%f');",ObjectInfo[i][modelidfs], ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman], ObjectInfo[i][rXman], ObjectInfo[i][rYman], ObjectInfo[i][rZman]);
fread(file, FileStr);
if (!sscanf(string, "p<\">'CreateObject('d''f''f'f'f''f''f''f''f''f');", ObjectInfo[i][modelidfs], ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman], ObjectInfo[i][rXman], ObjectInfo[i][rYman], ObjectInfo[i][rZman]))
{
printf( "Прочитали названия 4 %s",bigDialog);
ObjectInfo[i][objects] = CreateDynamicObject(ObjectInfo[i][modelidfs], ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman], ObjectInfo[i][rXman], ObjectInfo[i][rYman], ObjectInfo[i][rZman]);
format(s,256,"{527ac1}ID Объекта %d",ID);
printf( "modelidfs = %d |Start %s | X - %f | Y - %f | Z - %f | Rx - %f | rY - %f | rZ - %f |",ObjectInfo[i][modelidfs],ObjectInfo[i][Start],ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman],ObjectInfo[i][rXman],ObjectInfo[i][rYman],ObjectInfo[i][rZman]);
}
}
}
fclose(file);
return 1;
}
5
CreateObject(18450, -1378.38, -2979.43, 45.92, 0.00, 0.00, 90.00);
CreateObject(18450, -1378.37, -3058.60, 45.91, 0.00, 0.00, 90.00);
CreateObject(18450, -1378.38, -3137.98, 45.89, 0.00, 0.00, 90.00);
CreateObject(18450, -1378.37, -3217.32, 45.85, 0.00, 0.00, 90.00);
CreateObject(18450, -1378.37, -3297.18, 45.82, 0.00, 0.00, 90.00);
for(new i; i<CountObject; i++)
{
fread(file, FileStr);
sscanf(string, "p<|>ifffffffff", ObjectInfo[i][modelidfs], ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman], ObjectInfo[i][rXman], ObjectInfo[i][rYman], ObjectInfo[i][rZman]);
ObjectInfo[i][objects] = CreateDynamicObject(ObjectInfo[i][modelidfs], ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman], ObjectInfo[i][rXman], ObjectInfo[i][rYman], ObjectInfo[i][rZman]);
format(s,256,"{527ac1}ID Объекта %d",ID);
printf( "modelidfs = %d |Start %s | X - %f | Y - %f | Z - %f | Rx - %f | rY - %f | rZ - %f |",ObjectInfo[i][modelidfs],ObjectInfo[i][Start],ObjectInfo[i][Xman],ObjectInfo[i][Yman],ObjectInfo[i][Zman],ObjectInfo[i][rXman],ObjectInfo[i][rYman],ObjectInfo[i][rZman]);
}
PHP код:
|