[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: 263
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: 725
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: 328
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: 328
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: 263
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: 328
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: 725
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: 287
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)

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 21 guests