Page 1 of 3

[HL2:DM] Deathmsg Help

Posted: Sat Oct 08, 2016 1:43 pm
by Painkiller
Hello, this plugin does not work with the latest SP version.

Could someone help me to repair?

Syntax: Select all

from colors import Color
from cvars.public import PublicConVar
from events import Event
from messages import HudMsg
from players.entity import Player
from players.helpers import index_from_userid
from plugins.info import PluginInfo

info = PluginInfo()
info.name = 'deathmsg'
info.author = 'RocKs'
info.version = 'version (Final)'
info.basename = 'deathmessage'
info.variable = info.basename + '_version'
info.url = 'http://www.rocks-clan.de'
info.convar = PublicConVar(info.variable, info.version, info.name + ' Version')


@Event('player_death')
def player_death(game_event):
victim_userid = game_event.get_int('userid')
victim = Player(index_from_userid(victim_userid))

attacker_userid = game_event.get_int('attacker')
if attacker_userid in (victim_userid, 0):
return
attacker = Player(index_from_userid(attacker_userid))

distance = attacker.origin.get_distance(victim.origin)

kdr = attacker.kills / attacker.deaths if attacker.deaths != 0 else 0
kdr = "%.3f" % kdr
HudMsg(
"Attacker info:\n "
"Name: %s\n"
"Health: %s\n"
"Armor: %s\n"
"Distance: %s units\n"
"KDR: %s" % (
attacker.name,
attacker.health,
attacker.armor,
round(distance, 2),
kdr
),
-1, 0.3,
Color(255, 0, 0),
Color(255, 255, 0),
0, 0.05, 1.5, 8, 1.0, 4
).send(victim.index)


[code][/code]


Thanks in Advance

Re: [HL2:DM] Deathmsg Help

Posted: Sat Oct 08, 2016 3:24 pm
by satoon101
I don't see any reason this wouldn't work with the newest SP version. I have not tested this, but I cleaned up the plugin a little bit:

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


# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = PluginInfo()
info.name = 'deathmsg'
info.author = 'RocKs'
info.version = 'version (Final)'
info.basename = 'deathmessage'
info.variable = info.basename + '_version'
info.url = 'http://www.rocks-clan.de'
info.convar = PublicConVar(info.variable, info.version, info.name + ' Version')


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

attacker = game_event['attacker']
if attacker in (victim.userid, 0):
return
killer = Player.from_userid(attacker)

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}'
),
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, player=killer, distance=distance, kdr=kdr)

Re: [HL2:DM] Deathmsg Help

Posted: Sat Oct 08, 2016 3:40 pm
by Painkiller
Now work the script

But no ad hp suit distance etc.

Re: [HL2:DM] Deathmsg Help

Posted: Wed Oct 26, 2016 1:42 pm
by Painkiller
Hello mates,
that's my problem

Image

Re: [HL2:DM] Deathmsg Help

Posted: Wed Oct 26, 2016 7:17 pm
by iPlayer
I suspect the formatting only takes place when the string is a translatable object. When it's just a str object, it's not formatted.

Since we decided not to make HudMsg instance global, but to create it on demand, we can format the string right away:

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


# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = PluginInfo()
info.name = 'deathmsg'
info.author = 'RocKs'
info.version = 'version (Final)'
info.basename = 'deathmessage'
info.variable = info.basename + '_version'
info.url = 'http://www.rocks-clan.de'
info.convar = PublicConVar(info.variable, info.version, info.name + ' Version')


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

attacker = game_event['attacker']
if attacker in (victim.userid, 0):
return
killer = Player.from_userid(attacker)

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)

Re: [HL2:DM] Deathmsg Help

Posted: Wed Oct 26, 2016 7:24 pm
by Painkiller
Thanks this work

I will keep watching

Re: [HL2:DM] Deathmsg Help

Posted: Thu Oct 27, 2016 8:29 pm
by satoon101
iPlayer wrote:I suspect the formatting only takes place when the string is a translatable object. When it's just a str object, it's not formatted.

Good point! Though, I think we should probably update the messages package to format the string with the given tokens even when it isn't a TranslationStrings instance.

Re: [HL2:DM] Deathmsg Help

Posted: Wed Nov 16, 2016 6:48 pm
by Painkiller
Could someone please insert me there with

Or even individually as it is better for you many thanks.
It shows a game_text at the top of the screen
Every time a kill etc. happens
Only the headshot is missing in this script, maybe you can paste in with.

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', '255 0 0')
es.entitysetvalue(index, 'effect', 0)
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.01)
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
)


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



Example Video:
https://www.youtube.com/watch?v=KBGHbmKiR6k

Re: [HL2:DM] Deathmsg Help

Posted: Mon Nov 21, 2016 6:33 pm
by Painkiller
nobody can help me?

Re: [HL2:DM] Deathmsg Help

Posted: Mon Nov 28, 2016 9:25 am
by Painkiller
Hi mates,

Can someone please insert this?

Re: [HL2:DM] Deathmsg Help

Posted: Sun Jun 02, 2019 7:03 am
by Painkiller
I could pull that mistake out of the logs.
It seems to have something to do with the KDR.

Maybe someone could help.


Code: Select all

2019-06-02 08:54:14 - 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 34, in player_death
    ).format(player=killer, distance=distance, kdr=kdr),

ValueError: Unable to find property 'm_ArmorValue'.

Re: [HL2:DM] Deathmsg Help

Posted: Sun Jun 02, 2019 7:06 am
by Ayuto
I fixed that already a few days ago. Just haven't created a new release:
https://github.com/Source-Python-Dev-Te ... 60f67d519d

I will do that today.

Re: [HL2:DM] Deathmsg Help

Posted: Sun Jun 02, 2019 7:17 am
by Painkiller
Thank you

Re: [HL2:DM] Deathmsg Help

Posted: Fri Apr 10, 2020 2:55 pm
by Painkiller
Hello Python team and community,

I noticed an error in the display of the deathmessage.

Unfortunately I did not find any error in the logs or console.

Image

This version is currently running:

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 in (victim.userid, 0):
return
killer = Player.from_userid(attacker)

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)

Re: [HL2:DM] Deathmsg Help

Posted: Fri Apr 10, 2020 4:39 pm
by Ayuto
This does not seem to be the plugin that print the message shown in your screenshot.

Re: [HL2:DM] Deathmsg Help

Posted: Mon Apr 13, 2020 8:54 am
by Painkiller
Ok it's already fixed.

Re: [HL2:DM] Deathmsg Help

Posted: Wed Nov 11, 2020 10:39 am
by Painkiller
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 display in the upper left corner who killed whom with which weapon is no longer shown)
Tested with bots

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 in (victim.userid, 0):
return
killer = Player.from_userid(attacker)

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)

Re: [HL2:DM] Deathmsg Help

Posted: Wed Nov 11, 2020 6:13 pm
by PEACE
Hey all ,

Painkiller wrote "(The display in the upper left corner who killed whom with which weapon is no longer shown)
Tested with bots"
I would like to see those both in one script with death msg and who killed who like in the old python one in es , i rememeber having to add all the custom guns to the list for them to show .

Peace

Re: [HL2:DM] Deathmsg Help

Posted: Wed Nov 11, 2020 10:32 pm
by VinciT
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.

Re: [HL2:DM] Deathmsg Help

Posted: Wed Nov 11, 2020 10:52 pm
by PEACE
Im running it and the death message is fine but I think Painkiller was taking about the real time line that displays Nick killed Bill with a Shotgun , joe killed sam with a pistol , it streams across the left top doesnt stop as long as kills are going that was part of the original you got that and the Death message when you died

Peace