sm_advertisements_file (def "advertisements.txt")
File to read the advertisements from. Useful if you're running multiple servers from one installation, and want to use different advertisements per server.
sm_advertisements_interval (def 30)
Number of seconds between advertisements.
sm_advertisements_random (0/1, def 0)
Enable/disable random advertisements. When enabled, advertisements are randomized on every map change and reload.
sm_advertisements_reload
Server command to reload the advertisements.
By default the plugin reads from addons/sourcemod/configs/advertisements.txt, which has this format:
Make sure to save this file as UTF-8 (without BOM), otherwise special characters will not work!
Types
The following types are supported:
center: A center message, like sm_csay. chat: A chat message, like sm_say. A list of supported colors can be found on https://github.com/PremyslTalich/ColorVariables. hint: A hint message, like sm_hsay. menu: A menu message, like sm_msay, but without the title or the Exit-option. Pressing 0 will still hide the message, but it will block 1-9 from switching weapons while it's showing. top: A top-left message, like sm_tsay. It supports any of the colors listed on https://www.doctormckay.com/morecolors.php, or custom colors with {#abcdef}.
Multiple types per advertisement are allowed, so you can show a different message in multiple places at the same time.
Message
The message supports the following variables: {currentmap}, {nextmap}, {date}, {time}, {time24} and {timeleft}. Next to that you can print the value of any cvar by enclosing the name with {}, for example {mp_friendlyfire}. Use \n for newlines, which works with center, chat, hint and menu messages.
A couple of examples are given in the supplied advertisements.txt.
Flags
This field is optional. It accepts a list of flags of players who will not see the advertisement if they have any of those flags. If left empty, only admins will see the advertisement. If omitted everyone will see the advertisement.
Allow more chat colors for Insurgency and Source 2013 games.
Fixed {currentmap} variable for workshop maps.
Support \n in chat messages on CS:GO.
Throw an error when using {teamcolor} on an unsupported game.
Fall back to stock Source engine chat colors instead of CS:GO colors.
2.0
Implemented proper color support for chat messages.
Implemented custom colors for top-left messages.
Instead of being able to show the same message in different places, you can now show different messages at the same time.
Removed support for {tickrate} and boolean cvars to simplify plugin.
Added Updater support.
0.6
CS:GO support
Bug fixes
0.5.5
Fixed {LIGHTGREEN}.
Added \n for newlines.
0.5
Support for boolean cvars has been added.
{LIGHTGREEN} was added to say messages.
Multiple types per advertisement are now supported.
Multiple flags per advertisement are now supported, with the possibility to leave it empty so they only show to admins.
Added sm_advertisements_file in case you're running multiple servers from one installation, and want different advertisements per server.
Made center messages show for 5 seconds, so they don't disappear anymore within 2 seconds.
Switched to a KeyValues file, the format is explained above and shown in the attached advertisements.txt.
0.4
I skipped it! Why? Because I can
0.3
Support for cvars has been added, for example to print the next map use {SM_NEXTMAP}. Because of this {NEXTMAP} has been removed. I haven't been able to get bounds to work yet (the upper bound of for example mp_friendlyfire always returned 0.0) so for now boolean cvars just show 0/1.
{TICKRATE} was added and obviously shows the server's tickrate (thanks to Nican's code he posted on the forums).
{TIME24} was added and shows a 24-hour clock.
SayText2 is now only used when you use {TEAM}, otherwise it uses PrintToChat. This should fix the problems with mods that don't support SayText2 (Insurgency, and contrary to what I thought earlier, Day of Defeat: Source doesn't support it either), so as long as you don't use {TEAM} you should be good on those mods. Two notes: {GREEN} is actually red in DoD:S, and SayText2 in CS:S produces the same tick sound that you hear when someone types something. So if you use {TEAM} in CS:S note that it will give a tick sound when that ad shows.
Advertisements can now be hidden from clients with a specific flag by adding that flag's letter after the type, like this: SA This say ad will be hidden from clients with a reserved slot
Of course by omitting the letter it will be shown to everyone.
0.2
Added colors to chat messages, it now has {DEFAULT} (white), {TEAM} (the color of on the team you're on, or light green if you're a spectator) and {GREEN} (green). Those are the colors in TF2, they might be different in other games. You can just use them wherever you want, for example: S He{GREEN}llo t{TEAM}he{DEFAULT}re
Split {TIME} into {DATE} and {TIME} where {TIME} returns a 12-hour clock with AM/PM.
The timer is now restarted when you change sm_advertisements_interval, it doesn't require a map change anymore.
Excellent plugin! It's short and concise and efficient. I'll be using this.
And for chat colors, precede the text you want colored with the color code (i.e. PrintToChatAll("%cThis is green", COLOR_GREEN), where COLOR_GREEN is defined as 4).
Thanks guys, I thought this would be such a basic feature, and since we already had the functions for it it was very easy to make. I'll definitely look into the colors.