Array sizes do not match
#1

Hey,

Error:
pawn Код:
array sizes do not match, or destination array is too small

Line:
pawn Код:
PlayerInfo[playerid][Job]="Mechanic";
Seriously,what is wrong?
Reply
#2

pawn Код:
format(PlayerInfo[playerid][Job],sizeof(PlayerInfo[playerid][Job]),"%s","Mechanic");
Make sure 'Job' is a string, if it's not, it won't work.
Reply
#3

pawn Код:
format(PlayerInfo[playerid][Job], sizeof(PlayerInfo[playerid][Job]), "Mechanic");
Might not be the best solution, but unless you provide us your enum definitions, I can't state much more.
Reply
#4

Here is my enum:
pawn Код:
enum pInfo
{
    userid,
    username[128],
    pPass[128],
    alevel,
    money,
    level,
    SkinID,
    Leader[32],
    Job[32]
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Yea, i though of format myself...just didn't want to use it. Is there a better way?
Reply
#5

Quote:
Originally Posted by dusk
Посмотреть сообщение
Yea, i though of format myself...just didn't want to use it. Is there a better way?
Well, according to your enum the ways stated above should work and seem to be the best ones to use. I do not know of any way to set this with ="...";

What's so bad in using format? ^^
Reply
#6

I suggest you use 'Job' as a integer, and make the mechanic job for example, number 1. Then to check the job, just do
pawn Код:
if(PlayerInfo[playerid][Job] == 1) {
//code
}
Reply
#7

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
What's so bad in using format? ^^
I've heard format is slower than other methods for formating a string.
Reply
#8

Exactly,i heard that as well.

Anyway,this topic is done. I used Jari's suggestion. Thank you all!
Reply
#9

should use the numbers
pawn Код:
if(PlayerInfo[playerid][Job] == 1)
{

}
etc.
Reply
#10

I like the number idea but that is really bad practice to do it in such a direct manner use #define define your jobs then reference them that way.

#define JOB_MECHANIC 1
#define JOB_GUNDEALER 2
#define JOB_DRUGDEALER 3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)