[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Проблема с сохранением авто в ЛАРПе
Дата: 21.11.2009, Суббота, 19:46:39 | Сообщение # $NUMBER
Группа: Пользователи
Сообщений: 52
Репутация: 5+
Помогите плз если сможете у меня следующая проблема в моде есть скрипт сохранения авто(Хозяин координаты модель цена и.т.п)При покупке(или иных действиях) все сохраняеться в файл cars.cfg
Вот строки которые отвечают за это(вроде все)
public LoadCar()
{
new arrCoords[13][64];
new strFromFile2[256];
new File: file = fopen("cars.cfg", io_read);
if (file)
{
new idx = 184;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo[idx][cModel] = strval(arrCoords[0]);
CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
CarInfo[idx][cColorOne] = strval(arrCoords[5]);
CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
CarInfo[idx][cValue] = strval(arrCoords[9]);
CarInfo[idx][cLicense] = strval(arrCoords[10]);
CarInfo[idx][cOwned] = strval(arrCoords[11]);
CarInfo[idx][cLock] = strval(arrCoords[12]);
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
idx++;
}
}
return 1;
}

public SaveCarCoords()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo]);
if(idx == 0)
{
file2 = fopen("cars.cfg", io_write);
}
else
{
file2 = fopen("cars.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
....
idx = 184;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
CarInfo[idx][cModel],//
CarInfo[idx][cLocationx],//
CarInfo[idx][cLocationy],//
CarInfo[idx][cLocationz],//
CarInfo[idx][cAngle],//
CarInfo[idx][cColorOne],//
CarInfo[idx][cColorTwo],//
CarInfo[idx][cOwner],//
CarInfo[idx][cDescription],//
CarInfo[idx][cValue],//
CarInfo[idx][cLicense],//
CarInfo[idx][cOwned],//
CarInfo[idx][cLock]);
if(idx == 184)
{
file2 = fopen("cars.cfg", io_write);
}
else
{
file2 = fopen("cars.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
Проблема в том что после рестарта ид машины меняеться(и если ей владел игрок она снова продаеться или хозяин владеет ей но не может сесть)
Вот строка из файла КФГ 536,2118.743408,-1140.133666,24.724407,304.783538,3,0,Dealership,Bl ade,70000,,0,1

PS извените что так много моя ася если че 554407824 могу более подробно описать баг

  • Страница 1 из 1
  • 1
Поиск: