array sizes do not match or destination array is too small -
skaman44 - 23.07.2013
I keep getting this error:
error 047: array sizes do not match, or destination array is too small
here is the code for it:
CMD: setadminname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
new string[128], newname[15];
//This is the line that is getting the error
if(sscanf(params, "s", newname)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setadminanme <name>");
PlayerInfo[playerid][pAdminName] = newname;
format(string, sizeof(string), "You set your admin name to %s", newname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to use this command!");
return 1;
}
Any help would be much appreciated
Re: array sizes do not match or destination array is too small -
ThePhenix - 23.07.2013
Max Player Name string is 24.
So change it to:
newname[24]; or MAX_PLAYER_NAME
Re: array sizes do not match or destination array is too small -
ToiletDuck - 23.07.2013
pawn Код:
CMD: setadminname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
new string[128], newname[15]; //This is the line that is getting the error
if(sscanf(params, "s[15]", newname)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setadminanme <name>");
PlayerInfo[playerid][pAdminName] = newname;
format(string, sizeof(string), "You set your admin name to %s", newname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
else SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to use this command!"); // remove the return this should be fix.
return 1;
}
Re: array sizes do not match or destination array is too small -
skaman44 - 23.07.2013
thank you
Re: array sizes do not match or destination array is too small -
ReVo_ - 23.07.2013
If you want to do this:
PlayerInfo[playerid][pAdminName] = newname;
pAdminName size and newname size should be the same.
Max player name is 24, so make sure you used 24 in pAdminName and change newname size.