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

pawn Код:
CMD:forumname(playerid, params[])
{
    new forumname[32], fstring[126],s_forumname[32];
    if(sscanf(params, "s[32]", forumname)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /forumname [name]");
    format(s_forumname, 32, "%s", forumname);
    PlayerInfo[playerid][pForum] = s_forumname; //error line
    format(fstring, sizeof(fstring), "You have set your forum name to: %s", s_forumname);
    SCM(playerid, COLOR_YELLOW, fstring);
    return 1;
}
Reply
#2

Given the fact that '[pForum]' variable is (or it should be) a string, you can't just change it's value like that. You need to format the string, like below:

pawn Код:
CMD:forumname(playerid, params[])
{
    new forumname[32], fstring[126],s_forumname[32];
    if(sscanf(params, "s[32]", forumname)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /forumname [name]");
    format(s_forumname, 32, "%s", forumname);
    format(PlayerInfo[playerid][pForum], sizeof PlayerInfo[playerid][pForum], "%s", s_forumname);
    //PlayerInfo[playerid][pForum] = s_forumname; //error line
    format(fstring, sizeof(fstring), "You have set your forum name to: %s", s_forumname);
    SCM(playerid, COLOR_YELLOW, fstring);
    return 1;
}
Try and see if it works.

If not, please share where you created the 'PlayerInfo[playerid][pForum]' variable.
Reply
#3

PlayerInfo[playerid][pForum] should have 32 lenght as well in order to work. It's possible to copy strings like that if the lenght are same to both of them. If I were you, then I would copy the string with:
pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest)
{
    strcat((dest[0] = EOS, dest), source, maxlength);
}
pawn Код:
strcpy(PlayerInfo[playerid][pForum], s_forumname);
PS: format is too slow, try using other methods such as strins for example!
Reply
#4

I'll edit with results.
EDIT:
I only see the first letter I write.
I'll give you everything related to the variable.

Saving:
pawn Код:
format(query, sizeof(query), "UPDATE `users` SET `forum` = %s WHERE `name` = '%s'",
        PlayerInfo[playerid][pForum],
        GetName(playerid));
        mysql_function_query(dbHandle, query, false, "", "");
Loading:
pawn Код:
cache_get_row(0, 97, PlayerInfo[playerid][pForum], dbHandle, 24);
CMD:
pawn Код:
CMD:forumname(playerid, params[])
{
    new forumname[24], fstring[126],s_forumname[24];
    if(sscanf(params, "s[24]", forumname)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /forumname [name]");
    format(s_forumname, 24, "%s", forumname);
    format(PlayerInfo[playerid][pForum], 24, "%s", s_forumname);
    format(fstring, sizeof(fstring), "You have set your forum name to: %s", s_forumname);
    SCM(playerid, COLOR_YELLOW, fstring);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)