Size gets big +rep
#1

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?
Reply
#2

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

new Business[100][bInfo];
Reply
#3

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
Reply
#4

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!
Reply
#5

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

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

Disregard.
Reply
#8

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
    
}  

Reply
#9

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)