Need Help - #define Dialog -
Vaishnav - 20.06.2015
Hi my problem is when I am defining dialogs it's giving me errors I don't why it's happening I've checked that dialog id's aren't crossing each other I mean dialog ids are not same. I have just three dialogs I don't know why it's happening
here is the code
pawn Код:
#define DIALOG_HOUSE 9000
#define DIALOG_pCMDS 9001
#define DIALOG_vCMDS 9002
Errors
pawn Код:
C:\Users\PC\Desktop\Samp-server\gamemodes\star.pwn(15486) : error 040: duplicate "case" label (value 9002)
C:\Users\PC\Desktop\Samp-server\gamemodes\star.pwn(15579) : error 040: duplicate "case" label (value 9001)
C:\Users\PC\Desktop\Samp-server\gamemodes\star.pwn(15590) : error 040: duplicate "case" label (value 9002)
// Ondialogresponse
pawn Код:
case DIALOG_pCMDS:
{
if ( !response )
return 1;
ShowPlayerDialog( playerid, DIALOG_pCMDS+1, DIALOG_STYLE_MSGBOX, ""NAME_S" "GRI"Player Commands Page "O"#2", CMDS_Page_2( ), "(Back)", "(Close)" );
return ( 1 );
}
case DIALOG_pCMDS+1:
{
if (!response)
return 1;
ShowPlayerDialog(playerid, DIALOG_pCMDS, DIALOG_STYLE_MSGBOX, ""NAME_S" "GRI"Player Commands Page "O"#1", CMDS_Page_1( ), "(Next)", "(Close)");
return ( 1 );
}
case DIALOG_vCMDS+1:
{
if ( !response )
return 1;
ShowPlayerDialog( playerid, DIALOG_vCMDS, DIALOG_STYLE_MSGBOX, ""NAME_S" "GRI"Vehicle Commands Page "O"#1", VCMDS_Page_1( ), "(Next)", "(Close)" );
return ( 1 );
}
case DIALOG_vCMDS:
{
if ( !response )
return 1;
ShowPlayerDialog( playerid, DIALOG_vCMDS+1, DIALOG_STYLE_MSGBOX, ""NAME_S" "GRI"Vehicle Commands Page "O"#2", VCMDS_Page_2( ), "(Back)", "(Close)" );
return ( 1 );
}
case DIALOG_HOUSE+1:
{
if(!response) return 1;
new id = GetPVarInt(playerid, "PickupHouseID");
if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
if(!(1 <= strlen(inputtext) <= MAX_HOUSE_PASSWORD)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+1, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:\n\n{E74C3C}The password you entered is either too short or too long.", "Try Again", "Close");
if(strcmp(HouseData[id][Password], inputtext)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+1, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:\n\n{E74C3C}Wrong password.", "Try Again", "Close");
SendToHouse(playerid, id);
return 1;
}
Re: Need Help - #define Dialog -
Banana_Ghost - 20.06.2015
DIALOG_pCMDS+1
DIALOG_vCMDS+1
DIALOG_HOUSE+1
You're +1'ing them, which just adds 1 to them. It's causing them to collide with the other dialog ids (sorry if this isn't worded correctly).
Define a new name for all of those +1's and use that defined name instead.
Re: Need Help - #define Dialog -
Vaishnav - 20.06.2015
no not working... still giving errors
Re: Need Help - #define Dialog -
Gammix - 20.06.2015
pawn Код:
#define DIALOG_HOUSE 9000
#define DIALOG_pCMDS 9001
#define DIALOG_vCMDS 9002
Its simple, adding 1 to
DIALOG_pCMDS will be
9002 which is defiend as
DIALOG_vCMDS. So thats why when you use them in switch, they collide.
Just increase the gap between the numbers, gap depends on how much you add to them.
According to the given code, this would work properly:
pawn Код:
#define DIALOG_HOUSE 9000
#define DIALOG_pCMDS 9001
#define DIALOG_vCMDS 9005
Re: Need Help - #define Dialog -
Vaishnav - 20.06.2015
ok thanks gammix bro I will try it out
Re : Need Help - #define Dialog -
Dutheil - 20.06.2015
I advise you to use "enum" for that.
Re: Need Help - #define Dialog -
Vaishnav - 20.06.2015
Solved
Thanks everyone for the help specially Gammix thank u so much brother
+rep