15.04.2011, 14:04
Всем привет , я сделал пробел для авто он норм работает но почему то не сохрняется , в cars.cfg он создает еще одни 0 , но не записывает туда сколько авто проехало , я делал так:
public OnPropUpdate()
помогите пожалуйста вроде все верно но после рестарта он пропадает и опять 0
PHP код:
new Text:probeg[MAX_PLAYERS];
PHP код:
enum cInfo
{
CarOwner[MAX_PLAYER_NAME],
CarOwned,
cId,
cModel,
Float:cSTCar_x,
Float:cLocationx,
Float:cLocationy,
Float:cPARKCar_x,
Float:cPARKCar_y,
Float:cPARKCar_z,
Float:cPARKCar_a,
Float:cSTCar_z,
Float:cSTCar_a,
Float:cSTCar_y,
Float:CarIzmPosY,
Float:CarIzmPosX,
Float:CarIzmPosZ,
Float:cLocationz,
cKey,
cVents,
Float:cAngle,
cRearBumper,
cFrontBumper,
cFrontBullbars,
cFrontSign,
cRearBullbars,
cPolis,
cBullbar,
cWheels,
cCost,
cColor1,
cColor2,
cColorOne,
cColorTwo,
cOwner[MAX_PLAYER_NAME],
cDescription[MAX_PLAYER_NAME],
cValue,
cLicense,
cRegistration,
cOwned,
cLock,
cNumbercar,// (12)
cTeh,// (13)
cWheel,// (14)
cSpoiler,// (15)
cPaintJob,
cHood,// (16)
cRoof,// (17)
cSideskirt,// (18)
cLamps,// (19)
cNitro,// (20)
cExhaust,// (21)
cStereo,// (22)
cHydraulics,// (23)
cFrontbumper,// (24)
CarDump,
cRearbumper,// (25)
cVentright,// (26)
cVentleft,// (27)
Float:cProbeg,
CarParkFine,
};
new CarInfo[609][cInfo];
PHP код:
public LoadCar()
{
new arrCoords[29][64];
new strFromFile2[256];
new File: file = fopen("cars.cfg", io_read);
if (file)
{
new idx = 365;//машины родные
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]);
//-----------------------------[Тюнинг]-----------------------------------------
CarInfo[idx][cNumbercar] = strval(arrCoords[13]);
CarInfo[idx][cTeh] = strval(arrCoords[14]);
CarInfo[idx][cWheel] = strval(arrCoords[15]);
CarInfo[idx][cSpoiler] = strval(arrCoords[16]);
CarInfo[idx][cHood] = strval(arrCoords[17]);
CarInfo[idx][cSideskirt] = strval(arrCoords[18]);
CarInfo[idx][cLamps] = strval(arrCoords[19]);
CarInfo[idx][cNitro] = strval(arrCoords[20]);
CarInfo[idx][cExhaust] = strval(arrCoords[21]);
CarInfo[idx][cStereo] = strval(arrCoords[22]);
CarInfo[idx][cHydraulics] = strval(arrCoords[23]);
CarInfo[idx][cFrontbumper] = strval(arrCoords[24]);
CarInfo[idx][cRearbumper] = strval(arrCoords[25]);
CarInfo[idx][cVentright] = strval(arrCoords[26]);
CarInfo[idx][cVentleft] = strval(arrCoords[27]);
CarInfo[idx][cProbeg] = floatstr(arrCoords[28]);
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
idx++;
}
}
return 1;
}
PHP код:
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|%f|\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo],
CarInfo[idx][cProbeg]);
if(idx == 0)
{
file2 = fopen("cars.cfg", io_write);
}
else
{
file2 = fopen("cars.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
PHP код:
idx = 365;//машины родные
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%f\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],
CarInfo[idx][cNumbercar],//
CarInfo[idx][cTeh],//
CarInfo[idx][cWheel],//
CarInfo[idx][cSpoiler],//
CarInfo[idx][cHood],//
CarInfo[idx][cRoof],//
CarInfo[idx][cSideskirt],//
CarInfo[idx][cLamps],//
CarInfo[idx][cNitro],//
CarInfo[idx][cExhaust],//
CarInfo[idx][cStereo],//
CarInfo[idx][cHydraulics],//
CarInfo[idx][cFrontbumper],//
CarInfo[idx][cRearbumper],//
CarInfo[idx][cVentright],//
CarInfo[idx][cVentleft],//
CarInfo[idx][cProbeg]);
if(idx == 365) file2 = fopen("cars.cfg", io_write);//машины родные
else file2 = fopen("cars.cfg", io_append);
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
PHP код:
forward Probeg();
public Probeg()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
/* if(VehInfo[i][aMod]==0||VehInfo[i][aMod]==1) break;
new carid = VehInfo[i][aID];
new Float:sp = GetVehicleSpeed(carid);
new l = (sp/3.6)/1000;
VehInfo[i][aProbeg] += l;*/
new string[256];
if(IsPlayerConnected(i))
{
if(IsPlayerInAnyVehicle(i))
{
if(IsAnOwnableCar(GetPlayerVehicleID(i)))
{
new Float:sp = GetPlayerSpeed(i);
new Float:ms;
ms = (sp/1.4)/1000;
CarInfo[GetMassiveAddress(GetPlayerVehicleID(i))][cProbeg] += ms;
format(string,256,"%f km",CarInfo[GetMassiveAddress(GetPlayerVehicleID(i))][cProbeg]);
TextDrawSetString(probeg[i],string);
}
}
}
}
return 1;
}