SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 21/03/2011, 02:09 AM   #1
PCheriyan007
Huge Clucker
 
Join Date: May 2010
Location: in hiding
Posts: 305
Reputation: 6
Lightbulb [UPDATED] How to stream Shoutcast to your server

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.

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);
This starts the audio stream that is typed in the place of url[].
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");

StopAudioStreamForPlayer
pawn Code:
StopAudioStreamForPlayer(playerid);
This stops the audio stream that was playing (if one was playing).

Command Explanations

/startradio Explanation
pawn Code:
CMD:radio(playerid, params[])
This is the command that we are going to use to start the audio stream.

pawn Code:
PlayAudioStreamForPlayer(playerid, "http://www.internetradio.com/listen.pls");
This is the audio stream which we are going to use as our radio. You need to change the example URL to the URL of the stream to your preferred radio station.

pawn Code:
SendClientMessage(playerid, 0x33CCFFAA, "(SERVER) {FFFFFF}Connecting to [NAME OF STATION]");
This notifies the player that they are connecting to the stream and the audio should start playing shortly. You need to replace [NAME OF STATION with the name of the radio station that you will be using.

/stopradio Explanation
pawn Code:
CMD:stopradio(playerid, params[])
This is the command that we are going to use to stop streaming the radio.

pawn Code:
StopAudioStreamForPlayer(playerid);
This will stop the streaming of audio.

pawn Code:
SendClientMessage(playerid, 0x33CCFFAA, "(SERVER) {FFFFFF}Audio stream playback has been stopped");
This will let the player know that the audio stream has 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.
__________________

Code:
[Filterscripts]
Nothing So Far
[Tutorials]
How to use SQLite (by Zh3r0)
How to stream Shoutcast to your server
[Current Project]
[DR]Drifting Roaches (Server)

Last edited by PCheriyan007; 31/07/2012 at 01:31 AM. Reason: SA-MP 0.3d added native Audio functionality.
PCheriyan007 is offline   Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Your favorite radio stations (shoutcast) Ivan_Pantovic Everything and Nothing 20 17/02/2011 02:25 PM
Integrated SHOUTcast Server Ehm-Dee Help Archive 6 27/12/2010 01:19 AM
How do you stream mods into server ? -CnR-Leonardo Server Support 1 15/02/2010 02:10 PM
Hello I have a question if vresiuea server and go on Mido Stream 0.3A KeEpEr Help Archive 2 17/12/2009 12:23 PM
car stream z bug ? c-middia Help Archive 6 16/09/2009 11:14 AM


All times are GMT. The time now is 03:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.