Page 1 of 1

[HL2:DM] Entity View

Posted: Fri Feb 18, 2022 2:43 pm
by cssbestrpg
Hi, i have issue getting my code work properly in hl2dm.
When i look at health/suit charger it doesn't get any messages when suppose to.

Syntax: Select all

from messages import HudMsg
from listeners.tick import Repeat
from filters.players import PlayerIter
from colors import CYAN

_HUDMSG_X = -1
_HUDMSG_Y = 0.60
_HUDMSG_EFFECT = 0
_HUDMSG_FADEOUT = 0
_HUDMSG_HOLDTIME = 2
_HUDMSG_FXTIME = 0
_HUDMSG_CHANNEL = 5

msg = []

def check_msg():
for player in PlayerIter('alive'):
target = player.view_entity
if target and target.classname == 'item_healthcharger':
msg = 'I am not getting executed'
hudmessage(msg, player.index, CYAN)
if target and target.classname == 'item_suitcharger':
msg = 'I am not getting executed'
hudmessage(msg, player.index, CYAN)

def hudmessage(text, index, color):
HudMsg(text, color1=color, x=_HUDMSG_X, y=_HUDMSG_Y,
effect=_HUDMSG_EFFECT,
fade_out=_HUDMSG_FADEOUT,
hold_time=_HUDMSG_HOLDTIME,
fx_time=_HUDMSG_FXTIME,
channel=_HUDMSG_CHANNEL
).send(index)

msg_check = Repeat(check_msg)
msg_check.start(0.1)

Re: [HL2:DM] Entity View

Posted: Fri Feb 18, 2022 11:56 pm
by satoon101
I'm not sure what to tell you. It works perfectly fine when I test it.

Re: [HL2:DM] Entity View

Posted: Sat Feb 19, 2022 12:27 am
by daren adler
I also used it and works great, i did have to change the channel number, but other then that works great.

Re: [HL2:DM] Entity View

Posted: Sat Feb 19, 2022 10:15 am
by cssbestrpg
I found the issue, i should have use elif instead if word for each check entity, after i changed it to elif it started working fine on my side