Error 047 on a return statement?!
#1

I am getting the following error:
error 047: array sizes do not match, or destination array is too small
At this:
pawn Код:
new rankname[100];
    rankname = ranks[strval(rank)];
    return rankname;
(note: also tried as this:
pawn Код:
new rankname[50];
    format(rankname, sizeof(rankname), "%s", ranks[strval(rank)]);
    return rankname;
and since then changed the array sizes because they were too large..)

Ranks being defined as such:
pawn Код:
new ranks[8][100] = { // note in above NOTE it is not 100 but 50
"New guy" // further results omitted
};
I tried in multiple ways but it still wont let me return the string.
Reply
#2

Change [8][100] to [] [] - which will let the pawn compiler determine how big the array is based on what data is in there.
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
Change [8][100] to [] [] - which will let the pawn compiler determine how big the array is based on what data is in there.
Still the same
Reply
#4

what are you trying to return

//edit:

try this
pawn Код:
new rankname[50];
    format(rankname, sizeof(rankname), "%s", ranks[0]); //
    return rankname;
Reply
#5

I'm not sure how just returning it would work without any use of another public.
Here:

pawn Код:
new rankname[50];
    format(rankname, sizeof(rankname), "%s", ranks[0]); //
    return SendClientMessage(playerid, -1, rankname);
If that doesn't work please do show how ranks is used.
Reply
#6

I don't want to return the first rank but the rank specified in a MYSQL tuple.

pawn Код:
new connectString[128], rank[50];
        cache_get_field_content(0, "rank", rank);
        format(connectString, 128, "* %s %s (%d) has connected", getRank(rank), getPlayerName(playerid), playerid);
pawn Код:
stock getRank(rank[]) {
    if(strlen(rank) >= 2)
        return rank;
    new rankname[50];
    format(rankname, sizeof(rankname), "%s", ranks[strval(rank)]);
    return rankname;
}
(because I have not found a way to check if the value is an int or a string, I am just sending a string and checking the length)


Edit:
Changed this:

pawn Код:
stock getRank(rank[]) {
    if(strlen(rank) >= 2)
        return rank;
//  new rankname[50];
 // format(rankname, sizeof(rankname), "%s", ranks[strval(rank)]);
    return ranks[strval(rank)];
}
And that seems to work with an array like this:
pawn Код:
new ranks[][] = {
{"new guy"},
{"R2"}
};
It just doesn't return to its normal way but breaks off everything :/ Any thoughts on that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)