SA-MP Forums Archive
Size gets big +rep - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Size gets big +rep (/showthread.php?tid=587144)



Size gets big +rep - iBots - 28.08.2015

I have a system, that players can buy like a business, and each business has 100 slots, like in the enum:
pawn Код:
businessthing1[100],
businessthing2[100],
businessthing3[100],
There is no way to remove business2 and business3 so dont suggest that,the main problem is i have to loop over them in order to do few things with them, and looping them makes the size of the max very big, is there a way to fix?


Re: Size gets big +rep - Isolated - 28.08.2015

Just use an enum.
pawn Код:
enum bInfo {
   BusinessItem1,
   BusinessItem2,
   BusinessItem3[28] // We'll say this is a string.
}

new Business[100][bInfo];



Re: Size gets big +rep - iBots - 28.08.2015

But my enum should include business id so it will be:
pawn Код:
new Business[max_businesses][100][binfo]
which means it will be the same


Re: Size gets big +rep - Logofero - 28.08.2015

Quote:
Originally Posted by iBots
Посмотреть сообщение
I have a system, that players can buy like a business, and each business has 100 slots, like in the enum:
pawn Код:
businessthing1[100],
businessthing2[100],
businessthing3[100],
There is no way to remove business2 and business3 so dont suggest that,the main problem is i have to loop over them in order to do few things with them, and looping them makes the size of the max very big, is there a way to fix?
PHP код:
enum E_BUSINESS {
     
BUSINESS_NAME1[MAX_PLAYERS][24], // is string
     
BUSINESS_NAME2[MAX_PLAYERS][24], // ...
     
BUSINESS_NAME3[MAX_PLAYERS][24],  // eof string
     
BUSINESS_COST1[MAX_PLAYERS// is integer
     
BUSINESS_COST2[MAX_PLAYERS// ...
     
BUSINESS_COST3[MAX_PLAYERS// eof integer
}
new 
business[100][E_BUSINESS]; // declaration
business[0][BUSINESS_NAME2][playerid] = "My Bussuname"// set varlue
business[0][BUSINESS_COST2][playerid] = 10000;
// Test
for (new i100i++) {
      
printf("index %d bussuname '%s' cost $%d"ibusiness[i][BUSINESS_NAME2][playerid], business[i][BUSINESS_COST2][playerid]);

NOTE: You have to understand, the more cells in the array, the more it will weigh when compiling!


Re: Size gets big +rep - iBots - 28.08.2015

I just tried it,and it gives like 700 kb to the script.


Re: Size gets big +rep - iBots - 28.08.2015

I got max business is like 1000, so it will even give more weight to the gamemode


Re: Size gets big +rep - Sew_Sumi - 28.08.2015

Disregard.


Re: Size gets big +rep - Logofero - 28.08.2015

Fixed.

Example:
PHP код:
#define MAX_BUSINESS (1000)
enum E_BUSINESS {
     
BUSINESS_NAME1[24], // is string
     
BUSINESS_NAME2[24],
     
BUSINESS_NAME3[24],
     
BUSINESS_COST1// is integer
     
BUSINESS_COST2,
     
BUSINESS_COST3
}
new 
business[MAX_BUSINESS][E_BUSINESS]; // declaration
main() 
{   
    
format(business[0][BUSINESS_NAME1], 24"%s""My Bussuname"); // set business name 
    
business[0][BUSINESS_COST1] = 10000// set business cost
    
    
for (new iMAX_BUSINESSi++) {
          
printf("index %d bussuname '%s' cost $%d"ibusiness[i][BUSINESS_NAME1], business[i][BUSINESS_COST1]); // Show all business
    
}  

You can also add:
PHP код:
enum E_BUSINESS {
     
BUSINESS_NAME1[24], // is string
     
BUSINESS_NAME2[24],
     
BUSINESS_NAME3[24],
     
BUSINESS_COST1// is integer
     
BUSINESS_COST2,
     
BUSINESS_COST3,
     
BUSINESS_OWNERS[MAX_PLAYERS]  // is integer
}
main() 
{   
    
format(business[0][BUSINESS_NAME1], 24"%s""My Bussuname"); // set business name 
    
business[0][BUSINESS_COST1] = 10000// set business cost
    
business[0][BUSINESS_OWNERS][0] = 1// set business stat for player ID 0
    
for (new iMAX_BUSINESSi++) {
          
printf("index %d bussuname '%s' cost $%d"ibusiness[i][BUSINESS_NAME1], business[i][BUSINESS_COST1]); // Show all business
    
}  




Re: Size gets big +rep - Rodri99 - 28.08.2015

enum condition will just lag-bug the function, you should improve the code using [100] or minium on the string you want to make


Re: Size gets big +rep - iBots - 28.08.2015

Oh really?so you want me to type 300 things in the enum?are you kidding me?what if i want to loop them?>