22.06.2012, 09:40
Hello there, I will be showing how to create radio system using PlayAudioStreamForPlayer function in dialogs.
Alright so, lets start.
Alright so, lets start.
At the top of your script, add
pawn Код:
#include <a_samp>
pawn Код:
#define COLOR_BLUE 0xFFFFFF
pawn Код:
#define DIALOG1 9312 // You can choose any number
#define DIALOG2 9313
pawn Код:
if (strcmp("/playradio", cmdtext, true, 10) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) // You can remove this if you want, this means the radio won't start If you're not inside a vehicle.
{
SendClientMessage(playerid, COLOR_BLUE, "In-case you want to turn the radio on, you have to be in a vehicle!");
return 1;
}
ShowPlayerDialog(playerid, 9312, DIALOG_STYLE_LIST, "Radio Station", "Radio Channels\nTurn the music off", "Select", "Cancel"); // Now, we're using the first dialog, you can add any options you want, for example, I've added 'Radio Channels, and turn the music off.
return 1;
}
return 0;
}
pawn Код:
if(dialogid == 9313) // Here, we're gonna use the second dialog, which contains the radio channels
{
if(response)
{
if(listitem == 0)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0; // This means the distance that the player would be able to hear music
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.230:8002/listen.pls"); // Here, you can add any stream URL you'd like,
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 1)
{
new Float:X, Float:Y, Float:Z;// Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.229:8004/listen.pls");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 2)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.228:8002/listen.pls");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 3)
{
new Float:X, Float:Y, Float:Z;// Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.229:8006/listen.pls");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 4)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.229:8042/listen.pls");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 5)
{
new Float:X, Float:Y, Float:Z;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.225:8022/listen.pls");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 6)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://205.188.215.229:8040/listen.pls");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 7)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=357703");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 8)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1026951");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 9)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=2057543");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 10)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1543115");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 11)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=616366");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 12)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283516");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 13)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=737152");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 14)
{
new Float:X, Float:Y, Float:Z ;//Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=259629");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 15)
{
new Float:X, Float:Y, Float:Z;//, Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1193516");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
return 1;
}
if(listitem == 16)
{
new Float:X, Float:Y, Float:Z;//, Float:Distance = 10.0;
GetPlayerPos(playerid, X, Y, Z);
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1878");
SendClientMessage(playerid, COLOR_BLUE, "Music started!");
}
return 1;
}
}
if(dialogid == 9312)
{
if(response)
{
if(listitem == 0)
{
ShowPlayerDialog(playerid, 9313, DIALOG_STYLE_LIST, "Choose the channel you would like to listen!", "977 The Hitz Channel\n977 The 80s Channel\n181.FM - POWER 181\n1POWER\n108.FM - THE HITLIST\nChroniX Metal\nHOT 108 JAMZ\nSpart FM Tupac Channel\nAlex Jones FM\nFrench Kiss FM\nBlackBeat FM\nDEFJAY\nPower Hitz\nSky FM\nOld School 99\nTrance Channel\nIbiza Sonica", "Select", "Cancel"); // Here, you can add any channel you want, incase you have the streaming URL for it
}
if(listitem == 1)
{
StopAudioStreamForPlayer(playerid); // Now, this will turn the radio stream off, this means you won't be able to hear the streaming.
SendClientMessage(playerid, COLOR_BLUE, "Music off.");
}
return 1;
}
}
return 1;
}