SA-MP Forums Archive
enum expected token - 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: enum expected token (/showthread.php?tid=613069)



enum expected token - Mister0 - 24.07.2016

what iswrong here?

Код HTML:
enum
{
DIALOG_LOGIN,
DIALOG_REGISTER,
DIALOG_SEX,
DIALOG_AGE,
DIALOG_EMAIL
}
this enum have not name because i use on dialogresponse

ondialogresponse

switch(dialogid)
case DIALOG_LOGIN etc...


error 001: expected token: "-identifier-", but found "-integer value-"


Re: enum expected token - Vince - 24.07.2016

Nothing wrong with the enum itself. Show the surrounding code for OnDialogResponse.


Re: enum expected token - Mister0 - 24.07.2016

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    static 
string[500],strong[1500],string2[120];
    static 
named[30];
    
GetPlayerName(playerid,named,sizeof(named));
    if(    
strfind(inputtext"%"true) != -1  ||
           
strfind(inputtext"'"true) != -||
           
strfind(inputtext"`"true) != -||
           
strfind(inputtext";"true) != -)
     {
        
SCM(playerid,COLOR_RED,"don't use this characters!");
        return 
0;
    }
     switch(
dialogid)
    {
        case 
DIALOG_LOGIN:
        { 



Re: enum expected token - Mister0 - 24.07.2016

so what is the problem?


Re: enum expected token - K0P - 24.07.2016

I think its because you are not setting the value of the dialogs (dialogids)

Try doing it like this:

Код:
enum dialogs
{
DIALOG_LOGIN,
DIALOG_REGISTER,
DIALOG_SEX,
DIALOG_AGE,
DIALOG_EMAIL
}

new DialogID[dialogs];

DialogID[DIALOG_LOGIN] = 1 /*Any unique id*/;
DialogID[DIALOG_REGISTER] = 2 /*Any unique id*/;
DialogID[DIALOG_SEX] = 3 /*Any unique id*/;
DialogID[DIALOG_AGE] = 4 /*Any unique id*/;
DialogID[DIALOG_EMAIL] = 5 /*Any unique id*/;



Re: enum expected token - Deadpoop - 24.07.2016

Quote:
Originally Posted by K0P
Посмотреть сообщение
I think its because you are not setting the value of the dialogs (dialogids)

Try doing it like this:

Код:
enum dialogs
{
DIALOG_LOGIN,
DIALOG_REGISTER,
DIALOG_SEX,
DIALOG_AGE,
DIALOG_EMAIL
}

new DialogID[dialogs];

DialogID[DIALOG_LOGIN] = 1 /*Any unique id*/;
DialogID[DIALOG_REGISTER] = 2 /*Any unique id*/;
DialogID[DIALOG_SEX] = 3 /*Any unique id*/;
DialogID[DIALOG_AGE] = 4 /*Any unique id*/;
DialogID[DIALOG_EMAIL] = 5 /*Any unique id*/;
No need to set id''s because enum allready does that

DIALOG_LOGIN //= 0
DIALOG_REGISTER //= 1
...


Re: enum expected token - K0P - 24.07.2016

Quote:
Originally Posted by Deadpoop
Посмотреть сообщение
No need to set id''s because enum allready does that

DIALOG_LOGIN //= 0
DIALOG_REGISTER //= 1
...
What if you want to set the id to 100 or any other unique id to prevent dialog ids collision?
Read the post before commenting.Or take English learning classes if you can't understand basic sentences.

Quote:
Originally Posted by K0P
Посмотреть сообщение
/*Any unique id*/;



Re: enum expected token - J0sh... - 24.07.2016

Quote:
Originally Posted by K0P
Посмотреть сообщение
What if you want to set the id to 100 or any other unique id to prevent dialog ids collision?
Read the post before commenting.Or take English learning classes if you can't understand basic sentences.
You could just do enum { DIALOG_REGISTER = 100 }; then it'll increment.


Re: enum expected token - Konstantinos - 24.07.2016

Search for "#define DIALOG_LOGIN .." in your script and remove it (where .. is a number).

Quote:
Originally Posted by K0P
Посмотреть сообщение
What if you want to set the id to 100 or any other unique id to prevent dialog ids collision?
Read the post before commenting.Or take English learning classes if you can't understand basic sentences.
Collisions have nothing to do with compiling and the error he gets.


Re: enum expected token - K0P - 24.07.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Search for "#define DIALOG_LOGIN .." in your script and remove it (where .. is a number).



Collisions have nothing to do with compiling and the error he gets.
But it has a bad effect on dialogs that have responses.