[Tutorial] Car / Vehicle Internet Radio
#1

SIMPLE CAR INTERNET RADIO BY JANI

At first, this is my first tutorial.
INTRODUCTION
This is simple radio script, that will play internet radio when you enter a vehicle, and stop, when you exit vehicle.
Step 1.
Code:
#include <a_samp>
Include the scripting language.
Step 2.
Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    //start the internet stream
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
        {
                PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=37586");//here you can put your own url, thats just example.
        }
        // stop the internet stream
        else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
        {
            StopAudioStreamForPlayer(playerid);
        }
        return 1;
}
So, now comes the explain.
Code:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
If players new state is driver or passenger (A.K.A. in a vehicle),
Code:
PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=37586");
this starts the stream. (PlayAudioStreamForPlayer). After playerid, you can put your own radio you want to listen to. The URL goes inside " ".
Code:
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
This means, that if someone was a driver or passenger, and is no more, it stops the radio
Code:
StopAudioStreamForPlayer(playerid);
because the player exited the vehicle.

Thats it!
I REALLY hope this helps, because this is first tutorial I have ever made.
Reply
#2

Not a good idea to edit the script everytime we want to change the song.
Reply
#3

Do you know what radio is? They play online different songs. Listen to internet radio man.
Reply
#4

Wheren can I get that URL of my desired radio?
Reply
#5

The helped me so much!
I had absolutely no clue, on how to Add this to my server!

Thanks Jani!

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)