SA-MP Forums Archive
[Tutorial] Make your own Radio System - PlayHard's Tutorials! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Make your own Radio System - PlayHard's Tutorials! (/showthread.php?tid=301986)

Pages: 1 2


Make your own Radio System - PlayHard's Tutorials! - PlayHard - 06.12.2011

Making a Radio System


Introduction:
Today I am going to talk about making radios and show you how to make your very own radio system and enjoy the music and your favorite radio stations playing in your favorite game Grand Theft Auto: San Andreas. I believe that some of us still want to know how to make their own radio systems or Audio streaming system that allows them to hear, listen and enjoy their favorite radio station and music.
What is this?
It is a tutorial that shows you how to use the new functions "PlayAudioStreamForPlayer" and "StopAudioStreamForPlayer" and make a radio system using them.
What are these functions?
These functions allows you to play and stop an Audio stream for a specific player using a radios tation url.
What do I need to start learning from this tutorial?
Part I (Getting urls for our radio system)
Getting urls is the first very important step in creating the radio system, because without the urls you will not be able to play or do anything. So, here is a list of websites you can get urls from,And here are some of the urls I took from my Radio on my Nokia 5800's radio,

Part II (Setting up our second step)
Open a new project on Pawn, remove everything but keep OnPlayerCommandText, OnDialogResponse, OnFilterScriptInit, OnFilterScriptExit and the
pawn Code:
#if defined FILTERSCRIPT

This is how your project supposed to look like:


pawn Code:
#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif


public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}
Part III (Scripting the most important codes to run everything in your Radio System!)

*Everything is explained in the next pawno quotes.
pawn Code:
#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Radio System is starting ..");
    print(" Radio system has started.");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
    print(" Radio System has been shut down due to a Filterscript unload/Exit.");
    print("--------------------------------------\n");
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Radio Tutorial by PlayHard. Powered by PlayHard's Tutorials :P");
    print("----------------------------------\n");
}

#endif


public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/myradio", cmdtext, true, 10) == 0) //Change this one to whatever you want.
    {
        ShowPlayerDialog(playerid,90,DIALOG_STYLE_LIST,"My Radio list","1. My first channel\r\n2. My second channel\r\n3. My third channel","Select", "Cancel");
        //We use the line above to make the Dialog show, and as you notice we want DIALOG_STYLE_LIST because it will be a list so we can choose from.
        //As you notice everytime you add \r\n it adds a new line to the list, which means in our tutorial adds a new radio station to the list.
        //Make sure you change the ID of the Dialog, we don't want it to mix with other dialogs in your server, I set it to 90.
        return 1;
    }
    if (strcmp("/stopradio", cmdtext, true, 10) == 0)
    {
        StopAudioStreamForPlayer(playerid);//This is the function we need to stop the audio from streaming the music.
        return 1;
    }
    return 0;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 90: //Remember the ID we changed in ShowPlayerDialog? (90) That's how the DialogResponse will get to know which Dialog it's going to use.
        {
            if(!response)// This one is used for option 2 which we changed to (Cancel).
            {
                    SendClientMessage(playerid, 0x42F3F198, "You canceled the dialog.");//This one sends a message when you close the dialog using (Cancel).
                    return 1;
            }

            switch(listitem)//This one will list the items.
            {
                case 0://Case 0 is basically the first line we made in ShowPlayerDialog (1.)
                {
                    PlayAudioStreamForPlayer(playerid, "http://radio02-cn3.akadostream.ru:8814/nrj192.mp3");//This function will play our desired radio. So we have to put the url between its brackets.
                    SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming."); //This line sends a message to the listener that he can stop it using /stopradio.
                }
                case 1://Case 1 is the second line we put in ShowPlayerDialog (\r\n2.)
                {
                    PlayAudioStreamForPlayer(playerid, "http://stream.radioactivity.fm:8002/");//This function will play our desired radio. So we have to put the url between its brackets.
                    SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
                }
                case 2://Case 2 is the third line we put in ShowPlayerDialog(\r\n3.)
                {
                    PlayAudioStreamForPlayer(playerid, "http://sc.3wk.com:8300/");//This function will play our desired radio. So we have to put the url between its brackets.
                    SendClientMessage(playerid, 0x42F3F198, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
                }
                //You can continue cases here but make sure you make a new line in the ShowPlayerDialog on /myradio command \r\n4. 4th \r\n5. 5th channel etc..
            }
        }
    }
    return 1;
}
PlayHard's Tutorials
All rights are reserved to PlayHard
I hope that you got something new today and found this useful.



Re: Make your own Radio System - PlayHard's Tutorials! - MathijsS - 06.12.2011

PLease! Change the font and color, it's fucking hard to read.


Re: Make your own Radio System - PlayHard's Tutorials! - Mark™ - 06.12.2011

Thanks a lot mate, simple and brief to the point.


Re: Make your own Radio System - PlayHard's Tutorials! - PlayHard - 07.12.2011

Quote:
Originally Posted by MathijsS
View Post
PLease! Change the font and color, it's fucking hard to read.
Take it easy mate, I removed them.
Quote:
Originally Posted by Xtreme_playa
View Post
Thanks a lot mate, simple and brief to the point.
You're very welcome and I am glad to hear that!


Re: Make your own Radio System - PlayHard's Tutorials! - jueix - 07.12.2011

this doesnt work for me when i try to make the dialog and go to my server and type the command it says invalid command.


Re: Make your own Radio System - PlayHard's Tutorials! - jueix - 07.12.2011

Quote:
Originally Posted by jueix
View Post
this doesnt work for me when i try to make the dialog and go to my server and type the command it says invalid command.
nvm it wernt you it was me sorry forgot to add one of them return things.


Re: Make your own Radio System - PlayHard's Tutorials! - PlayHard - 09.12.2011

Quote:
Originally Posted by jueix
View Post
nvm it wernt you it was me sorry forgot to add one of them return things.
Yup, no problem, just be more 'open-eyed' next time and I hope you learned something new today!


Re: Make your own Radio System - PlayHard's Tutorials! - [DRuG]Mouldy - 11.12.2011

If anyone needs a shoutcast server

http://radio.chyfm.com:9000/listen.pls
750 slots
plays hitmusic
Real station


Re: Make your own Radio System - PlayHard's Tutorials! - PlayHard - 14.12.2011

Okay thank you Mouldy I guess!


Re: Make your own Radio System - PlayHard's Tutorials! - Fresh9884 - 18.12.2011

Does anyone know how to convert putting the URL links and names into a .cfg instead for easy editing and what not like. URL || NAME.


Re: Make your own Radio System - PlayHard's Tutorials! - PlayHard - 19.12.2011

Well, you can edit the urls in my FS easily. Read above in the script!


Re: Make your own Radio System - PlayHard's Tutorials! - fangoth1 - 30.12.2011

umm it doesnt play anything with the urls i give it, tried many


Re: Make your own Radio System - PlayHard's Tutorials! - Dan_Barocu - 30.12.2011

i want to pres Num 4 & 6 to listen to more radios statios,how do i do it?


Re: Make your own Radio System - PlayHard's Tutorials! - PlayHard - 31.12.2011

Quote:
Originally Posted by Dan_Barocu
Посмотреть сообщение
i want to pres Num 4 & 6 to listen to more radios statios,how do i do it?
Well, I'll try to make that.

Quote:
Originally Posted by fangoth1
Посмотреть сообщение
umm it doesnt play anything with the urls i give it, tried many
It works, make sure that the urls are fine and dialog (Return) 1 or 0.


AW: Make your own Radio System - PlayHard's Tutorials! - BigETI - 31.12.2011

pawn Код:
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Radio System is starting ..");
    print(" Radio system has started.");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
    print(" Radio System has been shut down due to a Filterscript unload/Exit.");
    print("--------------------------------------\n");
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Radio Tutorial by PlayHard. Powered by PlayHard's Tutorials :P");
    print("----------------------------------\n");
}

#endif
In this part you know that OnFilterScriptInit() and OnFilterScriptExit() gets never called since the compiler won't compile the lines.
And main() does not get called for a filterscript.

remove the part with "#if defined FILTERSCRIPT", "#else" and "#endif".


Re: Make your own Radio System - PlayHard's Tutorials! - Dan_Barocu - 31.12.2011

Quote:
Originally Posted by Dan_Barocu
Посмотреть сообщение
i want to pres Num 4 & 6 to listen to more radios statios,how do i do it?
Cand somebody make me exemple?+Can u put it in pawn soo we can do copy..paste please.


Re: Make your own Radio System - PlayHard's Tutorials! - [FR]Fratzica - 26.07.2012

[REDACTED BY FBI]


Re: Make your own Radio System - PlayHard's Tutorials! - Glint - 26.07.2012

Quote:
Originally Posted by [FR]Fratzica
Посмотреть сообщение
HELPPPPPP

E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(31) : warning 217: loose indentation
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(37) : warning 217: loose indentation
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(37) : error 029: invalid expression, assumed zero
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(37) : error 004: function "OnDialogResponse" is not implemented
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(39) : error 017: undefined symbol "dialogid"
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(43) : error 017: undefined symbol "response"
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(4 : error 017: undefined symbol "listitem"
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(52) : error 017: undefined symbol "PlayAudioStreamForPlayer"
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(57) : error 017: undefined symbol "PlayAudioStreamForPlayer"
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(62) : error 017: undefined symbol "PlayAudioStreamForPlayer"
E:\Users\PredelCorp\Desktop\sv samp\Server DKR\filterscripts\RadioTaran.pwn(71) : error 030: compound statement not closed at the end of file (started at line 2
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


9 Errors.
how to fix them
??
Post your code.


Re: Make your own Radio System - PlayHard's Tutorials! - Jeth - 06.08.2012

C:\Documents and Settings\JETHRO\Desktop\secret\RADIO SYSTEM.pwn(42) : error 017: undefined symbol "StopAudioStreamForPlayer"
C:\Documents and Settings\JETHRO\Desktop\secret\RADIO SYSTEM.pwn(65) : error 017: undefined symbol "PlayAudioStreamForPlayer"
C:\Documents and Settings\JETHRO\Desktop\secret\RADIO SYSTEM.pwn(70) : error 017: undefined symbol "PlayAudioStreamForPlayer"
C:\Documents and Settings\JETHRO\Desktop\secret\RADIO SYSTEM.pwn(75) : error 017: undefined symbol "PlayAudioStreamForPlayer"
C:\Documents and Settings\JETHRO\Desktop\secret\RADIO SYSTEM.pwn(80) : error 017: undefined symbol "PlayAudioStreamForPlayer"
C:\Documents and Settings\JETHRO\Desktop\secret\RADIO SYSTEM.pwn(85) : error 017: undefined symbol "PlayAudioStreamForPlayer"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.


Please help!


Re: Make your own Radio System - PlayHard's Tutorials! - Dan. - 06.08.2012

Update your server to 0.3e.