SA-MP Forums Archive
error 039: constant symbol has no size - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: error 039: constant symbol has no size (/showthread.php?tid=446319)



error 039: constant symbol has no size - conor565 - 25.06.2013

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);
            }  
        }



Re: error 039: constant symbol has no size - Rokzlive - 25.06.2013

sizeof(PlayerInfo[playerid][pAdminName])


Re: error 039: constant symbol has no size - conor565 - 25.06.2013

Getting more errors now with that


Re: error 039: constant symbol has no size - SuperViper - 25.06.2013

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


Re: error 039: constant symbol has no size - conor565 - 25.06.2013

So like this?

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



Re: error 039: constant symbol has no size - introzen - 25.06.2013

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



Re: error 039: constant symbol has no size - conor565 - 25.06.2013

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);
            }  
        }



Re: error 039: constant symbol has no size - Vince - 25.06.2013

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);



Re: error 039: constant symbol has no size - Dragonsaurus - 25.06.2013

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);
        }
    }



Re: error 039: constant symbol has no size - conor565 - 27.06.2013

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.