AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Initialization data exceeds declared size (https://forums.alliedmods.net/showthread.php?t=99056)

Rexonspix 08-01-2009 08:11

Initialization data exceeds declared size
 
Hello.

I'm getting this error "Initialization data exceeds declared size", and I can't figure out, what I am doing wrong.

First I have this declared:
Code:

new jobPoliceRank[7] = { "Officer", "Detective", "Sergeant", "Lieutenant", "Major", "Inspector", "Sheriff" };
and later I have:
Code:

new rank[256];

rank[255] = jobPoliceRank[1];


Arkshine 08-01-2009 09:18

Re: Initialization data exceeds declared size
 
- jobPoliceRank[7]-> jobPoliceRank[7][]
- Use copy()

Rexonspix 08-01-2009 12:07

Re: Initialization data exceeds declared size
 
Now I get the error: "Must be assigned to an array" on the code:
Code:

rank[255] = jobPoliceRank[1];

Bugsy 08-01-2009 12:15

Re: Initialization data exceeds declared size
 
Quote:

Originally Posted by Rexonspix (Post 887534)
Now I get the error: "Must be assigned to an array" on the code:
Code:

rank[255] = jobPoliceRank[1];

Quote:

Originally Posted by Arkshine (Post 887462)
- Use copy()


PHP Code:

//A little easier to read
new jobPoliceRank[][] = 

    
"Officer"
    
"Detective"
    
"Sergeant"
    
"Lieutenant"
    
"Major"
    
"Inspector"
    
"Sheriff" 
};

new 
szRank11 ];

//the_rank_index should be 0 through 6. 0 = "Officer", 6 = "Sherriff"
copyszRank 10 jobPoliceRankthe_rank_index ] ); 

Show us what you are trying to do because you may not need to make a copy of the string, you can probably just use the original.

Rexonspix 08-01-2009 12:34

Re: Initialization data exceeds declared size
 
Oh like that :)

Anyways, I'm using the variable to either setting another variable, or using it in a format()
Etc.
Code:

playerJob[id] = rank;
or
format(menutext,255,"something %s",rank);


Bugsy 08-01-2009 12:54

Re: Initialization data exceeds declared size
 
Quote:

Originally Posted by Rexonspix (Post 887549)
Oh like that :)

Anyways, I'm using the variable to either setting another variable, or using it in a format()
Etc.
Code:

playerJob[id] = rank;
or
format(menutext,255,"something %s",rank);


Just use it directly then.
PHP Code:

formatmenutext255 "Something %s" jobPoliceRankthe_rank_index ] ); 

If playerJob[id] holds the rank index, you can do:
PHP Code:

formatmenutext255 "Something %s" jobPoliceRankplayerJob[id] ] ); 



All times are GMT -4. The time now is 18:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.