This is the radio script i use.
PHP код:
#include <a_samp>
#include <zcmd>
#define RADIO 3000
#define COLOR_YELLOW 0xDABB3EAA
#define COLOR_GREEN 0x9EC73DAA
new Radio[MAX_PLAYERS];
new Radio1[MAX_PLAYERS];
new Radio2[MAX_PLAYERS];
new Radio3[MAX_PLAYERS];
new Radio4[MAX_PLAYERS];
new Radio5[MAX_PLAYERS];
new Radio6[MAX_PLAYERS];
new Radio7[MAX_PLAYERS];
new Radio8[MAX_PLAYERS];
new Radio9[MAX_PLAYERS];
new Radio10[MAX_PLAYERS];
new Radio11[MAX_PLAYERS];
new Radio12[MAX_PLAYERS];
new Radio13[MAX_PLAYERS];
new Radio14[MAX_PLAYERS];
CMD:radio(playerid, params[])
{
ShowPlayerDialog(playerid, RADIO, DIALOG_STYLE_LIST, "Real Online Radio", "{007DFF}0 - Classic Rock\n{007DFF}1 - Pop\n{007DFF}2 - Dubstep\n{007DFF}3 - CLassical\n{007DFF}4 - Reggae\n{007DFF}5 - Infowars(Real Talk)\n{007DFF}6 - Comedy\n{007DFF}7 - Jazz\n{007DFF}8 - New Hip Hop\n{007DFF}9 - New Metal\n{007DFF}10 - Old School Metal\n{007DFF}11 - Classic Alternative\n{007DFF}12 - Russian\n{007DFF}13 - Old School Rap\n{007DFF}14 - Jungle\n{007DFF}[STOP RADIO]", "Okay", "Exit");
SendClientMessage(playerid,COLOR_GREEN,"Pick your radio station");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == RADIO)
{
if(response)
{
if(listitem == 0)// (1-Classic Rock)
{
Radio[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=49731");
}
if(listitem == 1)// (2-Pop)
{
Radio1[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283896");
}
if(listitem == 2)// (3-Dubstep)
{
Radio2[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=148196");
}
if(listitem == 3)// (4-CLassical)
{
Radio3[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=22146");
}
if(listitem == 4)// (5-Reggae)
{
Radio4[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1654897");
}
if(listitem == 5)// (6-Infowars(Real talk))
{
Radio5[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1026951");
}
if(listitem == 6)// (7-Comedy)
{
Radio6[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=212920");
}
if(listitem == 7)// (8-Jazz)
{
Radio7[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=9486735");
}
if(listitem == 8)// (9-New Hip Hop)
{
Radio8[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=32999");
}
if(listitem == 9)// (10-New Metal)
{
Radio9[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=545492");
}
if(listitem == 10)// (11-Old School Metal)
{
Radio10[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=558051");
}
if(listitem == 11)// (12-Classic Alternative)
{
Radio11[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=99169508");
}
if(listitem == 12)// (13-Russian)
{
Radio12[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=9495657");
}
if(listitem == 13)// (14-Old School Rap)
{
Radio13[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=210543");
}
if(listitem == 14)// (14-Jungle)
{
Radio14[playerid] = PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1531712");
}
if(listitem == 15)// (STOP RADIO)
{
StopAudioStreamForPlayer(playerid);
}
}
}
return 1;
}
To use PlayAudioStreamForPlayer i go to shoutcast.com and search for a station I like. To listen to the station I go to HELP - settings on the shoutcast page and select "Play SHOUTcast stations in SHOUTcast web player". Then to download the link for the stations I go to HELP - settings on the shoutcast page and select "Play SHOUTcast stations in default media player". Then finally I look at my downloads and copy paste the station URL into the correct place in PlayAudioStreamForPlayer like this:
PHP код:
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=49731");
You can use PlayAudioStreamForPlayer anywhere that has a playerid or similar (killerid, damagedid, etc.), this will play the stream for the player at the same volume no matter where he is.
Or you can set the x, y, z, positions and range of the audio stream.
More help?
https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer