Error 047 on a return statement?! -
mamorunl - 08.09.2012
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.
Re: Error 047 on a return statement?! -
MP2 - 08.09.2012
Change [8][100] to [] [] - which will let the pawn compiler determine how big the array is based on what data is in there.
Re: Error 047 on a return statement?! -
mamorunl - 08.09.2012
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
Re: Error 047 on a return statement?! - HuSs3n - 08.09.2012
what are you trying to return
//edit:
try this
pawn Код:
new rankname[50];
format(rankname, sizeof(rankname), "%s", ranks[0]); //
return rankname;
Re: Error 047 on a return statement?! - Guest3598475934857938411 - 08.09.2012
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.
Re: Error 047 on a return statement?! -
mamorunl - 08.09.2012
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?