[CS:GO] Warmup HudDestination

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

[CS:GO] Warmup HudDestination

Postby Kami » Tue Feb 02, 2021 8:26 pm

Hey guys,

I was wondering if it was possible to send a message of the same type as the warmup message in CS:GO to a player.
I've read at some places that it's a client side message, so I'm not sure we can do anything about it.
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [CS:GO] Warmup HudDestination

Postby VinciT » Tue Feb 02, 2021 10:25 pm

Not sure about the warmup message specifically, but you can get something that resembles that:

Syntax: Select all

# ../win_message/win_message.py

# Source.Python
from events.manager import game_event_manager
from players.entity import Player


def send_win_message(message='', recipients=None):
"""Creates and sends the 'cs_win_panel_round' event.

Args:
message (str): Message to send, supports some HTML tags.
recipients: List/tuple of player indexes that should receive the
message.
"""
event = game_event_manager.create_event('cs_win_panel_round')
event.set_string('funfact_token', message)

# Should the message be sent to everyone on the server?
if recipients is None:
game_event_manager.fire_event(event)

# Or have the recipients been specified?
else:
for index in recipients:
try:
# Try to get a Player instance.
Player(index).base_client.fire_game_event(event)
except ValueError:
continue

# When firing events to players/clients directly, we need to free it
# once we're done with it.
game_event_manager.free_event(event)

Here's an example:

Syntax: Select all

from commands import CommandReturn
from commands.client import ClientCommand


@ClientCommand('win_msg')
def win_msg_cmd(command, index):
send_win_message(
message='One line..\nTwo lines..\nThree lines?!',
recipients=(index,)
)

return CommandReturn.BLOCK
Image

The message should stay on the player's screen until the round ends. If you want to remove it beforehand - just send an empty message:

Syntax: Select all

# The 'message' argument is an empty string by default. Just specify from which
# player(s) you want to remove the message/panel.
send_win_message(recipients=(index,))

One thing to note is that the message is shown after a one second delay. Oh and another thing, you can use some HTML tags to style the text, I've only messed around with the color though:

Syntax: Select all

# This will be sent to everyone.
send_win_message(
message='<font color="#FF0000">RED TEXT, MUST BE IMPORTANT</font>')


Edit: Added a try/catch in case an invalid index was specified.
ImageImageImageImageImage

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 18 guests