#1

Hello guys, well is there any way to shorten the script? I mean the dialogs, it's annoying that I have to put for each one like this..
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 90: 
            if(!response)
            {
                    SendClientMessage(playerid, 0x42F3F198, "You canceled the dialog.");
                    return 1;
            }

            switch(listitem)
            {
                case 0:
                {
                    PlayAudioStreamForPlayer(playerid, "http://radio02-cn3.akadostream.ru:8814/nrj192.mp3");
                    SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming."); 
                }
                case 1:
                {
                    PlayAudioStreamForPlayer(playerid, "http://stream.radioactivity.fm:8002/");
                    SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");
                }
            }
        }
    }
    return 1;
}
Is there any way to make the dialogs not spend un-necesary code needed? I want to short it up.

Код:
Example
if(response)
	    {
	        case 0: return SendClientMessage(playerid, COLOR_RED, "BLA!");
	        return 1;
		}
Reply
#2

You can define the dialog IDs, it may be easier to read the code this way.

Just do:

pawn Код:
#define DIALOG_TEST 1
// You define the dialog and then the 1 is the dialog ID
ShowPlayerDialog(playerid, DIALOG_TEST, DIALOG_STYLE_MSG, "This is a test!", "Next", "Close");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
     switch(dialogid)
     {
          case DIALOG_TEST:
          {
                //CODE HERE
          }
     }
     return 1;
}
Reply
#3

I am not asking for that, I am just wondering if there is a way to short the code up when it comes to the cases. Example I want of it to be

case 0: return PlayAudioStreamForPlayer(playerid, "link...");
Reply
#4

You can do something like this:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 90:
        {
            if(!response) return SendClientMessage(playerid, 0x42F3F198, "You canceled the dialog.");
            switch(listitem)
            {
                case 0: PlayAudioStreamForPlayer(playerid, "http://radio02-cn3.akadostream.ru:8814/nrj192.mp3"), SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");
                case 1: PlayAudioStreamForPlayer(playerid, "http://stream.radioactivity.fm:8002/"), SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");
            }
        }
    }
    return 1;
}
Reply
#5

Hmm yeah, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)