[HL2:DM] Mini Scoreboard Always display
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
[HL2:DM] Mini Scoreboard Always display
Would it be possible to write a plugin for hl2dm,
What exactly does that indicate?
It is displayed up in the middle with a timeleft.
First place, last place with name and kills.
Thanks in Advance
1 place | Calle | 12 Kills
5 last place | RocKsPainkiller | 9 Kills
What exactly does that indicate?
It is displayed up in the middle with a timeleft.
First place, last place with name and kills.
Thanks in Advance
1 place | Calle | 12 Kills
5 last place | RocKsPainkiller | 9 Kills
Last edited by Painkiller on Tue Jun 06, 2017 2:29 pm, edited 1 time in total.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] mini scoreboard
Hi mates,
can anybody help me for this ?
(You could display game_text in HL2:DM)
can anybody help me for this ?
(You could display game_text in HL2:DM)
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] mini scoreboard
No one idea please?
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
Please help me with this idea
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
Nobody can help for it?
Re: [HL2:DM] Mini Scoreboard Always display
Give this a try:
Syntax: Select all
#mini_scoreboard.py
from colors import Color
from events import Event
from players.entity import Player
from players.helpers import index_from_userid
from filters.players import PlayerIter
from messages import HudMsg
from listeners import OnLevelEnd
from listeners.tick import Repeat
# how often should the mini scoreboard refresh? (default: 0.49 seconds)
UPDATE_RATE = 0.49
# text colors
FIRST_PLACE_COLOR = Color(255, 187, 43)
LAST_PLACE_COLOR = Color(200, 200, 200)
FIRST_PLACE = None
LAST_PLACE = None
# =============================================================================
# >> PLAYER INSTANCE
# =============================================================================
player_instance = {}
def get_player_instance(userid):
if userid not in player_instance:
player_instance[userid] = Player(index_from_userid(userid))
return player_instance[userid]
def get_all_players():
return list(player_instance.values())
# =============================================================================
# >> EVENTS
# =============================================================================
def load():
for player in PlayerIter():
if player.userid not in player_instance:
player_instance[player.userid] = player
get_new_first_place()
get_new_last_place()
@Event('player_activate')
def player_joined(event):
userid = event.get_int('userid')
player = get_player_instance(userid)
global FIRST_PLACE
if not FIRST_PLACE:
FIRST_PLACE = player
return
if FIRST_PLACE.kills < 0:
FIRST_PLACE = player
get_new_last_place()
global LAST_PLACE
if not LAST_PLACE or LAST_PLACE.kills > 0:
LAST_PLACE = player
@Event('player_disconnect')
def player_left(event):
userid = event.get_int('userid')
if userid in player_instance:
del player_instance[userid]
if FIRST_PLACE and userid == FIRST_PLACE.userid:
get_new_first_place()
if LAST_PLACE and userid == LAST_PLACE.userid:
get_new_last_place()
@OnLevelEnd
def map_changing():
player_instance.clear()
global FIRST_PLACE
FIRST_PLACE = None
global LAST_PLACE
LAST_PLACE = None
@Event('player_death')
def player_died(event):
userid_a = event.get_int('attacker')
# killed by world
if userid_a == 0:
return
attacker = get_player_instance(userid_a)
global FIRST_PLACE
if attacker.kills > FIRST_PLACE.kills:
FIRST_PLACE = attacker
get_new_last_place()
# =============================================================================
# >> MINI SCOREBOARD RENDER / PRINT
# =============================================================================
def render_mini_scoreboard():
if FIRST_PLACE:
HudMsg(message='1 | {player_name} | {player_kills} kills'.format(
player_name=FIRST_PLACE.name,
player_kills=FIRST_PLACE.kills),
x=-1, y=0,
color1=FIRST_PLACE_COLOR,
fade_in=0.05, fade_out=0.05,
hold_time=UPDATE_RATE * 2, fx_time=0, channel=1).send()
if LAST_PLACE:
place = len(player_instance)
HudMsg(message='{player_place} | {player_name} | {player_kills} kills'.format(
player_place=place,
player_name=LAST_PLACE.name,
player_kills=LAST_PLACE.kills),
x=-1, y=0.03,
color1=LAST_PLACE_COLOR,
fade_in=0.05, fade_out=0.05,
hold_time=UPDATE_RATE * 2, fx_time=0, channel=2).send()
render_loop = Repeat(render_mini_scoreboard)
render_loop.start(UPDATE_RATE)
# =============================================================================
# >> HELPER FUNCTIONS
# =============================================================================
def get_new_first_place():
players = get_all_players()
new_first_place = None
for player in players:
if LAST_PLACE and player.userid == LAST_PLACE.userid:
continue
if not new_first_place:
new_first_place = player
continue
if player.kills > new_first_place.kills:
new_first_place = player
global FIRST_PLACE
FIRST_PLACE = new_first_place
def get_new_last_place():
players = get_all_players()
new_last_place = None
for player in players:
if FIRST_PLACE and player.userid == FIRST_PLACE.userid:
continue
if not new_last_place:
new_last_place = player
continue
if player.kills < new_last_place.kills:
new_last_place = player
global LAST_PLACE
LAST_PLACE = new_last_place
Re: [HL2:DM] Mini Scoreboard Always display
I think that might work, but I really don't think you need to keep track of all the players like that. Retrieving the kills on the fly should work just fine. Maybe something like (untested):
I don't believe that HL2:DM allows for spectators. But, if I am wrong, I can attempt to fix that later.
Syntax: Select all
from time import time
import colors
from cvars import ConVar
from filters.players import PlayerIter
from listeners import OnLevelInit
from listeners.tick import Repeat
from messages import HudMsg
# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Set to the number of seconds between refreshing the messages
UPDATE_RATE = 1.0
# Set to the color to use for the First Place player
# Choices can be found starting here:
# http://wiki.sourcepython.com/developing/modules/colors.html#colors.BLACK
FIRST_PLACE_COLOR = 'ORANGE'
# Set to the color to use for the Last Place player
# Choices can be found starting here:
# http://wiki.sourcepython.com/developing/modules/colors.html#colors.BLACK
LAST_PLACE_COLOR = 'LIGHT_BLUE'
# Set to the color to use for the Timeleft message
# Choices can be found starting here:
# http://wiki.sourcepython.com/developing/modules/colors.html#colors.BLACK
TIME_LEFT_COLOR = 'WHITE'
# =============================================================================
# >> END OF CONFIGURATION
# =============================================================================
_common_kwargs = {
'x': -0.7,
'fade_in': 0.0,
'fade_out': 0.0,
'hold_time': UPDATE_RATE + 0.04,
'fx_time': .07,
}
FIRST_PLACE_MESSAGE = HudMsg(
message='1 | {player.name} | {player.kills}',
y=0.0,
color1=getattr(colors, FIRST_PLACE_COLOR, colors.ORANGE),
channel=1,
**_common_kwargs
)
LAST_PLACE_MESSAGE = HudMsg(
message='{place} | {player.name} | {player.kills}',
y=0.03,
color1=getattr(colors, LAST_PLACE_COLOR, colors.LIGHT_BLUE),
channel=2,
**_common_kwargs
)
TIME_LEFT_MESSAGE = HudMsg(
message='{minutes}:{seconds}',
x=-1.0,
y=0.0,
fade_in=0.0,
fade_out=0.0,
hold_time=0.5,
fx_time=0,
color1=getattr(colors, TIME_LEFT_COLOR, colors.WHITE),
channel=3,
)
map_end_time = None
mp_timelimit = ConVar('mp_timelimit')
@OnLevelInit
def load(map_name=None):
global map_end_time
timelimit = mp_timelimit.get_int() * 60
map_end_time = time() + timelimit if timelimit else None
@Repeat
def _send_messages():
players = list(PlayerIter())
total_places = len(players)
if total_places < 2:
return
sorted_players = sorted(
players,
key=lambda player: (player.kills, -player.deaths),
reverse=True,
)
FIRST_PLACE_MESSAGE.send(
player=sorted_players[0],
)
LAST_PLACE_MESSAGE.send(
player=sorted_players[~0],
place=total_places,
)
_send_messages.start(UPDATE_RATE)
@Repeat
def _send_timeleft():
if map_end_time is None:
return
timeleft = map_end_time - time()
if timeleft < 0:
return
minutes, seconds = divmod(timeleft, 60)
TIME_LEFT_MESSAGE.send(
minutes=int(minutes),
seconds=int(seconds),
)
_send_timeleft.start(0.3)
I don't believe that HL2:DM allows for spectators. But, if I am wrong, I can attempt to fix that later.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
Ok I tried both plugins VinciT and satoon101.
At VinciT everything worked as far as desired only the timeleft display the map round did not go.
At satoon101 The display blinked a bit and it only showed the player at the last place. Timeleft was not displayed.
Thank you first until then mates
At VinciT everything worked as far as desired only the timeleft display the map round did not go.
At satoon101 The display blinked a bit and it only showed the player at the last place. Timeleft was not displayed.
Thank you first until then mates
Re: [HL2:DM] Mini Scoreboard Always display
Painkiller wrote:At satoon101 The display blinked a bit and it only showed the player at the last place. Timeleft was not displayed.
I fixed those 2 issues in my plugin above. I honestly missed that the "timeleft" was a part of this request. I will look into that one after work tonight.
Re: [HL2:DM] Mini Scoreboard Always display
Wow, that's much cleaner than what I did.
I tried to cache stuff as much as I could, cause I thought PlayerIter created new player objects every time it ran.
I tried to cache stuff as much as I could, cause I thought PlayerIter created new player objects every time it ran.
Re: [HL2:DM] Mini Scoreboard Always display
VinciT wrote:I thought PlayerIter created new player objects every time it ran.
It does, but it's not like that takes a long time to do. I prefer to only create roundabout optimizations when it is absolutely necessary.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
satoon101 wrote:Painkiller wrote:At satoon101 The display blinked a bit and it only showed the player at the last place. Timeleft was not displayed.
I fixed those 2 issues in my plugin above. I honestly missed that the "timeleft" was a part of this request. I will look into that one after work tonight.
Yes now is ok.
thanks for soon timeleft
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
satoon101 wrote:Painkiller wrote:At satoon101 The display blinked a bit and it only showed the player at the last place. Timeleft was not displayed.
I fixed those 2 issues in my plugin above. I honestly missed that the "timeleft" was a part of this request. I will look into that one after work tonight.
Hi,
You could already make progress in order to timeleft?
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
As far as it works well but it still seems to admit to a regulating problem.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
satoon101 wrote:Updated post above to include the timeleft.
Can you please set me this as on the first picture?
Timleft left and then right scoreboard.
I tried it but it disappears the scoreboard when I put the coordinates.
I tried to set an x coordinate.
Syntax: Select all
FIRST_PLACE_MESSAGE = HudMsg(
message='1 | {player.name} | {player.kills}',
y=0.0,
color1=getattr(colors, FIRST_PLACE_COLOR, colors.ORANGE),
channel=1,
**_common_kwargs
)
LAST_PLACE_MESSAGE = HudMsg(
message='{place} | {player.name} | {player.kills}',
y=0.03,
color1=getattr(colors, LAST_PLACE_COLOR, colors.LIGHT_BLUE),
channel=2,
**_common_kwargs
)
TIME_LEFT_MESSAGE = HudMsg(
message='{minutes}:{seconds}',
x=0.3,
y=0.0,
fade_in=0.0,
fade_out=0.0,
hold_time=0.5,
fx_time=0,
color1=getattr(colors, TIME_LEFT_COLOR, colors.WHITE),
channel=3,
)
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
Hi mates, could someone put it in the right position?
I do not get it.
I do not get it.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
Hello, after the last SP update I have errors in the display
Could anyone fix this?
Could anyone fix this?
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: [HL2:DM] Mini Scoreboard Always display
I installed the latest SP version
Now it looks like this and the timeleft display is missing completely.
it should look like this(in the center top):
[/quote]
Now it looks like this and the timeleft display is missing completely.
Painkiller wrote:As far as it works well but it still seems to admit to a regulating problem.
it should look like this(in the center top):
[/quote]
Who is online
Users browsing this forum: No registered users and 5 guests