AlliedModders
XFactor Servers

Advertisements 0.5.5 (Updated 05/26/08)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: Netherlands
Plugin ID:
306
Plugin Version:
0.5.5
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Approver:
    Plugin Description:
    Display advertisements.
    Servers with this Plugin:
    1796 
    Old 03-03-2008 , 12:08   Advertisements 0.5.5 (Updated 05/26/08)
    Reply With Quote #1

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

    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.

    By default the plugin reads the advertisements from configs/advertisements.txt, which has this format:

    Code:
    "Advertisements"
    {
        "1"
        {
            "type"        "S"
            "text"        "{GREEN}contact@domain.com"
        }
        "2"
        {
            "type"        "T"
            "text"        "www.domain.com"
            "flags"       "a"
        }
    }
    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 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} and {TIMELEFT}. 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.

    Changelog
    • 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
    Attached Files
    File Type: sp Get Plugin or Get Source (advertisements.sp - 33561 views - 11.4 KB)
    File Type: txt advertisements.txt (1.2 KB, 21682 views)
    __________________
    My Plugins
    Don't PM me asking for support, post in the plugin's topic.

    Last edited by DJ Tsunami; 09-17-2008 at 15:50.
    DJ Tsunami is offline
    FrostbyteX
    Senior Member
    Join Date: Dec 2007
    Old 03-03-2008 , 12:34   Re: Advertisements
    Reply With Quote #2

    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).

    Steve
    FrostbyteX is offline
    Extreme_One
    Veteran Member
    Join Date: Nov 2006
    Old 03-03-2008 , 12:43   Re: Advertisements
    Reply With Quote #3

    Nice work
    Thank you.

    Coloured chat messages would be a great addition

    Anyway I've dropped ^BugS^ Ads plugin now and installed this one
    __________________
    Extreme_One is offline
    DJ Tsunami
    DJ Post Spammer
    Join Date: Feb 2008
    Location: Netherlands
    Old 03-03-2008 , 13:12   Re: Advertisements
    Reply With Quote #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.
    __________________
    My Plugins
    Don't PM me asking for support, post in the plugin's topic.
    DJ Tsunami is offline
    tcviper
    SourceMod Moderator
    Join Date: Oct 2005
    Location: Netherlands
    Old 03-03-2008 , 14:10   Re: Advertisements
    Reply With Quote #5

    Tsunami AWESOME job mate, no irritating TICK sound when a chat ad appears and works very well! Thank you.
    __________________
    tcviper is offline
    Send a message via MSN to tcviper
    bl4nk
    SourceMod Developer
    Join Date: Jul 2007
    Old 03-03-2008 , 14:57   Re: Advertisements
    Reply With Quote #6

    The reload command doesn't seem to work. It still prints out the same exact things as before I used it.
    - See edit

    Also, I added in {FF}. Here's the code I used.

    Code:
            if (StrContains(sBuffer, "{FF}")) {
                new Handle:ffConVar, ffSetting, String:sFF[6];
                ffConVar = FindConVar("mp_friendlyfire");
                ffSetting = GetConVarInt(ffConVar);
    
                switch (ffSetting) {
                    case 0:
                        Format(sFF, sizeof(sFF), "OFF");
                    case 1:
                        Format(sFF, sizeof(sFF), "ON");
                }
    
                ReplaceString(sBuffer, sizeof(sBuffer), "{FF}", sFF);
            }
    [edit]

    Nevermind about the reload thing. I was saving the file to the wrong place like a fool.

    Last edited by bl4nk; 03-05-2008 at 16:09.
    bl4nk is offline
    pRED*
    Join Date: Dec 2006
    Old 03-03-2008 , 15:08   Re: Advertisements
    Reply With Quote #7

    Nice work. Includes more features than the old advertisements plugin (which is no longer supported since the author has gone AWOL).

    Approved.
    pRED* is offline
    DJ Tsunami
    DJ Post Spammer
    Join Date: Feb 2008
    Location: Netherlands
    Old 03-03-2008 , 15:09   Re: Advertisements
    Reply With Quote #8

    Thanks for approving, and thanks for the code bl4nk, I will incorporate it.
    __________________
    My Plugins
    Don't PM me asking for support, post in the plugin's topic.
    DJ Tsunami is offline
    [Arnold]
    Senior Member
    Join Date: May 2004
    Location: Hannover, Germany
    Old 03-03-2008 , 15:22   Re: Advertisements
    Reply With Quote #9

    Great and absolutely missing! Hope you keep supporting it.
    __________________
    [Arnold] is offline
    Send a message via ICQ to [Arnold]
    FrostbyteX
    Senior Member
    Join Date: Dec 2007
    Old 03-03-2008 , 15:22   Re: Advertisements
    Reply With Quote #10

    Instead of {FF}, it would be nice to have a method for putting cvar values into the string, such as [mp_friendlyfire] and [sv_contact].
    FrostbyteX is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 23:35.


    Powered by vBulletin® Version 3.8.1
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
    Theme made by Freecode Sponsored by Layered Technologies