28.06.2013, 22:34
(
Last edited by JimmyCh; 26/07/2013 at 08:06 AM.
)
Hello everyone, well this is my first released script you can use.
I did this just now, and thought I could share it with you, since It can be helpful to some people.
So, you'll need to put these codes into your script for them to work.
This includes 8 types of music, which you can change the link of, of course.( PS: All songs go back to their respected owners, this is just a stream, just like streaming from the website itself.
If this causes any trouble, I kindly ask administrators to remove the URLs "if this causes any trouble." )
------------------------------------------------------------------------------------------------
So first of all, let's create the command which pops up a dialog for us to choose from.
The code is:
Let's explain it a bit.
First of all, we're popping up a dialog for the player which types the command: /radio.
He will find 8 genres of music from which he will chose and click on.
It will show up for him in the shape of a list.
But this ain't enough, we must put OnDialogReponse for this to work, else nothing will appear when he chooses one.
Now let's move on to OnDialogResponse, we got this code:
Now let's explain it a bit.
First we got the :
This is used to define that we're working on the dialogid 1499 which we used before when making the /radio command.
Now, we put if(response) to show that "If player chooses an item from the list".
Next we got the:
This means that if he chooses the first item in the list, an audio stream will play for player, with the above link.
A small text on the bottom right of the screen will appear saying: Dubstep On for 3 seconds.
The same goes for the other ones.
At last, we got the last item of the list:
As we put in the dialog, the last one was :Stop Stream.
Now behind that, we got this code.
So if player chooses that from the list, it will "StopAudioStreamForPlayer", which means stop playing the music, aswell as show him a text saying: Music off.
Put all this code under OnDialogResponse and it should work properly.
---------------------------------------------------------------------------------------------------
Anyway, hope this helped guys, this is my first tutorial.. If I helped you, leave some positive feedback and if you need more tutorials which I know how to do, I will surely make them for you guys.
Thanks again!
I did this just now, and thought I could share it with you, since It can be helpful to some people.
So, you'll need to put these codes into your script for them to work.
This includes 8 types of music, which you can change the link of, of course.( PS: All songs go back to their respected owners, this is just a stream, just like streaming from the website itself.
If this causes any trouble, I kindly ask administrators to remove the URLs "if this causes any trouble." )
------------------------------------------------------------------------------------------------
So first of all, let's create the command which pops up a dialog for us to choose from.
The code is:
PHP Code:
CMD:radio(playerid, params[])
{
ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_LIST, "Choose any type of music!", ">Dubstep\n>Blues\n>Metal\n>Jazz\n>POP\n>R&B\n>Rock\n>Country\n>>Stop Stream", "Choose", "Cancel");
return 1;
}
First of all, we're popping up a dialog for the player which types the command: /radio.
He will find 8 genres of music from which he will chose and click on.
It will show up for him in the shape of a list.
But this ain't enough, we must put OnDialogReponse for this to work, else nothing will appear when he chooses one.
Now let's move on to OnDialogResponse, we got this code:
PHP Code:
if(dialogid ==1499)
{
if(response)
{
if(listitem==0)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=40568");
GameTextForPlayer(playerid, "~r~Dubstep ~g~on", 3000, 1);
}
if(listitem==1)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1270282");
GameTextForPlayer(playerid, "~r~Blues ~g~on", 3000, 1);
}
if(listitem==2)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=212870");
GameTextForPlayer(playerid, "~r~Metal ~g~on", 3000, 1);
}
if(listitem==3)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=86433");
GameTextForPlayer(playerid, "~r~Jazz ~g~on", 3000, 1);
}
if(listitem==4)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=203280");
GameTextForPlayer(playerid, "~r~pop ~g~on", 3000, 1);
}
if(listitem==5)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=139386");
GameTextForPlayer(playerid, "~r~R&B ~g~on", 3000, 1);
}
if(listitem==6)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=19275");
GameTextForPlayer(playerid, "~r~Rock ~g~on", 3000, 1);
}
if(listitem==7)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=109008");
GameTextForPlayer(playerid, "~r~Country ~g~on", 3000, 1);
}
if(listitem==8)
{
StopAudioStreamForPlayer(playerid);
GameTextForPlayer(playerid, "~g~Music ~r~off", 3000, 1);
}
}
}
First we got the :
PHP Code:
if(dialogid ==1499)
{
if(response)
{
Now, we put if(response) to show that "If player chooses an item from the list".
Next we got the:
PHP Code:
if(listitem==0)
{
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=40568");
GameTextForPlayer(playerid, "~r~Dubstep ~g~on", 3000, 1);
}
A small text on the bottom right of the screen will appear saying: Dubstep On for 3 seconds.
The same goes for the other ones.
At last, we got the last item of the list:
PHP Code:
if(listitem==8)
{
StopAudioStreamForPlayer(playerid);
GameTextForPlayer(playerid, "~g~Music ~r~off", 3000, 1);
}
Now behind that, we got this code.
So if player chooses that from the list, it will "StopAudioStreamForPlayer", which means stop playing the music, aswell as show him a text saying: Music off.
Put all this code under OnDialogResponse and it should work properly.
---------------------------------------------------------------------------------------------------
Anyway, hope this helped guys, this is my first tutorial.. If I helped you, leave some positive feedback and if you need more tutorials which I know how to do, I will surely make them for you guys.
Thanks again!