: error 047: array sizes do not match, or destination array is too small
#1

Код:
: error 047: array sizes do not match, or destination array is too small
pawn Код:
GetAdminRank(playerid)
{
    new string[24];

    switch(PlayerInfo[playerid][pAdmin])
    {
        case 0: string = "None";
        case 1: string = "{1D5857}Secret Admin";
        case 2: string = "{FFFF00}Junior Admin";
        case 3: string = "{26D607}General Admin";
        case 4: string = "{F9DE84}Senior Admin";
        case 5: string = "{F87627}Head Admin";
        case 6: string = "{C50574}Assistant Management"; // <<<<<< THIS LINE WHERE THE ERROR OCCURS
        case 7: string = "{EE39CE}Management";
    }
WHen i remove the {C50574} it doesnt give any error anymore

Pretty much weird why?
Reply
#2

It is because of the size of the string increase

PHP код:
new string[32]; 
Reply
#3

Quote:
Originally Posted by Swankeh
Посмотреть сообщение
It is because of the size of the string increase

PHP код:
new string[32]; 
thanks lol im so stupid
Reply
#4

Quote:
Originally Posted by Noris
Посмотреть сообщение
thanks lol im so stupid
No haha, same as I did before in my beginnings, are things that happens to the new ones there are many errors and warnings that when I leave and I know what I have to do to solve them. Anything I can help you with pleasure
Reply
#5

Quote:
Originally Posted by Swankeh
Посмотреть сообщение
No haha, same as I did before in my beginnings, are things that happens to the new ones there are many errors and warnings that when I leave and I know what I have to do to solve them. Anything I can help you with pleasure
you have to use format.
format(string, sizeof string, "{1D5857}Secret Admin");

Use this, no problem.
Код:
new AdminLevelArray[8][64] = {
	{"None"},{"{1D5857}Secret Admin"},{"{FFFF00}Junior Admin"},{"{26D607}General Admin"},{"{F9DE84}Senior Admin"},{"{F87627}Head Admin"},{"{C50574}Assistant Management"},{"{EE39CE}Management"}
};

GetAdminRank(playerid) return AdminLevelArray[PlayerInfo[playerid][pAdmin]];
// If GetAdminRank(playerid) gives some stupid return message, replace the function with this:
GetAdminRank(playerid) {
	new tempReturn[64];
	format(tempReturn,64,"%s",AdminLevelArray[PlayerInfo[playerid][pAdmin]]);
	return tempReturn;
}
Reply
#6

@whadez what about optimising it to be faster?
PHP код:

#define GetAdminLevel(%0)     AdminLevelArray[PlayerInfo[%0][pAdmin]]
new AdminLevelArray[8][64] = {
    {
"None"},{"{1D5857}Secret Admin"},{"{FFFF00}Junior Admin"},{"{26D607}General Admin"},{"{F9DE84}Senior Admin"},{"{F87627}Head Admin"},{"{C50574}Assistant Management"},{"{EE39CE}Management"}
}; 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)