Page 3 of 3

Re: [HL2:DM] Deathmsg Help

Posted: Sat Dec 19, 2020 9:01 am
by Kami
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.

Re: [HL2:DM] Deathmsg Help

Posted: Sat Dec 19, 2020 9:39 am
by Painkiller
Thanks Kami, I tested it and it does what it is supposed to at first glance.

Thank you and Merry Christmas.

Re: [HL2:DM] Deathmsg Help

Posted: Thu Dec 31, 2020 6:59 pm
by daren adler
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'}

Re: [HL2:DM] Deathmsg Help

Posted: Thu Mar 11, 2021 10:56 pm
by daren adler
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.

Re: [HL2:DM] Deathmsg Help

Posted: Fri Mar 12, 2021 9:13 am
by Kami
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)

Re: [HL2:DM] Deathmsg Help

Posted: Fri Mar 12, 2021 8:36 pm
by daren adler
:grin: :grin: :cool: Thank you :cool:

Re: [HL2:DM] Deathmsg Help

Posted: Fri Oct 29, 2021 9:35 am
by Painkiller
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?

Re: [HL2:DM] Deathmsg Help

Posted: Fri Oct 29, 2021 6:21 pm
by cssbestrpg
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)