Auto Message in Chat

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Auto Message in Chat

Postby Painkiller » Sun Nov 28, 2021 10:57 am

Hello Community and SP Team,

How can I also tell the plugin to automatically display the commands in the chat so that players know what commands are available for the chat.

Example: Type "Ranking" in the chat to see your stats.

Best with multiple color codes to highlight it.

Syntax: Select all

from messages import VGUIMenu
from commands.say import SayCommand

def motd(index, title, site, show=True):
name = 'info'
subkeys = {'title': title, 'type': '2', 'msg': site}

VGUIMenu(name, subkeys=subkeys, show=show).send(index)


Thanks in Advance
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: Auto Message in Chat

Postby velocity » Sun Nov 28, 2021 11:31 am

Try this:

Syntax: Select all

from messages import SayText2
from listeners.tick import Repeat
from listeners import OnLevelInit
from random import choice
MSG = ['Example: Type "Ranking" in the chat to see your stats.',
'other message #green colors..']
MSG_INTERVAL = 120


@Repeat
def _msg_repeater():
rng_choice = choice(MSG)
SayText2(str(rng_choice)).send()


def msg_repeater_start():
_msg_repeater.cancel_on_level_end = True
_msg_repeater.start(MSG_INTERVAL)


@OnLevelInit
def _on_level_start(_):
msg_repeater_start()


msg_repeater_start()
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: Auto Message in Chat

Postby Painkiller » Sun Nov 28, 2021 11:48 am

It works and I was able to match colors to some extent.

Thanks a lot

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 34 guests