SourceMod Radio 2

About:

Adds a Radio player to SourceMod that supports direct stations or streaming audio with built in volume control. Version 2 comes with improved support for genres in station lists, ShoutCast auto-updating playlists and currently playing track queries. Supported by https://radio.dubbeh.net utilising the ShoutCast API – Sourcecode of the PHP/MySQL script is available on request but requires a ShoutCast Dev Key from here.

Server Console Commands:

  • sm_radio_enable 1/0 – Enable the radio plugin
  • sm_radio_play_type 1/3 – Play type for the radio.
    1 – Direct using the very first method of loading a stream directly from a websites player.
    2 – Volume Wrapper mode using the wrapper pages (HTML5/JPlayer) with volume control.
    3 – ShoutCast powered with auto-updating playlists utilising radio.dubbeh.net
  • sm_radio_advert 1/0 – Enable advertising the users radio station choice
  • sm_radio_welcome 1/0 – Enable the welcome message
  • sm_radio_logging 1/0 – Enable logging to the server console and log file
  • sm_radio_autoplay 1/0 – Enable the radio to auto-play on map change.
  • sm_radio_init_conn_vol 0.01/1.0 – When one of the play type modes that support volume control is active, this sets the initial volume for a user on first connect (0.10 recommended (10%) in CS:GO at least)
  • sm_radio_auto_update 1/0 – Enable the plugin to automatically update (If available updates are found)
  • sm_radio_check_html_motd 1/0 – Check clients on connect for “cl_disablehtmlmotd” and warn them if enabled. The plugin won’t function with cl_disablehtmlmotd enabled on a client.
  • sm_radio_shoutcast_custom 1/0 – Append custom stations using the wrapper page under ShoutCast mode. Loaded from “sourcemod/configs/shoutcastcustom.txt” using the standard station list format.
  • sm_radio_track_query_enable 1/0 – Enable the track query feature.
    For none ShoutCast mode stations – You’ll need to upload trackquery.php to your own webhost (Contact me here for personal hosting of this script), then modify the line that looks like this:
    $AllowedIPs = array (“127.0.0.1”, “1.1.1.1”, “2.2.2.2”, “3.3.3.3”);
    Change to your own server IP(s). Once you’ve done that, make sure to edit the “Volume Track Query” and point it to your own hosted trackquery.php inside your playlist of choice.
  • sm_radio_shoutcast_playlist 1/4 – Sets the playlist type for ShoutCast mode.
    1 = Standard mode with genres and child-genres
    2 = No child genres
    3 = Top 500 stations
    4 = Top 500 HTTPS only streams
  • sm_radio_volume_wrapper_type 0/1 – This sets the player to use in volume wrapper mode:
    0 = Use the HTML5 audio player
    1 = Use the JPlayer audio player
    If you experience playback issues in your current mod of choice – Try changing this setting first.
  • sm_no_missing_motdf_msgs 0/1 – Don’t display any messaages when MOTD Fixer is missing – Warning: Only enable this if you have your own custom MOTD loading code
  • sm_radio_check_disabled_plugin_messages 0/1 – HL2:DM Only – Check if cl_showpluginmessages is disabled and warn the user.

Client Console Commands:

  • sm_radio – Pop up the radio station menu
  • sm_radiooff or sm_roff – Turns the radio off
  • sm_browse “www.site.com” – browse www.site.com
  • sm_genre or sm_genres – Popup the Genre selection menu.
    Can append a primary genre to get directly to that genre menu eg. “sm_genre alternative”. If the genre isn’t found, will list all primary genres to the user.
  • sm_song or sm_track – Displays the currently playing stations song/track (Works only for supported stations)
  • sm_volume or sm_vol – Set the volume for the station you’re currently listening to (Minimum is 0.01 (1%) – Maximum is 1.0 (100%)
  • sm_rhelp or sm_radiohelp – Lists available client commands in a panel

Admin Console Commands:

  • sm_radio_force_download – Forces the playlist download inside the plugin. This is if you change “sm_radio_shoutcast_playlist” and want to download the new type. Right now all playlists are loaded from the same file, and would only update to the new method once a week. So make sure to run this or delete the playlist file to update.

Chat Usage:

  • !radio – Pops up a radio stations menu
  • !radiooff or !roff – Switches off the radio
  • !browse “www.site.com” or /browse “www.site.com” – Browse a website of choice
  • !track or !song – Displays the stations currently playing track in chat (If station is supported)
  • !genre or !genres – Pops up the genre selection menu. Use “!genre “primary_genre_name” to access that genres menu directly. If primary_genre_name is unknown, will list all primary genres
  • !rhelp or !radiohelp – Lists available client commands in a panel
  • !volume or !vol – Set the volume for the station you’re currently listening to (Minimum is 0.01 (1%) – Maximum is 1.0 (100%)

Genre List Format:

Right now we have 3 methods to load stations using the console variable sm_radio_play_type.

  • 1 = Direct – This is the very first method released on Radio that used a direct webplayer from your favourite station.
  • 2 = Volume – Came around in v1.0.0.16 that utilised a wrapper page to load stations and could access streams directly, with volume control inside the game of choice.
  • 3 = ShoutCast – This is a new method in version 2, that loads everything through radio.dubbeh.net utilising the ShoutCast.com API and auto-updating playlists on a weekly basis.

The old method of station loading is no longer valid – so old playlists won’t work anymore, will have to be converted to the new format. Check notes near the bottom of this document for a simple solution to this problem, using a custom plugin to convert old list types.

Everything has now switched to Keyvalues and storing data using indexed ADT arrays, used to be using Dynamic by Neuro_Toxin.

Genres are supported with child-genres using:

“Has Children” “1” – This is essential to keep the parsing working correctly

Inside the root Genre Node, example:

"Radio Stations"
{
    "Off Page" "https://radio.dubbeh.net/radiooff.html"
    "Volume Wrappers Base URL" "https://radio.dubbeh.net"
    "Shoutcast Player" "https://radio.dubbeh.net/index.php"
        "Volume Track Query" "https://radio.dubbeh.net/trackquery.php"
    "Use Genres" "1"

    "Alternative"
    {
        "Genre ID" "1"
        "Has Children" "1"

        "Adult Alternative"
        {
            "Genre ID" "2"
            "Has Children" "0"
            "Cherry FM"
            {
                "Stream URL" "http://listen.com/stream"
            }
        }
    }
}

Can see an example of this inside the ShoutCast auto-updated playlist for full effect, just make sure to add the “Stream URL” for the station – So that Radio knows what the Stream URL is for the current station outside of ShoutCast mode.

This is another example with base genres only, without utilising a child genre:

"Radio Stations"
{
    "Off Page" "https://radio.dubbeh.net/radiooff.html"
    "Volume Wrappers Base URL" "https://radio.dubbeh.net"
    "Shoutcast Player" "https://radio.dubbeh.net/index.php"
        "Volume Track Query" "https://radio.dubbeh.net/trackquery.php"
    "Use Genres" "1"

    "Alternative"
    {
        "Genre ID" "1"
        "Has Children" "0"
        "Cherry FM"
        {
            "Stream URL" "http://listen.com/stream"
        }
    }
}

Now the parser will take the following section as an actual station because “Has Children” is set to 0.

Final example is stations without utilising any type of genres:

"Radio Stations"
{
    "Off Page" "https://radio.dubbeh.net/radiooff.html"
    "Volume Wrappers Base URL" "https://radio.dubbeh.net"
    "Shoutcast Player" "https://radio.dubbeh.net/index.php"
    "Volume Track Query" "https://radio.dubbeh.net/trackquery.php"
    "Use Genres" "0"

    "Cherry FM"
    {
        "Stream URL" "http://listen.com/stream"
    }
}

All we have to do is set “Use Genres” “0” and each section from that point on-wards is read as a station.
Don’t worry about having to add a Genre ID/Station ID for each individual entry, if one isn’t found then the plugin will generate a random one using the SourceMods built in random function.

Last final thing about the station config changes. All files are stored inside the “sourcemod/configs/” folder.

sm_radio_play_type config files are as follows:

  • 1 – Direct – sourcemod/configs/radiodirect.txt
  • 2 – Volume – sourcemod/configs/radiovolume.txt
  • 3 – ShoutCast – sourcemod/configs/radioshoutcast.txt (Don’t try to modify this. It’s auto-updated weekly.)

Also, the addition of custom streams along side shoutcast mode using sm_radio_shoutcast_custom “1”:

  • ShoutCast Custom – sourcemod/configs/shoutcastcustom.txt

Station file format is exactly the same without anything changed, just loads your personal Volume Wrapper in to the base plugin.

Supported Languages:

  • English
  • German – Thanks Miha And Tema + Warja Wachen
  • Russian – Thanks Miha And Tema
  • French – Huge thanks to Cripix
  • Italian – Incomplete for version 2
  • Spanish – Incomplete for version 2
  • Turkish – Almost complete – Huge thanks to chalr
  • Polish – Incomplete for version 2
  • Dutch – Huge thanks to Mutse

Installation:

  • radio.smx -> addons\sourcemod\plugins
  • radio.phrases.txt -> addons\sourcemod\translations
  • plugin.radio.cfg -> cfg\sourcemod
  • radioshoutcast.txt-> addons\sourcemod\configs
  • radiodirect.txt -> addons\sourcemod\configs
  • radiovolume.txt -> addons\sourcemod\configs
  • shoutcastcustom.txt -> addons\sourcemod\configs
  • radio2_wrappers.zip -> Your own custom web server (Feel free to use my host with the exception of Google Analytics and AdSense (Supports the plugin and hosting costs). Only for the html_rvw.html/jplayer_rvw.html – If you want the trackquery.php hosted by me, use the contact page here and I’ll see what I can come up with.

html_rvw.html (HTML5 Radio Volume Wrapper) / jplayer_rvw.html (JPlayer Radio Volume Wrapper) – Enables the volume control option to function correctly inside the plugin (This is hosted by my site as default)
trackquery.php (Track Query Script) – For track query outside of standard ShoutCast mode, need to put this on your own webhost and modify the $AllowedIPs to your own gameservers. Don’t forget to edit the playlist file of choice and change the “Track Query URL” to point at it.

All radio station links can be setup inside radiovolume.txt, radiodirect.txt and shoutcastcustom.txt depending on settings – radioshoutcast.txt is auto-updated inside the plugin (Don’t edit this file – It’s updated weekly).

Notes:

SteamWorksUpdate by Hexa-Core for SM 1.11 – Required to keep the ShoutCast playlists in sync with the radio.dubbeh.net player (Station indexes will change every single week).
MOTD Fixer – Essential if running under CS:GO for the plugin to function as intended and be able to load stations again – since the June-July 2017 Updates. Included in the base download package now
Dynamic – Essential for the plugin to function correctly – This is how all the genres and stations are stored internally using the in-built method maps.
Updater – This plugin is great to keep the latest versions of many plugins on your server that support it and save the hassle of manually updating everything.
“disabled/sm_playlist_converter.smx” – This is a small plugin to convert version 1 playlists to version 2. Move the radio_playlist_converter.smx to the base plugins folder and once loaded up, type in the console “sm_plconvert 1/2”. 1 is to output to “sourcemod\configs\radiovolume.txt” and option 2 will output to “sourcemod\configs\shoutcastcustom.txt”, make sure you have RCon command access for these commands. Wait a few seconds and you should have the new format playlists ready to utilise in Radio 2.

You need to press play inside the web player for stations to load with Steam autoplay permission changes under Chromium Embedded Framework

Guide for getting custom streams from TuneIn.com can be found here.

If you’re still confused about anything. Give me a shout in the forums here or SourceMod ones, can also be e-mailed directly from the contact page.

Download:

Download from my personal host here and extract straight to your game server directory (Complete package, including SteamWorks and Updater).
radio2_wrappers.zip can be downloaded here and put on your own custom webserver, or use my host and support the plugin.
The Official SourceMod thread is here.

Support

Any support is welcome and much appreciated, especially if you frequently use any of my plugin(s).
Really easy way to support the server and plugin development costs is to keep the html_rvw.html/jplayer_rvw.html hosted at “dubbeh.net” inside the config text files or or sign up for Vultr using my affiliate URL here for $100 credit, available for a limited time (Top 3 rated VPS host with multiple locations).
If you want to donate directly, please send it to the SourceMod project.

Credits:

SourceTunes, sessus, gH0sTy, InflatableSoulmate, Calystos, Swagger, jack_wade, Darkthrone, Maxximou5, kin5, MihaAndTema, GoD-Tony, Dr. McKay, chalr, CamerDisco, Bara, Neuro_Toxin and KyleS

Version History:

v2.0.0.16

  • Notice: MOTD panels still work fine, but you need to press play in the audio player with new chromium policies
    Tested under HL2:DM and TF2
  • Moved MOTD Fixer to the disabled folder
    It was only required in CS:GO that has now fully removed MOTD panels from the code base
  • Added #pragma dynamic to the build options to increase the stack space
  • Fixed return types in a few functions
  • Updated Multi-Colors by Bara to the lastest git commit: 2d9c20b8f4793e04ebfe2fe6e3ba467fdc22eb47
  • Updated and Added a lot of translations with help from deepl.com/en/translator
  • Added a check for cl_showpluginmessages under HL2:DM and warn the user if disabled
    Enabled by default, disable by setting “sm_radio_check_disabled_plugin_messages 0”
    You can disable this and use the awesome plugin @ https://github.com/Alienmario/plugin-messages-assist by AlienMario
  • Added a new playlist type in the plugin and radio.dubbeh.net – Top 500 with HTTPS only streams
    Enable this with “sm_radio_shoutcast_playlist 4”
  • Updated to the latest SteamWorks compatible with SM 1.11, Thanks to Hexa-Core – https://github.com/hexa-core-eu/SteamWorks/releases/tag/v1.2.4
  • Misc code changes

v2.0.0.15

  • Added a new cVar to stop displaying messages if MOTD Fixer is missing – “sm_no_missing_motdf_msgs 0/1” – Requested by CookieB

v2.0.0.14

  • Modified cl_disablehtmlmotd checking code, to only message clients when It’s set to 1 (Was messaging clients when cVar wasn’t found too)
  • Added the latest MOTD Fixer v1.06
  • Russian translations updated – Thanks to MihaAndTema
  • German translations updated – Thanks to Warja Wachen
  • Changed the config files to use “Volume Wrappers Base URL” for the volume wrappers

v2.0.0.13

  • Typo fixed in HTML5 (HTLM5) with the station playlists and plugin

v2.0.0.12

  • Fixed Left For Dead 2 support – 1 is currently untested right now but feedback would be great
  • New console variable “sm_radio_volume_wrapper_type 0/1”:
    • 0 = Use the HTML5 audio player – set inside the station lists under “HTML5 Volume Wrapper”
    • 1 = Use the JPlayer audio player – same as above using “JPlayer Volume Wrapper”
    • New pages are html_rvw.html and jplayer_rvw.html inside radio2_wrapper.zip
    • If you experience playback in your current mod of choice – Try changing this setting first
  • JPlayer forced under Left 4 Dead 1 and 2

v2.0.0.11

  • Reverted ShoutCast update timer fix – Was incorrect (Checks every 30 minutes now – 1,800 seconds)
  • French translation updated – Huge thanks to Cripix
  • Update all SteamWorks libraries to git 126 and updated SteamWorks.inc
  • Added a changelog to the download package

v2.0.0.10

  • Added missing Radio Playlist Converter source code
  • Fixed the ShoutCast updater timer – Changed from 3600 to 360
  • Removed SetFailState when MOTD Fixer not found under CS:GO
  • Reverted back to old panels without MOTD Fixer under CS:GO but added a message
  • Slight updated to the translation file
  • Fixed the Breakz.fm station link inside “addons/sourcemod/configs/shoutcastcustom.txt”
  • Added MOTD Fixer and SMJansson to the base package to make sure full functionality is back

v2.0.0.9

  • Problem with the volume loading incorrectly fixed
  • Added feedback for MOTD Fixer and checks if available – Translation file was also updated
  • New radiovolume.txt/shoutcastcustom.txt added to the package – Thanks to Caaine
  • Few more internal code changes

v2.0.0.8 FINAL

  • Added a missing Plugin_Handled on !rhelp
  • Reintroduced !browse/sm_browse for CS:GO with MOTD Fixer
  • Fixed the “Off Page” loading incorrectly under CS:GO – Wasn’t using MOTDF_ShowMOTDPanel
  • Added more checks for SteamWorks_IsLoaded()
  • Changed a few more LogMessage calls to utilise RLogMessage
    If you experience problems inside Radio – Make sure “sm_radio_logging” is set to 1
  • Removed unecessary null’s after calling delete on Handles
  • Added the latest Linux git123 SteamWorks.ext.so to the package
  • Updated to the latest Multi-Colors by Bara
  • Removed redundant files from the full download package
  • Fixed plugin dependancy issues with Updater/MOTD Fixer – Was an issue in the include files

v2.0.0.8 BETA 3

  • Fixed plugin dependancy issues with Updater/MOTD Fixer – Was an issue in the include files

v2.0.0.8 BETA 2

  • Forced MOTD Fixer to be installed under CS:GO – This is essential for full functionality
  • Added the missing radio.sp from the previous beta 1 release
  • Cleaned up the code base and removed unecessary files that slipped into the download package

v2.0.0.8 BETA 1

  • Initial support added for the latest CS:GO update that broken MOTD’s using MOTD Fixer

v2.0.0.7

  • Added Dutch translations – Big thanks to Mutse
  • Small logic processing problem with the volume menu fixed
  • Added the updated updater.inc for new decls – Was missing from previous versions
  • Plugin now compiles with “pragma new decls” forced
  • Other small internal code changes

v2.0.0.6

  • Improved cookie handling when changing play types
  • Extra checks added to the station storage – Fixes a small log error

v2.0.0.5

  • Fixed an invalid handling of the ShoutCast custom stations menus
  • Long standing issue with the base menu not utilising generes correctly in ShoutCast mode

v2.0.0.4

  • Added Russian and German Translations – Thanks Miha and Tema
  • Dropped Dynamic for now and switched over to custom internal station storage – Resolves the memory leaking bug

v2.0.0.3

  • Removed the hardcoded genres usage in ShoutCast mode
  • Only initialise the genre collections now when they’re enabled inside the playlist file(s)

v2.0.0.2

  • The problem with Dynamic and empty methodmaps is now fixed and added source to package
  • Cached the console variables “sm_radio_play_type” and “sm_radio_shoutcast_custom” in OnConfigsExecuted()
    This avoids conflicts or crashes with the way playlists are parsed on each map start
  • Added a slight change to the ShoutCast auto-generated playlists
    Potentially GeoBlocked stations are now marked with (*) – These are stations utilising Radionomy
    This also adds a small change to the translation file

v2.0.0.1

  • Fixed problem with Dynamic and trying to clear an uninitialized methodmap
  • Added the missing LANG_SERVER on Track Query Disabled string formatting
  • More checks done for missing playlist files and feedback to the users
  • 3 playlist modes supported from the ShoutCast API, all controlled with “sm_radio_shoutcast_playlist 1/3”
  • ShoutCast playlists can be forced to download with “sm_radio_force_download” – This is useful if you change the playlist type from the cVar above
  • Another couple more translations added – So make sure to update your translation files
  • ShoutCast Auto-Playlist downloading, if one isn’t found (Make sure to reload the map after the download completes to apply changes)
  • Updated to the latest SteamWorks inside the package

v2.0.0.0 Final

  • Finally moved the plugin out of BETA – Everything seems to be stable now
  • Added support for track query under Volume Wrapper mode and ShoutCast custom
    Need to put trackquery.php inside the radio2_wrappers.zip on your own webhost and modify the $AllowedIPs to your own game server ones. After you’ve edited the trackquery.php script, set the “Volume Track Query” to the URL of your own host.
  • Included Multi-Colors by Bara in the base package
  • Included a seperate plugin to convert your old Radio version 1 playlists to Version 2 KeyValues
  • Turkish translation added – Huge thanks to chalr (Incomplete again, sorry :()
  • Added sm_radio_track_query_enable – Enable or disable track query in Volume and ShoutCast modes
    This added a new translation text – So make sure to update your translation files from Beta 3 to current
  • Removed the “Browse Fix” completley for CS:GO – This doesn’t work anymore since a few patches back

v2.0.0.0 BETA 3

  • Changed menu processing – Saved a tiny bit of CPU in the process with one less iteration over genres
  • Added support for custom stations alongside the ShoutCast radio list with “sm_radio_shoutcast_custom 0/1”
    Parsed from “sourcemod/configs/shoutcastcustom.txt” using the standard format
  • Help panel added to show commands to users that can be accessed by typing !radiohelp or !rhelp
  • Finalised the translations – Updates and additions in various languages would be great, Thanks!

v2.0.0.0 BETA 2

  • Removed auto-appending “/;” to stream URL’s for now. Causes problems with IceCast 2 streams and makes them unreachable

v2.0.0.0 BETA 1

  • Switched all the station loading URLs over to HTTPS for Volume Wrapper and ShoutCast Mode (If using my website)
  • Plugin is now powered by www.ShoutCast.com with auto-updating playlists utilising radio.dubbeh.net
  • Radio is now using Dynamics to store stations and using key values to load the data – Huge Thanks to Neuro_Toxin for an amazing plugin
  • New radio stations format – Everything is based around key values
  • Genre support
  • Track query support (Only for SHoutCast mode right now)
  • Utilising SteamWorks by KyleS for auto-updating playlists to keep in sync with ShoutCast and Track Query (WIP)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.