Description
-----------
    This is a simple advertisements plugin based on basechat. 
    It supports say, csay, hsay, msay and tsay.

    http://forums.alliedmods.net/showthread.php?t=67885

Cvar
----
    sm_advertisements_version
        Plugin version.

    sm_advertisements_enabled (0/1, def 1)
        Enable/disable displaying advertisements.

    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)
        Amount of seconds between advertisements.

    sm_advertisements_reload
        Server command to reload the advertisements from advertisements.txt.

    sm_advertisements_dateformat (def "%m/%d/%Y")
        Date format for {DATE} placeholder.

    sm_advertisements_timeformat (def "%I:%M:%S%p")
        Time format for {TIME} placeholder.

    sm_advertisements_time24format (def "%H:%M:%S")
        Time format for {TIME24} placeholder.

    sm_advertisements_showexitbutton (def 0)
        Show exit button in menus.
        
Configuration
-------------
    By default the plugin reads the advertisements from configs/advertisements.txt, which has this format:

    "Advertisements"
    {
        "1"
        {
            "type"        "S"
            "text"        "{GREEN}contact@domain.com"
        }
        "2"
        {
            "type"        "T"
            "text"        "www.domain.com"
            "flags"       "a"
            "showcount"   "2"
        }
    }

    Type

        This field can contain the following letters:

        C A center message, like sm_csay.
        H A hint message, like sm_hsay.
        M A menu message, like sm_msay, but without the title or the Exit-option. 0 will still 
          hide the message though. Will block 1-9 from switching weapons as long as it's showing.
        S A chat message, like sm_say. It supports the following colors: {DEFAULT}, {TEAM}, {GREEN} 
          and {LIGHTGREEN}. {TEAM} and {LIGHTGREEN} unfortunately don't work together in a single 
          advertisement, so it's one or the other. 
          For L4D you can use {RED}.
          For TF2, DODS you can use {DARKGREEN}.
          For DODS you can not use {LIGHTGREEN} or {TEAM}.
          For example: {GREEN}Current {LIGHTGREEN}Map: {DEFAULT}{CURRENTMAP}
        T A top-left message, like sm_tsay. It supports one of the following colors: {WHITE}, {RED}, 
          {GREEN}, {BLUE}, {YELLOW}, {PURPLE}, {CYAN}, {ORANGE}, {PINK}, {OLIVE}, {LIME}, {VIOLET} 
          and {LIGHTBLUE}. You can omit the color if you just want the normal color. 
          For example to have an orange message, set text to: {ORANGE} Text here

        Multiple types per advertisement are allowed, so you can show a single advertisement 
        in multiple places at the same time.

    Text

        This field supports the following variables: {CURRENTMAP}, {DATE}, {TICKRATE}, {TIME}, {TIME24}, 
        {TIMELEFT} and {NEXTMAP}. Next to that you can print the value of a cvar by enclosing the name with {}. 
        For example you can use {SM_NEXTMAP} to show the name of the next map. Last but not least, for 
        a boolean cvar you might want to have it print OFF/ON instead of 0/1. For that you can use 
        {BOOL:name}. For example {BOOL:MP_FRIENDLYFIRE} will print OFF if mp_friendlyfire is set 
        to 0, and ON if it's set to 1. If you want it to print something other than OFF/ON, you will 
        have to open the source code, change the defines at the top and recompile. Also supports \n 
        for newlines (confirmed to work for C, M and S messages). A couple of examples are given in 
        the attached advertisements.txt.

    Flags

        This field is optional. It accepts a list of flags of admins that 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.

    ShowCount

        If omitted "1" is used. It meens how many times this ad will be shown in one full cycle. 
        Full cycle is when all ads shown all desired times. Another meaning of this field is weight.

Credits
-------
    * Thanks to DJ Tsunami for advertisements plugin till version 0.5.5.
      http://forums.alliedmods.net/showthread.php?t=67885
    
    * Thanks to AlliedModders LLC for Basic Info Triggers plugin. 
      http://www.sourcemod.net/
      Advertisement's triggers for {NEXTMAP} and {TIMELEFT} is 
      borrowed from it's source code.      

Changelog
---------
    0.6.2:
        + Added {YELLOW} placeholder for S-type advertisements for TF2.

    0.6.1:
        + Added {NEXTMAP} placeholder.
        * {TIMELEFT} and {NEXTMAP} now acts like their in-chat versions from basetriggers plugin.

    0.6.0:
        + Added "showcount" field to ads file. If omitted "1" is used. It meens how many times this
          ad will be shown in one full cycle. Full cycle is when all ads shown all desired times.

    0.5.10:
        + Added {DARKGREEN} to "S"-type message for TF2 and DODS mods.

    0.5.9:
        + Added {RED} to "S"-type message for L4D mod.
        * Fixed color for PrintToChat broken in release 0.5.8.
    
    0.5.8:
        * Fixed boxes that appears around some letters in the hint message after previous release 0.5.7.
          It was a bug because of color tags was striping incorrectly.
        + Added cvar sm_advertisements_showexitbutton. If enabled than players can close panel with "1" button. 
          It's more ergonomic than "0" button.
          
    0.5.7:
        * Fixed bug report:
            >> I want to have an ad pop up in two different places (chat and hint). I want it to be colored 
            >> in chat, but, as you know that isn't possible in hint and it shows the color tags.
          Now all color tags strips from ads if the method does not support colors.
        * Fixed multiline hint adv:
            >> Also added \n for newlines, which worked for me for C, M and S messages. Don't
            >> know why it doesn't work for H. 
          It was a bug, "\n" is char 10 not 13.
        * Optimized CPU usage. Removed OnGameFrame(). It was changed to another ticktime detection.

    0.5.6:
        * Fixed bug. Changed GetClientCount to MaxClients.
          It was a bug that ads did not showing to clients for example in the following situation:
            1) restart server
            2) add 4 bots
            3) connect to server
            4) remove one bot
            As a result - you'll not see any ads on release 0.5.5. 
        * Some minor code optimization. Added separate function to detect players to show ads to.
        + Added new cvars to set datetime format to date, time, time24 placeholders: 
          sm_advertisements_dateformat, sm_advertisements_timeformat and sm_advertisements_time24format.

    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.

    0.1:
        * Initial release

TODO
----

    * Feature request
        Counter-Strike Source support red, blue and white colors and it works in teg {TEAM}
        Whan I ct - blue , whan t - red, spectator - white
        I need: Whan I ct - red, whan t - red, s - red
        On es support red, blue and white in chat made this script: http://forums.eventscripts.com/viewtopic.php?t=32433
        sm colors inc - https://forums.alliedmods.net/showthread.php?t=96831
