14.10.2014, 17:18
Hello!
I need some help with my new business system please!
Ok so first of all I want my businesses to save each in it`s .cfg like Bizz1.cfg, Bizz2.cfg so on...
Second of all in game my businesses names and owner`s name doesn`t load properly.
NEXT CODES ARE SUGGESTIVE...These are just for making an idea how it looks like.
I need some help with my new business system please!
Ok so first of all I want my businesses to save each in it`s .cfg like Bizz1.cfg, Bizz2.cfg so on...
Second of all in game my businesses names and owner`s name doesn`t load properly.
NEXT CODES ARE SUGGESTIVE...These are just for making an idea how it looks like.
Код:
SaveBusiness() { new string3[32], id; new businessid[MAX_BUSINESSES]; format(string3, sizeof(string3), "Businesses.cfg", businessid); new File: hFile = fopen(string3, io_write); if (hFile) { new var[32]; for(new biz = 0; biz < MAX_BUSINESSES; biz++) { format(var, 32, "%dName=%s\n",biz, Businesses[biz][bName]); fwrite(hFile, var); format(var, 32, "%dOwnerName=%s\n",biz, Businesses[biz][bOwnerName]); fwrite(hFile, var); format(var, 32, "%dType=%d\n",biz, Businesses[biz][bType]); fwrite(hFile, var); format(var, 32, "%dValue=%d\n",biz, Businesses[biz][bValue]); fwrite(hFile, var); format(var, 32, "%dOwnerID=%d\n",biz, Businesses[biz][bOwner]); fwrite(hFile, var); format(var, 32, "%dMonths=%d\n",biz, Businesses[biz][bMonths]); fwrite(hFile, var); format(var, 32, "%dSafeBalance=%d\n",biz, Businesses[biz][bSafeBalance]); fwrite(hFile, var); format(var, 32, "%dInventory=%d\n",biz, Businesses[biz][bInventory]); fwrite(hFile, var); format(var, 32, "%dInventoryCapacity=%d\n",biz, Businesses[biz][bInventoryCapacity]); fwrite(hFile, var); } fclose(hFile); } return 1; }
Код:
LoadBusiness() { new string2[128]; new businessid[MAX_BUSINESSES]; format(string2, sizeof(string2), "Businesses.cfg", businessid); new File: BusinessesFile = fopen(string2, io_read); if ( BusinessesFile ) { new key[ 256 ] , val[ 256 ]; new Data[ 256 ]; while ( fread( BusinessesFile , Data , sizeof( Data ) ) ) { new string[128]; for(new idx = 0; idx < MAX_BUSINESSES; idx++) { key = ini_GetKey( Data ); format(string, 128, "%dName", idx); if( strcmp( key, "Name", true ) == 0 ) { val = ini_GetValue( Data ); strmid(Businesses[idx][bName], val, 0, strlen(val)-1, 255); } format(string, 128, "%dOwnerName", idx); if( strcmp( key, "OwnerName", true ) == 0 ) { val = ini_GetValue( Data ); strmid(Businesses[idx][bOwnerName], val, 0, strlen(val)-1, 255); } format(string, 128, "%dOwnerID", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bOwner] = strval( val ); } format(string, 128, "%dType", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bType] = strval( val ); } format(string, 128, "%dValue", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bValue] = strval( val ); } format(string, 128, "%dStatus", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bStatus] = strval( val ); } format(string, 128, "%dLevel", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bLevel] = strval( val ); } format(string, 128, "%dLevelProgress", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bLevelProgress] = strval( val ); } format(string, 128, "%dSafeBalance", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bSafeBalance] = strval( val ); } format(string, 128, "%dInventory", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bInventory] = strval( val ); } format(string, 128, "%dInventoryCapacity", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bInventoryCapacity] = strval( val ); } format(string, 128, "%dAutoSale", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bAutoSale] = strval( val ); } format(string, 128, "%dTotalSales", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bTotalSales] = strval( val ); } format(string, 128, "%dRankPay", idx); if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); Businesses[idx][bRankPay] = strval( val ); } } } RefreshBusinessPickup(idx); } } fclose(BusinessesFile); } }