24.11.2012, 06:47
Код:
stock LoadProperties() { if(fexist("PropertySystem/PropertyInfo.txt")) { CountProperties(); new Argument[9][70]; new entry[256], BoughtProps; new File: propfile = fopen("PropertySystem/PropertyInfo.txt", io_read); if (propfile) { for(new id; id<PropertiesAmount; id++) { fread(propfile, entry); split(entry, Argument, ','); format(PropInfo[id][PropName], 64, "%s", Argument[0]); PropInfo[id][PropX] = floatstr(Argument[1]); PropInfo[id][PropY] = floatstr(Argument[2]); PropInfo[id][PropZ] = floatstr(Argument[3]); PropInfo[id][PropValue] = strval(Argument[4]); PropInfo[id][PropEarning] = strval(Argument[5]); format(PropInfo[id][PropOwner], MAX_PLAYER_NAME, "%s", Argument[6]); PropInfo[id][PropIsBought] = strval(Argument[7]); PropInfo[id][PropUnbuyableTime] = strval(Argument[8]); PropInfo[id][PickupNr] = CreatePickup(1273, 1, PropInfo[id][PropX], PropInfo[id][PropY], PropInfo[id][PropZ]); if(PropInfo[id][PropIsBought] == 1) { BoughtProps++; } } fclose(propfile); printf("==================================="); printf("|| %d Propiedades A La Venta||", PropertiesAmount); printf("|| %d propiedades compradas||", BoughtProps); printf("==================================="); } } } stock SaveProperties() { new entry[256]; new File: propfile = fopen("PropertySystem/PropertyInfo.txt", io_write); for(new id; id<PropertiesAmount; id++) { format(entry, 128, "%s,%.2f,%.2f,%.2f,%d,%d,%s,%d,%d \r\n",PropInfo[id][PropName], PropInfo[id][PropX], PropInfo[id][PropY], PropInfo[id][PropZ], PropInfo[id][PropValue], PropInfo[id][PropEarning], PropInfo[id][PropOwner], PropInfo[id][PropIsBought], PropInfo[id][PropUnbuyableTime]); fwrite(propfile, entry); } printf("Saved %d Properties!", PropertiesAmount); fclose(propfile); } forward split(const strsrc[], strdest[][], delimiter); public split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)){ if(strsrc[i]==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; }