21.03.2011, 02:09
(
Last edited by PCheriyan007; 31/07/2012 at 01:31 AM.
Reason: SA-MP 0.3d added native Audio functionality.
)
How to Stream Shoutcast to your Server
By Sc0pe
I have heard some players wanted to know how to add Shoutcast streaming to their server so I made this little tutorial.By Sc0pe
What Will You Need
- AT LEAST SA-MP 0.3d (Current version is 0.3e)
- A Shoutcast Server (Don't fret if you don't have one, you can use just about any internet radio station)
The Code
So here is the code we will be looking at:pawn Code:
#include <a_samp>
#include <zcmd>
CMD:radio(playerid, params[])
{
PlayAudioStreamForPlayer(playerid, "http://www.internetradio.com/listen.pls");
SendClientMessage(playerid, 0x33CCFFAA, "(SERVER) {FFFFFF}Connecting to [NAME OF STATION]");
return 1;
}
CMD:stopradio(playerid, params[])
{
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, 0x33CCFFAA, "(SERVER) {FFFFFF}Audio stream playback has been stopped");
return 1;
}
Explanation
Now I will explain what each little piece of code does.PlayAudioStreamForPlayer
pawn Code:
PlayAudioStreamForPlayer(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0);
Stream URLs can look like the following: Below is a proper example of this code:
pawn Code:
PlayAudioStreamForPlayer(playerid, "http://www.internetradio.com/listen.pls");
pawn Code:
StopAudioStreamForPlayer(playerid);
Command Explanations
/startradio Explanationpawn Code:
CMD:radio(playerid, params[])
pawn Code:
PlayAudioStreamForPlayer(playerid, "http://www.internetradio.com/listen.pls");
pawn Code:
SendClientMessage(playerid, 0x33CCFFAA, "(SERVER) {FFFFFF}Connecting to [NAME OF STATION]");
/stopradio Explanation
pawn Code:
CMD:stopradio(playerid, params[])
pawn Code:
StopAudioStreamForPlayer(playerid);
pawn Code:
SendClientMessage(playerid, 0x33CCFFAA, "(SERVER) {FFFFFF}Audio stream playback has been stopped");
Final Notes
NOTE: If you want to make a Shoutcast Server for free, use one of the following:NOTE: For those wondering where they can find zcmd, look no further.