AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Advertisements 2.1 (Updated 2021/02/06) (https://forums.alliedmods.net/showthread.php?t=155705)

DJ Tsunami 03-03-2008 12:08

Advertisements 2.1 (Updated 2021/02/06)
 
11 Attachment(s)
This is a simple advertisements plugin. It supports center, chat, hint, menu and top messages.

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

Code:

"Advertisements"
{
    "1"
    {
        "chat"        "{green}[email protected]"
    }
    "2"
    {
        "top"        "www.domain.com"
        "flags"      "a"
    }
}

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.


Download | Source Code

Changelog

https://img.shields.io/github/workfl...ts/CI/main.svg https://img.shields.io/github/releas...rtisements.svg https://img.shields.io/github/downlo...ents/total.svg

FrostbyteX 03-03-2008 12:34

Re: Advertisements
 
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

Extreme_One 03-03-2008 12:43

Re: Advertisements
 
Nice work :D
Thank you.

Coloured chat messages would be a great addition :)

Anyway I've dropped ^BugS^ Ads plugin now and installed this one :up:

DJ Tsunami 03-03-2008 13:12

Re: Advertisements
 
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.

tcviper 03-03-2008 14:10

Re: Advertisements
 
Tsunami AWESOME job mate, no irritating TICK sound when a chat ad appears and works very well! Thank you.

bl4nk 03-03-2008 14:57

Re: Advertisements
 
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. :oops:

pRED* 03-03-2008 15:08

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

Approved.

DJ Tsunami 03-03-2008 15:09

Re: Advertisements
 
Thanks for approving, and thanks for the code bl4nk, I will incorporate it.

[Arnold] 03-03-2008 15:22

Re: Advertisements
 
Great and absolutely missing! Hope you keep supporting it.

FrostbyteX 03-03-2008 15:22

Re: Advertisements
 
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].


All times are GMT -4. The time now is 06:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.