[HL2:DM] Deathmsg Help

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[HL2:DM] Deathmsg Help

Postby Painkiller » Sat Oct 08, 2016 1:43 pm

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
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Deathmsg Help

Postby satoon101 » Sat Oct 08, 2016 3:24 pm

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)
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Sat Oct 08, 2016 3:40 pm

Now work the script

But no ad hp suit distance etc.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Oct 26, 2016 1:42 pm

Hello mates,
that's my problem

Image
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: [HL2:DM] Deathmsg Help

Postby iPlayer » Wed Oct 26, 2016 7:17 pm

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)
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Oct 26, 2016 7:24 pm

Thanks this work

I will keep watching
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Deathmsg Help

Postby satoon101 » Thu Oct 27, 2016 8:29 pm

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.
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Nov 16, 2016 6:48 pm

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
Last edited by Ayuto on Wed Nov 16, 2016 6:50 pm, edited 1 time in total.
Reason: code -> python
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Mon Nov 21, 2016 6:33 pm

nobody can help me?
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Mon Nov 28, 2016 9:25 am

Hi mates,

Can someone please insert this?
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Sun Jun 02, 2019 7:03 am

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'.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Deathmsg Help

Postby Ayuto » Sun Jun 02, 2019 7:06 am

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.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Sun Jun 02, 2019 7:17 am

Thank you
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Fri Apr 10, 2020 2:55 pm

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)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Deathmsg Help

Postby Ayuto » Fri Apr 10, 2020 4:39 pm

This does not seem to be the plugin that print the message shown in your screenshot.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Mon Apr 13, 2020 8:54 am

Ok it's already fixed.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Nov 11, 2020 10:39 am

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)
User avatar
PEACE
Member
Posts: 50
Joined: Mon Oct 12, 2020 1:13 pm

Re: [HL2:DM] Deathmsg Help

Postby PEACE » Wed Nov 11, 2020 6:13 pm

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
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [HL2:DM] Deathmsg Help

Postby VinciT » Wed Nov 11, 2020 10:32 pm

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.
ImageImageImageImageImage
User avatar
PEACE
Member
Posts: 50
Joined: Mon Oct 12, 2020 1:13 pm

Re: [HL2:DM] Deathmsg Help

Postby PEACE » Wed Nov 11, 2020 10:52 pm

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

Return to “Plugin Requests”

Who is online

Users browsing this forum: Bing [Bot] and 34 guests