Page 1 of 1

[HL2:DM] Advertisment

Posted: Sun May 14, 2017 7:23 pm
by Painkiller
Hello community,

Someone could make me a advertisment plugin?



-advertisment (https://forums.alliedmods.net/showthrea ... 5?t=155705)

Re: [HL2:DM] Advertisment

Posted: Fri May 26, 2017 5:48 pm
by Painkiller
Wanted to ask again if now, someone can help?

Re: [HL2:DM] Advertisment

Posted: Fri May 26, 2017 6:40 pm
by existenz
A really simple advert with random advert all rounds in chat. Maybe later i can make a more improve plugin.

Syntax: Select all

from random import choice

from events import Event
from messages import SayText2

## GLOBAL

ADVERTS = [
'Advert 1',
'Advert 2',
'Advert 3',
]

## EVENT

@Event('round_start')
def _on_round_start(event_data):
message = choice(ADVERTS)
SayText2(message).send()

Re: [HL2:DM] Advertisment

Posted: Fri May 26, 2017 8:48 pm
by Painkiller
Not work in HL2DM

Re: [HL2:DM] Advertisment

Posted: Fri May 26, 2017 9:07 pm
by satoon101
There is no round_start in HL2:DM. You would have to use a Repeat.

Re: [HL2:DM] Advertisment

Posted: Fri May 26, 2017 9:56 pm
by satoon101
From a simple standpoint, maybe something like this (untested):

Syntax: Select all

from itertools import cycle

from listeners.tick import Repeat
from messages import SayText2

# Set to the time (in minutes) between adverts
MINUTES_BETWEEN_ADVERTS = 3

# Add all adverts in the list below
ADVERTS = cycle([
'Advert 1',
'Advert 2',
'Advert 3',
])


@Repeat
def _send_advert():
SayText2(next(ADVERTS)).send()

_send_advert.start(MINUTES_BETWEEN_ADVERTS * 60)

Re: [HL2:DM] Advertisment

Posted: Sat May 27, 2017 6:39 am
by Painkiller
Yes works good.

Re: [HL2:DM] Advertisment

Posted: Sat May 27, 2017 7:48 am
by existenz
Oh sorry ! I don't check if HL2:DM has this event ...

Re: [HL2:DM] Advertisment

Posted: Sat May 27, 2017 7:58 am
by Ayuto
Well, it exists, but it doesn't get fired. :grin:

Re: [HL2:DM] Advertisment

Posted: Sat May 27, 2017 9:16 am
by existenz
Lol ! It's weird ...