17.03.2013, 08:27
I'm just wondering what switch statements actually do, I never really knew. I'll be using a lot of dialogs in my next game mode, and maybe they can be useful.
Thank you.
Thank you.
new
a = 5;
switch (a)
{
case 1:
{
// Won't be called
}
case 2:
{
// Won't be called
}
case 5:
{
// Will be called
}
default:
{
// Won't be called
}
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == MAIN_DIALOG && response)
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid,IN_WEAPONS, DIALOG_STYLE_LIST, "Weapons","Option 1\nOption 2","Select","Return");
}
case 1:
{
ShowPlayerDialog(playerid,IN_TELEPORTS, DIALOG_STYLE_LIST, "Teleports","Option1\nOption 2","Select","Return");
}
}
}
if(dialogid == IN_WEAPONS)
{
switch(listitem)
{
case 0:
{
if(!response) return ShowPlayerDialog(playerid, MAIN_DIALOG, DIALOG_STYLE_LIST, "Main Dialog.", "Weapons\nTeleports","Select","Cancel");
SendClientMessage(playerid, -1, "You selected option 1.");
}
case 1:
{
if(!response) return ShowPlayerDialog(playerid, MAIN_DIALOG, DIALOG_STYLE_LIST, "Main Dialog.", "Weapons\nTeleports","Select","Cancel");
SendClientMessage(playerid, -1, "You selected option 2.");
}
}
}
if(dialogid == IN_TELEPORTS)
{
switch(listitem)
{
case 0:
{
if(!response) return ShowPlayerDialog(playerid, MAIN_DIALOG, DIALOG_STYLE_LIST, "Main Dialog.", "Weapons\nTeleports","Select","Cancel");
SendClientMessage(playerid, -1, "You selected option 1.");
}
case 1:
{
if(!response) return ShowPlayerDialog(playerid, MAIN_DIALOG, DIALOG_STYLE_LIST, "Main Dialog.", "Weapons\nTeleports","Select","Cancel");
SendClientMessage(playerid, -1, "You selected option 2.");
}
}
}
return 1;
}