Symbol already defined (variable) in OnDlgResponse
#1

Hello, I'm facing this issue, why I'm getting this error, why does variables overlaps here?

error 021: symbol already defined: "header"
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case D_QUIZ_START:
        {
            if(!response)
            {
                gs_OptionOpened[playerid] = false;
                SelectTextDraw(playerid, 0xFFFFFF75);
               
            }
            else
            {
                gs_CurrentQuizQuestion[playerid]++;


                new
                    header[32],
                    body[128],
                    question,
                    randomex[4][1],
                    j,
                    finalporadie[4],
                    temp
                ;
            }
        }
       
        case D_QUIZ_Q1:
        {
            if(!response)
            {
           
            }
            else
            {
                new
                                     header //ERROR LINE, it also happens even if I use name of any variable from first dialog
                         ;
                        }
        }
    }

    #if defined login_OnDialogResponse
        return login_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
    #else
        return 1;
    #endif
}
#if defined _ALS_OnDialogResponse
    #undef OnDialogResponse
#else
    #define _ALS_OnDialogResponse
#endif

#define OnDialogResponse login_OnDialogResponse
#if defined login_OnDialogResponse
    forward login_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
#endif
Reply
#2

It is already defined, remove the second new header.
Reply
#3

Use header1 instead of header, it's sems a bug on OnDialogResponse function which I myself got it too, if you removed it and used the defined one server will crash try it yourself
Reply
#4

So its not my script bug? Does it only occur in dialog response?
Reply
#5

Quote:
Originally Posted by Riwerry
Посмотреть сообщение
So its not my script bug? Does it only occur in dialog response?
Maybe... I am not sure

Try this code btw

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case D_QUIZ_START:
		{
			if(!response)
			{
				gs_OptionOpened[playerid] = false;
				SelectTextDraw(playerid, 0xFFFFFF75);
				
			}
			else
			{
				gs_CurrentQuizQuestion[playerid]++;


				new
					header_1[32],
					body[128],
					question,
					randomex[4][1],
					j,
					finalporadie[4],
					temp
				;
			}
		}
		
		case D_QUIZ_Q1:
		{
			if(!response)
			{
			
			}
			else
			{
				new
                                     header_2 //ERROR LINE, it also happens even if I use name of any variable from first dialog
			             ;
                        }
		}
	}

	#if defined login_OnDialogResponse
		return login_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
	#else
		return 1;
	#endif
}
#if defined _ALS_OnDialogResponse
	#undef OnDialogResponse
#else
	#define _ALS_OnDialogResponse
#endif

#define OnDialogResponse login_OnDialogResponse
#if defined login_OnDialogResponse
	forward login_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
#endif
Reply
#6

This is quite strange. Looks like it may be a compiler bug. If I move that header variable to the end of the list it suddenly starts working. Putting it any other places causes the bug.

Edit: the problem is this array:
PHP код:
randomex[4][1
Removing it, or its second dimension solves the bug. The second dimension is useless, anyway, because it only has 1 slot.
Reply
#7

Its a filterscript?
if(it is then)
{
define this after includes
Код:
#define FILTERSCRIPT
}
else
{
try this
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		new header[32];
		case D_QUIZ_START:
		{
			if(!response)
			{
				gs_OptionOpened[playerid] = false;
				SelectTextDraw(playerid, 0xFFFFFF75);

			}
			else
			{
				gs_CurrentQuizQuestion[playerid]++;


				new
					body[128],
					question,
					randomex[4][1],
					j,
					finalporadie[4],
					temp
				;
			}
		}

		case D_QUIZ_Q1:
		{
			if(!response)
			{

			}
			else
			{
                        }
		}
	}

	#if defined login_OnDialogResponse
		return login_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
	#else
		return 1;
	#endif
}
#if defined _ALS_OnDialogResponse
	#undef OnDialogResponse
#else
	#define _ALS_OnDialogResponse
#endif

#define OnDialogResponse login_OnDialogResponse
#if defined login_OnDialogResponse
	forward login_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
#endif
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)