Array out of bounds; Referencing enum problem?
#1

pawn Код:
enum pStats{
    Money,
    Level,
    Admin,
    Password[128],
}
new PlayerStats[MAX_PLAYERS][pStats],Car[MAX_PLAYERS];
pawn Код:
forward LoadAccount(playerid);
public LoadAccount(playerid)
{
    new Player[MAX_PLAYER_NAME],File[128];
    GetPlayerName(playerid, Player, sizeof(Player) );
    format(File,sizeof(File),"\\Accounts\\%s.ini", Player);

    PlayerStats[playerid][Password] = dini_Get(File,"Password");
    return 1;

}
Код:
../NGZ/Functions.pwn(143) : error 047: array sizes do not match, or destination array is too small
It's hashed, but it's hashed as a string, i.e = including letters and symbols, I might just use whirlpool and an int.
Reply
#2

pawn Код:
enum pStats{
    Money,
    Level,
    Admin,
    Password[128] // no need to add the , here
};
or this
pawn Код:
PlayerStats[playerid][Password] = (dini_Get(File,"Password"));
not sure
Reply
#3

If i'm not mistaken, I think you need a size of 129.

@DaTa[X] the extra "," character won't cause any problems in a enum
Reply
#4

pawn Код:
new newpass[64];
pawn Код:
format(newpass,sizeof(newpass),"%s",inputtext);
pawn Код:
dini_Set(File,"Password",newpass);
pawn Код:
PlayerStats[playerid][Password] = dini_Get(File,"Password");
Код:
../NGZ/Functions.pwn(143) : error 047: array sizes do not match, or destination array is too small
Password in the enum is now [135], same problem.
Reply
#5

OK guys, dini_Get returns a string. You cant (like other languages) just do this:

pawn Код:
new string[55], stringtest[56];
string = "hello";
stringtest = string;
It just doesn't work. You have to use a function like format, or strcat or the following function (made by ******):

pawn Код:
#define strcpy(%0,%1,%2) \
    strcat((%0[0] = '\0', %0), %1, %2) //Top of your code
    strcpy(PlayerStats[playerid][Password], dini_Get(File,"Password"), 128);
Reply
#6

Interesting, thanks for that, I actually increased the string size to 256 and it copied without complains but I don't want the memory implications later on, I'll give the strcpy a go, thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)