[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
Kami
Global Moderator
Posts: 264
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] Deathmsg Help

Postby Kami » Sat Dec 19, 2020 9:01 am

PEACE wrote: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



I don't think that the deathmsg plugin is responsible for this. There is nothing that interacts with players joining so you might have to look for another cause.
User avatar
Painkiller
Senior Member
Posts: 751
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Sat Dec 19, 2020 9:39 am

Thanks Kami, I tested it and it does what it is supposed to at first glance.

Thank you and Merry Christmas.
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Thu Dec 31, 2020 6:59 pm

I did the sp update and got this.

Code: Select all

[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 40, in player_death
    killer = Player.from_userid(attacker)
  File "..\addons\source-python\packages\source-python\players\_base.py", line 109, in from_userid
    return cls(index_from_userid(userid), caching=caching)

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


and

Code: Select all

2021-01-02 15:21:57 - 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 78, in player_death
    message = "%s killed %s with %s." % (killer.name,victim.name,name)

UnboundLocalError: local variable 'name' referenced before assignment


I added my extra weapons to it also here, that may be the trouble ( i dont know)

Code: Select all

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',
                'laser':'Laser',
                'superplasmagun':'Super Plasma Rifle',
                'fists':'fists',
                'crowbar':'a Crowbar',
                'stunstick':'a Stunstick',
                'slam':'a Slam',
                'grenade_frag':'a Grenade'}
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Thu Mar 11, 2021 10:56 pm

Please help.

Code: Select all

2021-03-11 16:50:23 - 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 43, in player_death
    killer = Player.from_userid(attacker)
  File "..\addons\source-python\packages\source-python\players\_base.py", line 109, in from_userid
    return cls(index_from_userid(userid), caching=caching)

ValueError: Conversion from "Userid" (0) to "Index" failed.
User avatar
Kami
Global Moderator
Posts: 264
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2:DM] Deathmsg Help

Postby Kami » Fri Mar 12, 2021 9:13 am

This should fix your errors:

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']
try:
killer = Player.from_userid(attacker)
except:
return
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"
else:
name = weapon
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)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Fri Mar 12, 2021 8:36 pm

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

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Fri Oct 29, 2021 9:35 am

Hey SP-Team and Community i have a error in deathmsg.

Code: Select all

[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 71, in player_death
    message = "%s killed %s with %s." % (killer.name,victim.name,name)

UnboundLocalError: local variable 'name' referenced before assignment


can anybody help for this?
cssbestrpg
Senior Member
Posts: 315
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: [HL2:DM] Deathmsg Help

Postby cssbestrpg » Fri Oct 29, 2021 6:21 pm

Painkiller wrote:Hey SP-Team and Community i have a error in deathmsg.

Code: Select all

[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 71, in player_death
    message = "%s killed %s with %s." % (killer.name,victim.name,name)

UnboundLocalError: local variable 'name' referenced before assignment


can anybody help for this?


Hey try this one:

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

# =============================================================================
# >> 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']
try:
killer = Player.from_userid(attacker)
except:
return
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]
message = f'{killer.name} killed {victim.name} with {name}.'
elif weapon == "physics":
if killer.active_weapon.classname == "weapon_physcannon":
name = "Physcannon"
message = f'{killer.name} killed {victim.name} with {name}.'
if not killer.active_weapon.classname == "weapon_physcannon":
name = "a Barrel"
message = f'{killer.name} killed {victim.name} with {name}.'
else:
name = weapon
message = f'{killer.name} killed {victim.name} with {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)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Tue Jun 18, 2024 2:38 am

Could i get this to show in chat insteed ?. and have it show killer and the killed ?....... :cool:
cssbestrpg
Senior Member
Posts: 315
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: [HL2:DM] Deathmsg Help

Postby cssbestrpg » Tue Jun 18, 2024 5:16 pm

You mean show it in chat like: killer.name has killed victim.name with slam for example?

Edit:

Added show chat message same time when kills player

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from events import Event
from messages import HudMsg, SayText2
from players.entity import Player

# =============================================================================
# >> 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'
}


HUD_MESSAGE = HudMsg(message='Attacker info:\nName: {name}\nHealth: {health}\nArmor: {armor}\nDistance: {distance}\nKDR: {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)
WEAPON_MESSAGE = HudMsg(message='{killer} has killed {victim} with {name}', 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)
SUICIDE_HUD_MSG = HudMsg(message='{victim} has committed suicide', 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)

CHAT_MESSAGE_WEAPON = SayText2(message='{killer} has killed {victim} with {name}')
CHAT_MESSAGE_INFO = SayText2(message='Attacker info:\nName: {name}\nHealth: {health}\nArmor: {armor}\nDistance: {distance}\nKDR: {kdr}')
CHAT_SUICIDE_MSG = SayText2(message='{victim} has committed suicide')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
userid = game_event.get_int('userid')
attacker = game_event.get_int('attacker')

victim = Player.from_userid(userid)
try:
killer = Player.from_userid(attacker)
except ValueError:
return

if userid != attacker:
distance = round(killer.origin.get_distance(victim.origin), 2)
kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HUD_MESSAGE.send(victim.index, name=killer.name, health=killer.health, armor=killer.armor, distance=distance, kdr=f'{kdr:.03f}')


weapon_name = killer.active_weapon_classname

name = ''
if userid == attacker:
CHAT_SUICIDE_MSG.send(killer.index, victim=victim.name)
SUICIDE_HUD_MSG.send(killer.index, victim=victim.name)
else:
weapon = game_event['weapon']
if weapon in weapon_dict:
name = weapon_dict[weapon]
elif weapon == "physics":
if weapon_name == "weapon_physcannon":
name = "Physcannon"
if not weapon_name == "weapon_physcannon":
name = "a Barrel"
else:
name = weapon
WEAPON_MESSAGE.send(killer.index, killer=killer.name, victim=victim.name, name=name)
CHAT_MESSAGE_WEAPON.send(killer.index, killer=killer.name, victim=victim.name, name=name)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Tue Jun 18, 2024 7:34 pm

thank you so much, but i am getting this error and it does not show in chat.

Code: Select all

2024-06-18 15:31:24 - sp.hooks.exceptions   -   EXCEPTION   [Source.Python]
[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/entities/_base.py", line 244, in __getattr__
    instance, value = self.dynamic_attributes[attr]
KeyError: 'active_weapon_classname'

During handling of the above exception, another exception occurred:
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 58, in player_death
    weapon_name = killer.active_weapon_classname
  File "../addons/source-python/packages/source-python/entities/_base.py", line 246, in __getattr__
    raise AttributeError('Attribute "{0}" not found'.format(attr))

AttributeError: Attribute "active_weapon_classname" not found
cssbestrpg
Senior Member
Posts: 315
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: [HL2:DM] Deathmsg Help

Postby cssbestrpg » Tue Jun 18, 2024 8:09 pm

Fixed here the error

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
from colors import RED, YELLOW
from events import Event
from messages import HudMsg, SayText2
from players.entity import Player

# =============================================================================
# >> 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'
}


HUD_MESSAGE = HudMsg(message='Attacker info:\nName: {name}\nHealth: {health}\nArmor: {armor}\nDistance: {distance}\nKDR: {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)
WEAPON_MESSAGE = HudMsg(message='{killer} has killed {victim} with {name}', 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)
SUICIDE_HUD_MSG = HudMsg(message='{victim} has committed suicide', 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)

CHAT_MESSAGE_WEAPON = SayText2(message='{killer} has killed {victim} with {name}')
CHAT_MESSAGE_INFO = SayText2(message='Attacker info:\nName: {name}\nHealth: {health}\nArmor: {armor}\nDistance: {distance}\nKDR: {kdr}')
CHAT_SUICIDE_MSG = SayText2(message='{victim} has committed suicide')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
userid = game_event.get_int('userid')
attacker = game_event.get_int('attacker')

victim = Player.from_userid(userid)
try:
killer = Player.from_userid(attacker)
except ValueError:
return

if userid != attacker:
distance = round(killer.origin.get_distance(victim.origin), 2)
kdr = killer.kills / killer.deaths if killer.deaths != 0 else 0
HUD_MESSAGE.send(victim.index, name=killer.name, health=killer.health, armor=killer.armor, distance=distance, kdr=f'{kdr:.03f}')
CHAT_MESSAGE_INFO.send(victim.index, name=killer.name, health=killer.health, armor=killer.armor, distance=distance, kdr=f'{kdr:.03f}')


attacker_weapon = killer.get_active_weapon()
if attacker_weapon is None:
return
weapon_name = attacker_weapon.classname

name = ''
if userid == attacker:
CHAT_SUICIDE_MSG.send(killer.index, victim=victim.name)
SUICIDE_HUD_MSG.send(killer.index, victim=victim.name)
else:
weapon = game_event['weapon']
if weapon in weapon_dict:
name = weapon_dict[weapon]
elif weapon == "physics":
if weapon_name == "weapon_physcannon":
name = "Physcannon"
if not weapon_name == "weapon_physcannon":
name = "a Barrel"
else:
name = weapon
WEAPON_MESSAGE.send(killer.index, killer=killer.name, victim=victim.name, name=name)
CHAT_MESSAGE_WEAPON.send(killer.index, killer=killer.name, victim=victim.name, name=name)


You mean showing chat message for everyone?

Edit: Fixed missing chat message when killing player, it only showed hud message only
Last edited by cssbestrpg on Tue Jun 18, 2024 8:38 pm, edited 1 time in total.
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Tue Jun 18, 2024 8:15 pm

i think just yourself would be ok,,if i try and pick everyone with the bots,,it would be to full i think,,i will try this one, thank you so much for all your help, :)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: [HL2:DM] Deathmsg Help

Postby daren adler » Tue Jun 18, 2024 8:20 pm

Works great,,good work, thank you very much. :cool: :cool: :cool:

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 90 guests