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

MjrNuT 03-03-2008 16:02

Re: Advertisements
 
Quote:

Originally Posted by Extreme_One (Post 592556)
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:

true dat!!

DJ Tsunami 03-03-2008 16:20

Re: Advertisements
 
I could do that Frostbyte, but it's nicer to have it say on/off than 1/0 isn't it? And don't make me do {IF}{ELSE} :P I'll think about it anyway.

Extreme_One 03-03-2008 17:22

Re: Advertisements
 
Any chance you can have {TIMELEFT} read the number of rounds remaining if the map's set to mp_timelimit 0 and suffix with the word Rounds when appropriate?

X Rounds if mp_timelimit 0


(I need to use mp_maxrounds instead of mp_timelimit for cp_badlands :| )

FrostbyteX 03-03-2008 17:29

Re: Advertisements
 
Quote:

Originally Posted by DJ Tsunami (Post 592680)
I could do that Frostbyte, but it's nicer to have it say on/off than 1/0 isn't it? And don't make me do {IF}{ELSE} :P I'll think about it anyway.

Check the cvar limits. If it's 0, 1 then print On/Off.

fattitj 03-03-2008 19:36

Re: Advertisements
 
i set the interval to 300, but ads are still appearing every 30 secs

ThatGuy 03-03-2008 19:44

Re: Advertisements
 
Sweet ! thanks!

BrutalGoerge 03-03-2008 20:39

Re: Advertisements
 
awesome plugin, works great. :D

seemed like bugs thought of a way to color that chat messages, maybe u can thief some his code. XD

DJ Tsunami 03-03-2008 21:03

Re: Advertisements
 
fattitj: It needs a mapchange, I didn't bother to make it update when you change the cvar. I'll obviously look into everything else mentioned, it's just alot of requests, so one feature at a time :)

DJ Tsunami 03-04-2008 06:25

Re: Advertisements
 
Do you guys know where I can find a list of the color constants? I found like COLOR_DEFAULT (1), COLOR_TEAM (3) and COLOR_GREEN (4) for SourceMod, and COLOR_NORMAL, COLOR_RED, COLOR_BLUE, COLOR_GRAY and COLOR_GREEN for AMX, but I'm not sure if those all work for SourceMod too. Plus I got 3 shades of green for 3, 4 and 5... I'm guessing I can't use all the colors that work for sm_tsay :(

FrostbyteX 03-04-2008 12:09

Re: Advertisements
 
DJ, the COLOR_GREEN, COLOR_TEAM and COLOR_DEFAULT are all colors for chat messages. Their color is exactly as they are defined, and are used as I posted above.

As far as I'm aware, those are the only chat message colors available.

Steve

Extreme_One 03-04-2008 12:14

Re: Advertisements
 
I'm pretty sure COLOR_TEAM won't work for PrintToChatAll

This thread could prove useful: http://forums.alliedmods.net/showthread.php?t=66654

DJ Tsunami 03-04-2008 13:35

Re: Advertisements
 
It works, but it's always light green because the message is sent by the server. To be able to have red and blue text (using TF2 as an example, not sure what those colors are in other games) I'd have to send it from a currently playing client with SayText2, which means that if no one is playing those colors won't work. So I'm not sure if that's what you guys want... Implementing the 3 shades of green is easy, so.

FrostbyteX 03-04-2008 13:39

Re: Advertisements
 
Quote:

Originally Posted by DJ Tsunami (Post 593041)
It works, but it's always light green because the message is sent by the server. To be able to have red and blue text (using TF2 as an example, not sure what those colors are in other games) I'd have to send it from a currently playing client with SayText2, which means that if no one is playing those colors won't work. So I'm not sure if that's what you guys want... Implementing the 3 shades of green is easy, so.

I thought the color had to do with the target client... Never tested that.

DJ Tsunami 03-04-2008 14:19

Re: Advertisements
 
Nope, when I target it at me when sending it from the server it's still light green. I could of course loop through the users and use them as both the target and sender, but that would be a lot of commands if it can also be done with one (but without the team colors)... I don't know, on the other hand it doesn't get executed that often so I'm sure SM could handle it.

Edit: alright, what I did now was loop through every player, and use light green if they're a spectator, and their team color if they're playing. I guess that's the best way to do it.

DJ Tsunami 03-05-2008 09:23

Re: Advertisements
 
Alright, version 0.2 is up now. I've done everything requested except:
  • the rounds left when mp_timelimit is 0. I have to count the rounds myself and I think this works differently for every mod, so it's going to take more time than I thought :)
  • The cvars in the ads, this just takes a bit of time so I figured I'd release this version and get the colored chat messages out of the way.
Ofcourse what was added is described in the changelog.

Extreme_One 03-05-2008 10:23

Re: Advertisements
 
Cool! Glad to see colours. Thank you.

Who is the plugin looking at for the {TEAM} colour?

Are you saying it will display the colour differently for everyone on the server depending on what team they're on or whether they're in spec?

DJ Tsunami 03-05-2008 11:27

Re: Advertisements
 
Yes, to take the example of TF2: if the player that the advertisement is sent to is on Blue it will use the blue color, if he's on Red the red color, and if he's in spectate it's light green.

Extreme_One 03-05-2008 16:43

Re: Advertisements
 
It works really well DJ Tsunami.

Thank you.

+1 karma :D

cozmicshredder 03-10-2008 12:53

Re: Advertisements
 
Using Advertisement version 0.2 compiled with Sourcemod version 1924

Errors:

L 03/10/2008 - 00:00:00: [SM] Native "StartMessage" reported: Invalid message name: "SayText2"
L 03/10/2008 - 00:00:00: [SM] Displaying call stack trace for plugin "advertisements.smx":
L 03/10/2008 - 00:00:00: [SM] [0] Line 210, C:\Users\cozmicshredder\Documents\GAMESERVERS \SOURCEMOD\sourcemod-r1924\addons\sourcemod\scripting\include\user messages.inc::StartMessageOne()
L 03/10/2008 - 00:00:00: [SM] [1] Line 199, advertisements.sp::SayText2()
L 03/10/2008 - 00:00:00: [SM] [2] Line 134, advertisements.sp::Timer_DisplayAds()

tcviper 03-10-2008 17:56

Re: Advertisements
 
That's an Insurgency issue who uses a different way of displaying msgs, thats why its not working ;)

Private Dyin 03-10-2008 18:53

Re: Advertisements
 
I just downloaded the smx provided on the first post and installed. Only C,M and T messages work in Insurgency for me. :)

DontWannaName 03-13-2008 02:00

Re: Advertisements
 
While I was brushing my teeth I though of a new idea. Maybe people with reserved flags did have to see specified messages so they have an ad free experience?...

BrutalGoerge 03-13-2008 03:16

Re: Advertisements
 
Quote:

Originally Posted by DontWannaName (Post 596317)
While I was brushing my teeth I though of a new idea. Maybe people with reserved flags did have to see specified messages so they have an ad free experience?...

same with that reskick thing. :D
good ideare

DJ Tsunami 03-13-2008 14:23

Re: Advertisements
 
Yeah, I can do that :) I'll try to fix up and add some stuff somewhere in the next few days.

DontWannaName 03-13-2008 18:47

Re: Advertisements
 
Ok cool thanks. btw I meant didnt have to see specific messages. Like the donate today ones :P

Extreme_One 03-13-2008 18:55

Re: Advertisements
 
Could be cool if specific messages were disabled for those with a specific admin flag. (reserved flag would be ideal!)

I wouldn't like to block all adverts for those with the flag. :)

Mosalar 03-14-2008 11:54

Re: Advertisements
 
This works fine on our tf2 server, but does not on the DoDs. Here is the error.
Code:

L 03/14/2008 - 15:47:12: [SM] Native "StartMessage" reported: Invalid message name: "SayText2"
L 03/14/2008 - 15:47:12: [SM] Displaying call stack trace for plugin "advertisements.smx":
L 03/14/2008 - 15:47:12: [SM]  [0]  Line 210, /home/groups/sourcemod/compiler/include/usermessages.inc::StartMessageOne()
L 03/14/2008 - 15:47:12: [SM]  [1]  Line 199, /home/groups/alliedmodders/forums/files/3/4/6/6/8/24253.attach::SayText2()
L 03/14/2008 - 15:47:12: [SM]  [2]  Line 134, /home/groups/alliedmodders/forums/files/3/4/6/6/8/24253.attach::Timer_DisplayAds()

I haven't tried any of the other print options, all I want is "s" or chat output.

[Arnold] 03-17-2008 06:49

Re: Advertisements
 
Strange. From time to time the plugin skips advertising. If you switch into spec mode you get all the ads, if you join a team you don't. A "sm_advertisements_reload" doesn't help it, nor does a sm plugins reload [x]. After some time (and reconnects) you get your ads again, even after joining a team (I thought of some kind of anti-flood-problem).

Maybe you can check that. Thx in advance.

LocutusH 03-17-2008 07:03

Re: Advertisements
 
And also, this is not working for me:

T {CYAN}{CURRENTMAP} Advertisement text

Instead of making the ad CYAN colored, it writes this in the upper left corner
{CYAN}de_dust Advertisement text

So the color tag is not handled.

If i remove the color tag, so that the {CURRENTMAP} is the first and only, it works as it should, just that its white.
The coloring only works, if there is no other tag after the color tag.

flubber 03-17-2008 11:54

Re: Advertisements
 
Hi,
Any chance to have a 24hours clock?


All times are GMT -4. The time now is 03:22.

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