Page 2 of 3

Re: [HL2:DM] Deathmsg Help

Posted: Thu Nov 12, 2020 9:00 am
by Painkiller
VinciT wrote:
Painkiller wrote:I noticed that my deathmessage no longer works.

I probably noticed it quite late, maybe something was changed in SP?

Maybe someone could fix it.
The channel used for the HudMsg() in this plugin conflicts with npc_points - they both use channel 1. You could change the channel to 0 and see if it works then.
Additionally, since npc_points uses more than 1 channel (by default), you can set NOTIFICATION_MAX to 2 and use channel 3 for this plugin.



This will be a problem because I have several other plugins that use 1-2-3 channels.

If i kill a player and no npc should still show what it does not do

Re: [HL2:DM] Deathmsg Help

Posted: Thu Dec 17, 2020 11:10 am
by Painkiller
This is the original script for/from Eventscripts could someone take this fully for SP.

The availablene from the first error request, was not completely rewritten then.

I hope someone can do this for me.

Thanks in Advance and Happy XMAS.


Syntax: Select all

import es
import playerlib
import math
import gamethread
import time

info = es.AddonInfo()
info.name = "RocKs Death Message"
info.version = "3.0"
info.author = "Kami"
info.url = "www.rocks-clan.de"
info.description = "RocKs Death Message"

es.ServerVar(info.name, info.version, info.description).makepublic()

SAME_TIME_LIMIT = 1

killdict = {}
players = dict()

def es_map_start(ev):
es.reload('deathmsg')

def load():
for userid in es.getUseridList():
killdict[userid] = {}
killdict[userid]['kills'] = 0
killdict[userid]['killstreak'] = 0
killdict[userid]['slamkills'] = 0

def unload():
for userid in es.getUseridList():
del killdict[userid]

def player_activate(ev):
userid = int(ev['userid'])
killdict[userid] = {}
killdict[userid]['kills'] = 0
killdict[userid]['killstreak'] = 0

def showMessage1(message, userid):
index = es.createentity('game_text', 'MyMsgEntity')
es.entitysetvalue(index, 'origin', '0 0 0')
es.entitysetvalue(index, 'spawnflags', 0)
es.entitysetvalue(index, 'channel', 4)
es.entitysetvalue(index, 'fxtime', 1.0)
es.entitysetvalue(index, 'holdtime', 8)
es.entitysetvalue(index, 'fadeout', 1.5)
es.entitysetvalue(index, 'fadein', 0.05)
es.entitysetvalue(index, 'color2', '255 255 0')
es.entitysetvalue(index, 'color', '205 0 0')
es.entitysetvalue(index, 'effect', 2)
es.entitysetvalue(index, 'y', 0.5)
es.entitysetvalue(index, 'x', -1)
es.entitysetvalue(index, 'message', message)
es.server.insertcmd(
'es_spawnentity %s;'% index + \
'es_fire %s MyMsgEntity Display;'% userid + \
'es_fire %s MyMsgEntity Kill'% userid
)

def showMessage2(message):
userid = es.getuserid()
if not userid:
return
index = es.createentity('game_text', 'MyMsgEntity')
es.entitysetvalue(index, 'origin', '0 0 0')
es.entitysetvalue(index, 'spawnflags', 1)
es.entitysetvalue(index, 'channel', 2)
es.entitysetvalue(index, 'fxtime', 1.0)
es.entitysetvalue(index, 'holdtime', 8)
es.entitysetvalue(index, 'fadeout', 1.5)
es.entitysetvalue(index, 'fadein', 0.05)
es.entitysetvalue(index, 'color2', '255 255 0')
es.entitysetvalue(index, 'color', '205 0 0')
es.entitysetvalue(index, 'effect', 2)
es.entitysetvalue(index, 'y', -0.88)
es.entitysetvalue(index, 'x', 0.01)
es.entitysetvalue(index, 'message', message)
es.server.insertcmd(
'es_xspawnentity %i;'% index + \
'es_xfire %i MyMsgEntity Display;'% userid + \
'es_xfire %i MyMsgEntity Kill'% userid
)

def player_death(ev):
userid = int(ev['userid'])
attacker = int(ev['attacker'])
xx,yy,zz = es.getplayerlocation(userid)
x,y,z = es.getplayerlocation(attacker)
distance = (((xx - x) * 2 + (yy - y) * 2 + (zz - z) * 2) * 0.5) / 40.0
if distance < 0:
distance = distance * -1
atk = playerlib.getPlayer(ev['attacker'])
namex = es.getplayername(ev['attacker'])
health = atk.health
armor = atk.armor
kills = float(playerlib.getPlayer(attacker).kills)
deaths = float(playerlib.getPlayer(attacker).deaths)
kdr = kills / deaths
kdr = "%.3f" % kdr
showMessage1('Attacker info:\n Name: %s \n Health: %s \n Armor: %s \n Distance: %s m \n KDR: %s' % (namex, health, armor, round(distance, 2), kdr), userid)



killdict[userid]['slamkills'] = 0
killdict[userid]['killstreak'] = 0
weapon = ev['weapon']
if weapon == "rpg_missile": name = "RPG"
elif weapon == "combine_ball": name = "Combine Ball"
elif weapon == "smg1_grenade": name = "Smg Grenade"
elif weapon == "ar2": name = "AR2"
elif weapon == "crossbow_bolt": name = "Crossbow"
elif weapon == "physcannon": name = "Physcannon"
elif weapon == "pistol": name = "Pistol"
elif weapon == "shotgun": name = "Shotgun"
elif weapon == "smg1": name = "SMG"
elif weapon == "357": name = "357"
elif weapon == "crowbar": name = "a Crowbar"
elif weapon == "stunstick": name = "a Stunstick"
elif weapon == "slam": name = "a Slam"
elif weapon == "grenade_frag": name = "a Grenade"
elif weapon == "physics":
if ev['es_attackerweapon'] == "weapon_physcannon":
name = "Physcannon"
if not ev['es_attackerweapon'] == "weapon_physcannon":
name = "a Barrel"
gamethread.delayed(1, resetkills, (attacker))
now = time.time()
killer, then_time = players.get(attacker, (None, 0))
killdict[attacker]['killstreak'] += 1
if userid != attacker:
killdict[attacker]['kills'] += 1
if userid != attacker:
message = ('%s killed %s with %s'% (ev['es_attackername'], ev['es_username'], name))
if userid == attacker:
message = ('%s commited suicide' % (ev['es_attackername']))
if killdict[attacker]['kills'] >= 2:
message = ('%s killed %s with %s \n%s Multikill!!!' % (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
if killer == userid and now - then_time <= SAME_TIME_LIMIT:
message = ('%s and %s killed eachother at the same time!' % (ev['es_attackername'], ev['es_username']))
if weapon == 'slam':
killdict[attacker]['slamkills'] += 1
if killdict[attacker]['slamkills'] >= 3:
killdict[userid]['slamkills'] = 0
message = ('%s killed %s with %s \n%s is a Slamwhore and will be frozen for 10 seconds!'% (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
if killdict[attacker]['killstreak'] == 12:
message = ('%s killed %s with %s \n%s is Postal!' % (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
if killdict[attacker]['killstreak'] == 24:
message = ('%s killed %s with %s \n%s is Sensei!' % (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
showMessage2(message)
players[userid] = (attacker, now)

def resetkills(attacker):
killdict[attacker]['kills'] = 0

Re: [HL2:DM] Deathmsg Help

Posted: Thu Dec 17, 2020 6:13 pm
by Kami
This should enable the messages shown in the top left corner. I tried to have it show more than one message at once which kinda works. I think VinciT's way of doing it in his Npc points plugin looks better, so maybe he can help.

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from cvars.public import PublicConVar
from events import Event
from listeners.tick import Delay
from messages import HudMsg
from players.entity import Player
from plugins.info import PluginInfo

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================

message_buffer = []

# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
killer = Player.from_userid(attacker)
if victim.userid != killer.userid:
distance = round(killer.origin.get_distance(victim.origin), 2)

kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HudMsg(
message=(
'Attacker info:\n'
'Name: {player.name}\n'
'Health: {player.health}\n'
'Armor: {player.armor}\n'
'Distance: {distance}\n'
'KDR: {kdr:.3f}'
).format(player=killer, distance=distance, kdr=kdr),
x=-1,
y=0.3,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=1,
).send(victim.index)

if victim.userid == killer.userid:
message = "%s committed suicide." % (victim.name)

else:
weapon = game_event['weapon']
if weapon == "rpg_missile": name = "RPG"
elif weapon == "combine_ball": name = "Combine Ball"
elif weapon == "smg1_grenade": name = "Smg Grenade"
elif weapon == "ar2": name = "AR2"
elif weapon == "crossbow_bolt": name = "Crossbow"
elif weapon == "physcannon": name = "Physcannon"
elif weapon == "pistol": name = "Pistol"
elif weapon == "shotgun": name = "Shotgun"
elif weapon == "smg1": name = "SMG"
elif weapon == "357": name = "357"
elif weapon == "crowbar": name = "a Crowbar"
elif weapon == "stunstick": name = "a Stunstick"
elif weapon == "slam": name = "a Slam"
elif weapon == "grenade_frag": name = "a Grenade"
elif weapon == "physics":
if killer.active_weapon.classname == "weapon_physcannon":
name = "Physcannon"
if not killer.active_weapon.classname == "weapon_physcannon":
name = "a Barrel"
message = "%s killed %s with %s." % (killer.name,victim.name,name)

message_buffer.append(message)
Delay(8.0,remove_message,(message,))

formated_message = ""
for x in message_buffer:
formated_message = formated_message+"\n"+x


HudMsg(
message=formated_message,
x=0.01,
y=-0.88,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2,
).send()

def remove_message(message):
if message in message_buffer: message_buffer.remove(message)


This does not include killstreaks, so you will not get a postal message with this.

Re: [HL2:DM] Deathmsg Help

Posted: Thu Dec 17, 2020 10:19 pm
by Painkiller
Thank you very much first of all,

I have tested it and I noticed that the death message is no longer displayed at all.
It should be in the middle and that should be there:

Syntax: Select all

message=(
'Attacker info:\n'
'Name: {player.name}\n'
'Health: {player.health}\n'
'Armor: {player.armor}\n'
'Distance: {distance}\n'
'KDR: {kdr:.3f}'
).format(player=killer, distance=distance, kdr=kdr),


Furthermore, the npc_point should not play a role if I take another channel.
And the kill message in the top left corner sees only killers.
Not all.

The killed should then again only see what I described above.
Please try to take out the multiple displays one below the other in the upper left corner.

Thanks in Advance

This is my actual config:

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from cvars.public import PublicConVar
from events import Event
from listeners.tick import Delay
from messages import HudMsg
from players.entity import Player
from plugins.info import PluginInfo

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================

message_buffer = []

# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
killer = Player.from_userid(attacker)
if victim.userid != killer.userid:
distance = round(killer.origin.get_distance(victim.origin), 2)

kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HudMsg(
message=(
'Attacker info:\n'
'Name: {player.name}\n'
'Health: {player.health}\n'
'Armor: {player.armor}\n'
'Distance: {distance}\n'
'KDR: {kdr:.3f}'
).format(player=killer, distance=distance, kdr=kdr),
x=-1,
y=0.5,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(victim.index)

if victim.userid == killer.userid:
message = "%s committed suicide." % (victim.name)

else:
weapon = game_event['weapon']
if weapon == "rpg_missile": name = "RPG"
elif weapon == "combine_ball": name = "Combine Ball"
elif weapon == "smg1_grenade": name = "Smg Grenade"
elif weapon == "ar2": name = "AR2"
elif weapon == "crossbow_bolt": name = "Crossbow"
elif weapon == "physcannon": name = "Physcannon"
elif weapon == "pistol": name = "Pistol"
elif weapon == "shotgun": name = "Shotgun"
elif weapon == "smg1": name = "SMG"
elif weapon == "357": name = "357"
elif weapon == "crowbar": name = "a Crowbar"
elif weapon == "stunstick": name = "a Stunstick"
elif weapon == "slam": name = "a Slam"
elif weapon == "grenade_frag": name = "a Grenade"
elif weapon == "physics":
if killer.active_weapon.classname == "weapon_physcannon":
name = "Physcannon"
if not killer.active_weapon.classname == "weapon_physcannon":
name = "a Barrel"
message = "%s killed %s with %s." % (killer.name,victim.name,name)

message_buffer.append(message)
Delay(8.0,remove_message,(message,))

formated_message = ""
for x in message_buffer:
formated_message = formated_message+"\n"+x


HudMsg(
message=formated_message,
x=0.01,
y=-0.92,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send()

def remove_message(message):
if message in message_buffer: message_buffer.remove(message)

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 5:45 am
by Kami
Sorry, I think I misunderstood what the kill message in the corner ment.

Try this

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from cvars.public import PublicConVar
from events import Event
from messages import HudMsg
from players.entity import Player
from plugins.info import PluginInfo

# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
killer = Player.from_userid(attacker)
if victim.userid != killer.userid:
distance = round(killer.origin.get_distance(victim.origin), 2)

kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HudMsg(
message=(
'Attacker info:\n'
'Name: {player.name}\n'
'Health: {player.health}\n'
'Armor: {player.armor}\n'
'Distance: {distance}\n'
'KDR: {kdr:.3f}'
).format(player=killer, distance=distance, kdr=kdr),
x=-1,
y=0.3,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(victim.index)

if victim.userid == killer.userid:
message = "%s committed suicide." % (victim.name)

else:
weapon = game_event['weapon']
if weapon == "rpg_missile": name = "RPG"
elif weapon == "combine_ball": name = "Combine Ball"
elif weapon == "smg1_grenade": name = "Smg Grenade"
elif weapon == "ar2": name = "AR2"
elif weapon == "crossbow_bolt": name = "Crossbow"
elif weapon == "physcannon": name = "Physcannon"
elif weapon == "pistol": name = "Pistol"
elif weapon == "shotgun": name = "Shotgun"
elif weapon == "smg1": name = "SMG"
elif weapon == "357": name = "357"
elif weapon == "crowbar": name = "a Crowbar"
elif weapon == "stunstick": name = "a Stunstick"
elif weapon == "slam": name = "a Slam"
elif weapon == "grenade_frag": name = "a Grenade"
elif weapon == "physics":
if killer.active_weapon.classname == "weapon_physcannon":
name = "Physcannon"
if not killer.active_weapon.classname == "weapon_physcannon":
name = "a Barrel"
message = "%s killed %s with %s." % (killer.name,victim.name,name)

HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=RED,
color2=YELLOW,
effect=2,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(killer.index)


I just tested this and it shows the deathmsg to the killed player and the top message to the killer. I disabled the deathmsg when you commit suicide, as you would see your own (incorrect stats).

@Painkiller auf Deutsch: Das mit dem NPC Points bezog sich auf die Punkteanzeige für NPC kills. Die hat VinciT ziemlich gut gemacht, deswegen habe ich es in meinem Post erwähnt. Ansonsten hat das Plugin hier nichts damit zu tun. DIe Channel musst ja im Endeffekt du einstellen, damit sich nichts überschneidet.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 9:21 am
by Painkiller
It seems to be working great so far.
Thanks for that.

When you die it is still shown in the upper left corner who killed who with which weapon.

Could you please take that out.


I also found another error


Code: Select all

2020-12-18 10:16:46 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/events/listener.py", line 92, in fire_game_event
    callback(game_event)
  File "../addons/source-python/plugins/deathmsg/deathmsg.py", line 19, in player_death
    killer = Player.from_userid(attacker)
  File "../addons/source-python/packages/source-python/players/_base.py", line 105, in from_userid
    return cls(index_from_userid(userid), caching=caching)

ValueError: Conversion from "Userid" (0) to "Index" failed.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 5:27 pm
by Kami
Who should see the "who killed who" message? Right now it's set so only the killer sees it. Or do you want the whole message removed for everybody?

This should fix your error:

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from cvars.public import PublicConVar
from events import Event
from messages import HudMsg
from players.entity import Player
from plugins.info import PluginInfo

# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
if attacker == 0:
return
killer = Player.from_userid(attacker)
if victim.userid != killer.userid:
distance = round(killer.origin.get_distance(victim.origin), 2)

kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HudMsg(
message=(
'Attacker info:\n'
'Name: {player.name}\n'
'Health: {player.health}\n'
'Armor: {player.armor}\n'
'Distance: {distance}\n'
'KDR: {kdr:.3f}'
).format(player=killer, distance=distance, kdr=kdr),
x=-1,
y=0.3,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(victim.index)

if victim.userid == killer.userid:
message = "%s committed suicide." % (victim.name)

else:
weapon = game_event['weapon']
if weapon == "rpg_missile": name = "RPG"
elif weapon == "combine_ball": name = "Combine Ball"
elif weapon == "smg1_grenade": name = "Smg Grenade"
elif weapon == "ar2": name = "AR2"
elif weapon == "crossbow_bolt": name = "Crossbow"
elif weapon == "physcannon": name = "Physcannon"
elif weapon == "pistol": name = "Pistol"
elif weapon == "shotgun": name = "Shotgun"
elif weapon == "smg1": name = "SMG"
elif weapon == "357": name = "357"
elif weapon == "crowbar": name = "a Crowbar"
elif weapon == "stunstick": name = "a Stunstick"
elif weapon == "slam": name = "a Slam"
elif weapon == "grenade_frag": name = "a Grenade"
elif weapon == "physics":
if killer.active_weapon.classname == "weapon_physcannon":
name = "Physcannon"
if not killer.active_weapon.classname == "weapon_physcannon":
name = "a Barrel"
message = "%s killed %s with %s." % (killer.name,victim.name,name)

HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=RED,
color2=YELLOW,
effect=2,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(killer.index)

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 5:36 pm
by PEACE
Just tried this and once I add custom weapons to it it will not precashe , is it because it only finds the hl2 weapons ?

/Peace

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 5:47 pm
by Kami
The plugin uses a very cheap way to create the messages. Instead of having an automated system to check for the weapon every weapon name is hardcoded into the plugin. If you want to add a weapon name you'll need to know the weapon entity name and then add it to the big "elif" block in the code.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 5:53 pm
by PEACE
Yes i did this but then it wont precache , I use to use the old one in ES PY and it worked fine but when i put the new weapons in elif no precache

Im using the custon guns mod if that helps you \
and i use Bots so I want all kills to show not just to attacker please


/Peace

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 6:49 pm
by Kami
If you let me know what the weapon is called I can add it for you.

The entity name (weapon_?) and the actual name you give the weapon.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 7:02 pm
by PEACE
Kami ,

elif weapon == "PlasmaRifle": name = "Ionic Blast"
elif weapon == "minigun": name = "Minigun"
elif weapon == "oicw": name = "Oicw"
elif weapon == "annabelle": name = "Annabelle Rifle"
elif weapon == "gauss": name = "Gauss Rifle"
elif weapon == "f2000": name = "F2000"
elif weapon == "sniper": name = "Sniper Rifle"
elif weapon == "sniper2": name = "Sniper2 Rifle"
elif weapon == "thompson": name = "Thompson MG"
elif weapon == "egon": name = "Gluon"
elif weapon == "gaussrif": name = "Pulse Gauss"
elif weapon == "laser": name = "Laser Rifle"
elif weapon == "Q2Blaster": name = "Q2Blaster"
elif weapon == "chargebow": name = "chargebow"
elif weapon == "pulsemg": name = "Pulse MG"
elif weapon == "superplasmagun": name = "superplasma"
elif weapon == "guitar": name = "Heavy Metal"
elif weapon == "catgun": name = "A Pussy"
elif weapon == "4lyx": name = "Alyx Gun"
elif weapon == "sawedoffshotgun": name = "sawedoffshotgun"

this is what i had in the old one and thanks for your time


/peace

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 8:23 pm
by satoon101
It might be easier to use a dictionary to store the display names for each weapon than an expanding list of elif statements.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 9:02 pm
by Painkiller
@PEACE

Would it be possible to send me some weapons or are they private?
If it is private I understand that I have some myself which is not for the community "today".

PEACE wrote:Kami ,

elif weapon == "PlasmaRifle": name = "Ionic Blast"
elif weapon == "minigun": name = "Minigun"
elif weapon == "oicw": name = "Oicw"
elif weapon == "annabelle": name = "Annabelle Rifle"
elif weapon == "gauss": name = "Gauss Rifle"
elif weapon == "f2000": name = "F2000"
elif weapon == "sniper": name = "Sniper Rifle"
elif weapon == "sniper2": name = "Sniper2 Rifle"
elif weapon == "thompson": name = "Thompson MG"
elif weapon == "egon": name = "Gluon"
elif weapon == "gaussrif": name = "Pulse Gauss"
elif weapon == "laser": name = "Laser Rifle"
elif weapon == "Q2Blaster": name = "Q2Blaster"
elif weapon == "chargebow": name = "chargebow"
elif weapon == "pulsemg": name = "Pulse MG"
elif weapon == "superplasmagun": name = "superplasma"
elif weapon == "guitar": name = "Heavy Metal"
elif weapon == "catgun": name = "A Pussy"
elif weapon == "4lyx": name = "Alyx Gun"
elif weapon == "sawedoffshotgun": name = "sawedoffshotgun"

this is what i had in the old one and thanks for your time


/peace

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 9:10 pm
by PEACE
Hi guys ,
For some reason when i make and change to channel or color and re precasche restarting the server and join it , it crashes me out of game to the desktop unless i restart the server again , there is something in this script doing this


/Peace

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 9:19 pm
by Kami
I updated the plugin so it uses a dictionary now. If you want to add weapons you just add them to the dictionary and if it exists it will show the name you gave it in the dictionary. I'm not sure how the custom weapons work, so I don't know if they are recognized by the player_death event.

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from cvars.public import PublicConVar
from events import Event
from messages import HudMsg
from players.entity import Player
from plugins.info import PluginInfo

# =============================================================================
# >> WEAPON CONFIG
# =============================================================================

weapon_dict = {'rpg_missle':'RPG',
'combine_ball':'Combine Ball',
'smg1_grenade':'SMG Grenade',
'ar2':'AR2',
'crossbow_bolt':'Crossbow',
'physcannon':'Physcannon',
'pistol':'Pistol',
'shotgun':'Shotgun',
'smg1':'SMG',
'357':'357',
'crowbar':'a Crowbar',
'stunstick':'a Stunstick',
'slam':'a Slam',
'grenade_frag':'a Grenade'}



# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
killer = Player.from_userid(attacker)
if victim.userid != killer.userid:
distance = round(killer.origin.get_distance(victim.origin), 2)

kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HudMsg(
message=(
'Attacker info:\n'
'Name: {player.name}\n'
'Health: {player.health}\n'
'Armor: {player.armor}\n'
'Distance: {distance}\n'
'KDR: {kdr:.3f}'
).format(player=killer, distance=distance, kdr=kdr),
x=-1,
y=0.3,
color1=RED,
color2=YELLOW,
effect=0,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(victim.index)

if victim.userid == killer.userid:
message = "%s committed suicide." % (victim.name)

else:
weapon = game_event['weapon']
if weapon in weapon_dict:
name = weapon_dict[weapon]
elif weapon == "physics":
if killer.active_weapon.classname == "weapon_physcannon":
name = "Physcannon"
if not killer.active_weapon.classname == "weapon_physcannon":
name = "a Barrel"
message = "%s killed %s with %s." % (killer.name,victim.name,name)

HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=RED,
color2=YELLOW,
effect=2,
fade_in=0.05,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=4,
).send(killer.index)

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 9:37 pm
by PEACE
Kami,

If i want all to see the name killed name with weapon can i do this ").send(all.index)

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 9:51 pm
by Kami
To show the message to everyone you just do .send()

But in that case you should not use the same channel for the two messages, as the top message will overwrite the deathmsg for the victim if you use the same channel.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Dec 18, 2020 10:07 pm
by PEACE
Kami ,

Thanks for that info also whats could cause the kick me out on join to my desktop unless i strart the server twice ? It doesnt happen with the older py one i have used for years ..


/Peace

Re: [HL2:DM] Deathmsg Help

Posted: Sat Dec 19, 2020 1:26 am
by PEACE
Wanted to thank Kami , and Statoon for his dictionary suggestion , it works better .
Thanks guys much appreciated :)

/Peace