error 039: constant symbol has no size
#1

Hi I added a system that when a new admin is made that it will open the dialog and he/she can select their admin name. There is the error 039: constant symbol has no size error on the dialog response code

pawn Код:
else if(dialogid == DIALOG_ANAME) {
        if(!response) ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
            else
            {
                new
                    szString[100];
           
                if(isnull(inputtext))
                    return ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
               
                format(PlayerInfo[playerid][pAdminName], sizeof(pAdminName), "%s", inputtext);
                format(szString, sizeof(szString), "You have set your admin name to %s.", PlayerInfo[playerid][pAdminName]);
                SendClientMessage(playerid, -1, szString);
            }  
        }
Reply
#2

sizeof(PlayerInfo[playerid][pAdminName])
Reply
#3

Getting more errors now with that
Reply
#4

You can't get the size of an enum variable because enums aren't the same as arrays. Just use MAX_PLAYER_NAME.
Reply
#5

So like this?

pawn Код:
format(PlayerInfo[playerid][pAdminName], sizeof(PlayerInfo[MAX_PLAYER_NAME][pAdminName]), "%s", inputtext);
Reply
#6

pawn Код:
format(PlayerInfo[playerid][pAdminName], sizeof(PlayerInfo[playerid][MAX_PLAYER_NAME]), "%s", inputtext);
Reply
#7

Still getting these errors:

error 001: expected token: "]", but found "-identifier-"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line


Here is the full response code again:

pawn Код:
else if(dialogid == DIALOG_ANAME) {
        if(!response) ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
            else
            {
                new
                    szString[100];
           
                if(isnull(inputtext))
                    return ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
               
                format(PlayerInfo[playerid][pAdminName], sizeof(PlayerInfo[playerid][MAX_PLAYER_NAME]), "%s", inputtext);
                format(szString, sizeof(szString), "You have set your admin name to %s.", PlayerInfo[playerid][pAdminName]);
                SendClientMessage(playerid, -1, szString);
            }  
        }
Reply
#8

pawn Код:
format(PlayerInfo[playerid][pAdminName], MAX_PLAYER_NAME, "%s", inputtext);
Though using format to copy strings is a bad practice. Use strcat/strcpy instead.
pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest)
    strcat((dest[0] = EOS, dest), source, maxlength);

strcpy(PlayerInfo[playerid][pAdminName], inputtext, MAX_PLAYER_NAME);
Reply
#9

I just tested it and it turned to be like this: (No errors)
pawn Код:
if(dialogid == DIALOG_ANAME)
    {
        if(!response) ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
        else
        {
            new szString[100];
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
            format(PlayerInfo[playerid][pAdminName], 24, "%s", inputtext);
            format(szString, sizeof(szString), "You have set your admin name to %s.", PlayerInfo[playerid][pAdminName]);
            SendClientMessage(playerid, -1, szString);
        }
    }
Reply
#10

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
I just tested it and it turned to be like this: (No errors)
pawn Код:
if(dialogid == DIALOG_ANAME)
    {
        if(!response) ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
        else
        {
            new szString[100];
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2818, DIALOG_STYLE_INPUT, "Admin Name - Create", "Please enter your desired admin name in the box below.", "Submit", "");
            format(PlayerInfo[playerid][pAdminName], 24, "%s", inputtext);
            format(szString, sizeof(szString), "You have set your admin name to %s.", PlayerInfo[playerid][pAdminName]);
            SendClientMessage(playerid, -1, szString);
        }
    }
Sorry for late reply was busy, thanks very much, worked a charm.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)