[Tutorial] DIALOGS - How to stream music.
#1

Information:

Hello everyone. I am making a simple, clean tutorial, on how to stream music.
This tutorial will have two parts (ways).

1- You paste the link into a box.
2- You choose from a list.

Let's start!

Part 1 (Paste link)

We will make a simple command. /streamaudiol [l = link]
(You can convert this into zcmd - dcmd)

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/streamaudiol", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Audio streaming!", "Please paste the link down here.", "Play", "Cancel");
        /* 1 is the Dialog's id
        DIALOG_STYLE_INPUT is the box where you can type things.*/

        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response) // If you clicked Play not Cancel
    {
        switch(dialogid) // We are going to add more dialogs, so that's why we use this
        {
            case 1: // <- Our audio streaming with link dialog ID!
            {
                PlayerAudioStreamForPlayer(playerid, inputtext); // inputtext = the text we entered, which means the link we're gonna pase
            }
        }
    }
    return 1;
}
Part 2 (Choose between songs)

Now we will make another simple command. /audiostream

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/streamaudio", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Audio streaming!", "Master of puppets\nHighway to hell", "Play", "Cancel"); // "\n" means new line.
        /* 2 is the Dialog's id
        DIALOG_STYLE_LIST is the box where you choose between items / things.*/

        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response) // If you clicked Play not Cancel
    {
        switch(dialogid) // We are going to add more dialogs, so that's why we use this
        {
            case 2: // <- Our audio streaming with link dialog ID!
            {
                case 0: // If he clicked Master of puppets (song 1)
                {
                    PlayAudioStreamForPlayer(playerid,"http://www.dreammedia.ru/music/Metallica/(1985)Master%20Of%20Puppets/02%20-%20Master%20of%20puppets.mp3"); // That's the link for Master of puppets
                }
                case 1: // If we clicked Highway to hell (song 2)
                {
                    PlayAudioStreamForPlayer(playerid,"http://mymusic.ge/upload/music/67cd6239-4af4-4059-850d-0b0f001a6fc8.mp3"); // same as above, link for highway to hell
                }
            }
        }
    }
    return 1;
}
NOTES:

NOTE 1:

If you want to stream music for ALL players, change what I did to this.

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    PlayAudioStreamForPlayer(i,inputtext); // Inputtext or the link between " " like in part 2.
}
NOTE 2:

If you have any problem please post them here, with your code.
Also, you can convert them into ZCMD or dcmd (or whatever)

NOTE 3:

You need to have radio volume to the highest line in your settings menu, or else, you wont hear the music.
Reply


Messages In This Thread
DIALOGS - How to stream music. - by Stinged - 08.11.2013, 09:01
Re: DIALOGS - How to stream music. - by Akira297 - 08.11.2013, 09:11

Forum Jump:


Users browsing this thread: 1 Guest(s)