06.11.2012, 15:15
Loading code:
Saving code:
Whenever I buy a dealership and what not, it will save and show my name and the co-ordinates, but after I restart the server and go to the place I made it, its gone and when I place another dealership after the restart it resets the other one
pawn Код:
LoadDealerships() {
if(!fexist("Dealerships.cfg")) return 1;
new
szFileStr[1024],
File: iFileHandle = fopen("Dealerships.cfg", io_read),
iIndex;
while(iIndex < MAX_CARDEALERSHIPS && fread(iFileHandle, szFileStr)) {
if(!sscanf(szFileStr, "p<|>ds[32]dfffd",
CarDealer[iIndex][pOwned],
CarDealer[iIndex][pOwner],
CarDealer[iIndex][pPrice],
CarDealer[iIndex][pVehicleSpawnX],
CarDealer[iIndex][pVehicleSpawnY],
CarDealer[iIndex][pVehicleSpawnZ],
CarDealer[iIndex][pLocked])) {
if(!isnull(CarDealer[iIndex][pOwner])) format(szFileStr, sizeof(szFileStr), "{4BB325}Vehicle Dealership\n{C4C920}[Owner: %s]\n[Price: $%d]\n\n[ID: %d]", CarDealer[iIndex][pOwner], CarDealer[iIndex][pPrice], iIndex);
else format(szFileStr, sizeof(szFileStr), "{4BB325}Vehicle Dealership\n{C4C920}[Owner: None(/buydealer)]\n[Price: $%d]\n\n[ID: %d]", CarDealer[iIndex][pPrice], iIndex);
CarDealer[iIndex][pPickUp] = CreateDynamicPickup(1272, 23, CarDealer[iIndex][pVehicleSpawnX], CarDealer[iIndex][pVehicleSpawnY], CarDealer[iIndex][pVehicleSpawnZ], .worldid = 0, .interiorid = 0);
CarDealer[iIndex][pLabel] = Create3DTextLabel(szFileStr, COLOR_WHITE, CarDealer[iIndex][pVehicleSpawnX], CarDealer[iIndex][pVehicleSpawnY], CarDealer[iIndex][pVehicleSpawnZ] + 0.5, 10.0, 0,0);
++iIndex;
}
}
return fclose(iFileHandle);
}
pawn Код:
SaveDealerships() {
new
szFileStr[1024],
File: fHandle = fopen("Dealerships.cfg", io_write);
for(new iIndex; iIndex < MAX_CARDEALERSHIPS; iIndex++) {
format(szFileStr, sizeof(szFileStr),"%d|%s|$%d|%f.2|%f.2|%f.2|%d\r\n",
CarDealer[iIndex][pOwned],
CarDealer[iIndex][pOwner],
CarDealer[iIndex][pPrice],
CarDealer[iIndex][pVehicleSpawnX],
CarDealer[iIndex][pVehicleSpawnY],
CarDealer[iIndex][pVehicleSpawnZ],
CarDealer[iIndex][pLocked]
);
fwrite(fHandle, szFileStr);
}
fclose(fHandle);
return 1;
}