SA-MP Forums

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

Reply
 
Thread Tools Display Modes
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
Old 21/03/2011, 01:34 PM   #2
Vukilore
High-roller
 
Vukilore's Avatar
 
Join Date: Jan 2011
Posts: 3,055
Reputation: 96
Default Re : How to stream Shoutcast to your server

Oh God, Good job !
Vukilore is offline   Reply With Quote
Old 21/03/2011, 02:20 PM   #3
alpha500delta
High-roller
 
alpha500delta's Avatar
 
Join Date: Feb 2010
Posts: 1,301
Reputation: 91
Default Re: How to stream Shoutcast to your server

And this is supposed to be a tutorial?
__________________
Skype: Alpha500delta | Steam: Alpha500delta
alpha500delta is offline   Reply With Quote
Old 22/03/2011, 01:34 AM   #4
PCheriyan007
Huge Clucker
 
Join Date: May 2010
Location: in hiding
Posts: 305
Reputation: 6
Default Re: How to stream Shoutcast to your server

Quote:
Originally Posted by alpha500delta View Post
And this is supposed to be a tutorial?
Well for one thing I show how to add it, then I explain what each line does.
__________________

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)
PCheriyan007 is offline   Reply With Quote
Old 22/03/2011, 08:41 AM   #5
Ironboy
High-roller
 
Ironboy's Avatar
 
Join Date: Nov 2010
Location: United Arab Emirates
Posts: 1,669
Reputation: 368
Default Re: How to stream Shoutcast to your server

I did everything but i cant hear anything
It shows "Connected to [Name of the Radio station goes here]".
__________________
Ironboy is offline   Reply With Quote
Old 22/03/2011, 09:35 AM   #6
Michael@Belgium
High-roller
 
Michael@Belgium's Avatar
 
Join Date: Dec 2010
Location: Belgium
Posts: 2,502
Reputation: 836
Default Re: How to stream Shoutcast to your server

Nice tut but i don't understand something...
Euhm, what do you mean with 'A Shoutcast server' ? It's like a radio on internet ? :S
Michael@Belgium is offline   Reply With Quote
Old 23/03/2011, 07:34 AM   #7
Pz
Banned
 
Join Date: Mar 2011
Posts: 79
Reputation: 0
Default Re: How to stream Shoutcast to your server

One day, SA-MP will be just like Ventrilo, I have big feelings about it.
Pz is offline   Reply With Quote
Old 23/03/2011, 02:59 PM   #8
PCheriyan007
Huge Clucker
 
Join Date: May 2010
Location: in hiding
Posts: 305
Reputation: 6
Default Re: How to stream Shoutcast to your server

Ironboy - PM me how you put in the code and I will see what is wrong and if there is nothing wrong with the code then it could either be that you didn't install the audio client plugin or that you might have a slow connection.

Michael@Belgium - Yeah like a shoutcast radio station.

Pz - you have a very good point .
__________________

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)
PCheriyan007 is offline   Reply With Quote
Old 24/04/2011, 08:20 PM   #9
Csaba1996
Little Clucker
 
Join Date: Dec 2010
Posts: 2
Reputation: 0
Default Re: How to stream Shoutcast to your server

help 15 error:S
Csaba1996 is offline   Reply With Quote
Old 24/04/2011, 09:43 PM   #10
PCheriyan007
Huge Clucker
 
Join Date: May 2010
Location: in hiding
Posts: 305
Reputation: 6
Default Re: How to stream Shoutcast to your server

Quote:
Originally Posted by Csaba1996 View Post
help 15 error:S
paste the line, preferably with [pawn] tags
__________________

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)
PCheriyan007 is offline   Reply With Quote
Reply

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 08:22 PM.


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