25.03.2012, 12:26
i've been creating my own house system and I want that all hoses save in only one file! I made that partly but it is not fast enough....So I wanted to convert what i've made to faster file system and here is what i have
enum
house load on gamemodeinit
and i want to make saving system too, so that it saves ongamemodexit
I didn't do it yet because i tought it would be better to convert it first....
kuce.cfg
enum
Код:
enum kInfo { kID, kKupljeno, kVlasnik[MAX_PLAYER_NAME], Float:kUlazX, Float:kUlazY, Float:kUlazZ, Float:kIzlazX, Float:kIzlazY, Float:kIzlazZ, kInterijer, kSvijet, kLevel, kCijena, kZakljucano, Text3D:kTekst };
Код:
#define MAX_HOUSES 1000
Код:
stock LoadHouses() { new arrCoords[22][64]; new strFromFile2[128]; new File: file = fopen("kuce/kuce.cfg", io_read); if (file) { new idx; while (idx < sizeof(KucaInfo)) { fread(file, strFromFile2); split(strFromFile2, arrCoords, ','); KucaInfo[idx][kID] = strval(arrCoords[0]); KucaInfo[idx][kKupljeno] = strval(arrCoords[1]); strmid(KucaInfo[idx][kVlasnik], arrCoords[2], 0, strlen(arrCoords[2]), 255); KucaInfo[idx][kUlazX] = floatstr(arrCoords[3]); KucaInfo[idx][kUlazY] = floatstr(arrCoords[4]); KucaInfo[idx][kUlazZ] = floatstr(arrCoords[5]); KucaInfo[idx][kIzlazX] = floatstr(arrCoords[6]); KucaInfo[idx][kIzlazY] = floatstr(arrCoords[7]); KucaInfo[idx][kIzlazZ] = floatstr(arrCoords[8]); KucaInfo[idx][kInterijer] = strval(arrCoords[9]); KucaInfo[idx][kSvijet] = strval(arrCoords[10]); KucaInfo[idx][kLevel] = strval(arrCoords[11]); KucaInfo[idx][kCijena] = strval(arrCoords[12]); KucaInfo[idx][kZakljucano] = strval(arrCoords[13]); new infotekst[1024]; new vrsta[512]; if(KucaInfo[idx][kLevel] == 1){ vrsta = "Mala Kuca"; } if(KucaInfo[idx][kLevel] == 2){ vrsta = "Srednja Kuca"; } if(KucaInfo[idx][kLevel] == 3){ vrsta = "Velika Kuca"; } if(KucaInfo[idx][kLevel] == 4){ vrsta = "Vila"; } if(KucaInfo[idx][kKupljeno] == 1) { KucaInfo[idx][kID] = CreatePickup(1239,1,KucaInfo[idx][kUlazX],KucaInfo[idx][kUlazY],KucaInfo[idx][kUlazZ],0); format(infotekst, sizeof(infotekst), "{33FF00}Vlasnik:{FFFFFF} %s\n{33FF00}Vrsta:{FFFFFF} %s",KucaInfo[idx][kVlasnik],vrsta); KucaInfo[idx][kTekst] = Create3DTextLabel(infotekst,0x008080FF,KucaInfo[idx][kUlazX],KucaInfo[idx][kUlazY],KucaInfo[idx][kUlazZ],10, 0, 0); } else { KucaInfo[idx][kID] = CreatePickup(1273,1,KucaInfo[idx][kUlazX],KucaInfo[idx][kUlazY],KucaInfo[idx][kUlazZ],0); format(infotekst, sizeof(infotekst), "{33FF00}Status: {FFFFFF}Kuca na prodaju!\n{33FF00}Vlasnik:{FFFFFF} %s\n{33FF00}Vrsta:{FFFFFF} %s\n{33FF00}Cijena:{FFFFFF} $%i",KucaInfo[idx][kVlasnik],vrsta,KucaInfo[idx][kCijena]); KucaInfo[idx][kTekst] = Create3DTextLabel(infotekst,0x008080FF,KucaInfo[idx][kUlazX],KucaInfo[idx][kUlazY],KucaInfo[idx][kUlazZ],10, 0, 0); } if(!strlen(KucaInfo[idx][kVlasnik])) { strmid(KucaInfo[idx][kVlasnik],"Nitko",0,10,255); } idx++; } fclose(file); } return 1; }
I didn't do it yet because i tought it would be better to convert it first....
kuce.cfg
Код:
1,0,Nitko,2522.7849,-1679.2186,15.4970,328.493988,1480.589966,1084.449951,15,1,2,200000,0 2,1,Tom_Smith,2523.9614,-1658.5956,15.4935,223.043991,1289.259888,1082.199951,1,2,1,150000,1 0,0,Nitko,0,0,0,0,0,0,0,0,0,0,0 // last house is lagging as hell so i had to put this line