07.11.2012, 04:36
Quote:
enum eCarDealer { pOwned, pOwner[MAX_PLAYER_NAME], Text3D: pLabel, pPrice, Float: pVehicleSpawn[4], pLocked, pPickUp }; |
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;
}