HL2DM - killmessage script

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

Please request only one plugin per thread.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

HL2DM - killmessage script

Postby daren adler » Tue Dec 22, 2020 6:07 am

What i have here is a script that painkiller gave me awhile back, it work and all, but i need a timer on it so the attover goes away..for now if you kill someone or a bot it shows "x/killstreaks_v1/1_kill.vtf", but it stays on all the time untill you kill another one and then x/killstreaks_v1/2_kill.vtf shows up and got to do same as 1. heres the script https://www.dropbox.com/s/4s0xg25220dcp ... e.zip?dl=0 and i asked painkiller and he said ask someone on here if you could help me. Heres the scripts if you dont want to dl from my dropbox.

Killmessage

Code: Select all

from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
import core
from listeners.tick import Delay
from filters.players import PlayerIter

from path import path as Path
import sys
import os
from configobj import ConfigObj
from stringtables.downloads import Downloadables


downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
#Helper Functions
 

def show_message(index, message):
    HudMsg(
        message=message,
        x=0.01,
        y=-0.88,
        color1=Color(255,255,0),
        color2=Color(255,0,0),
        effect=2,
        fade_in=0.01,
        fade_out=1.5,
        hold_time=8,
        fx_time=1.0,
        channel=2
    ).send(index)
   
def show_message_all(message):
    HudMsg(
        message=message,
        x=0.01,
        y=-0.88,
        color1=Color(255,255,0),
        color2=Color(205,0,0),
        effect=2,
        fade_in=0.01,
        fade_out=1.5,
        hold_time=8,
        fx_time=1.0,
        channel=2
    ).send()
   
def get_addon_path():
    path = os.path.dirname(os.path.abspath(__file__))
    return path
   
def test(index):
    core.console_message(index)
   
def create_overlay(index, overlay):
    player = Player(index)
    player.client_command('r_screenoverlay %s' % overlay)
    has_overlay[player.userid] = 1
 

def remove_overlay(index):
    player = Player(index)
    player.client_command('r_screenoverlay 0')
   
   
def play_sound(sound):
    for player in PlayerIter("all"):
        player.play_sound(sound,1.0,0.0, download=True)

#Ini Class
class InI(object):
    def __init__(self):
        self.path = get_addon_path()

        self.config = os.path.join(self.path, 'config', 'frag.ini')

    @property
    def getConfigs(self):
        return ConfigObj(self.config)
   
ini = InI()
for x in ini.getConfigs:
    cfg_list.append(x)
    file = ini.getConfigs[x]['attover']
    file_vtf = file.replace('.vmt', '.vtf')
    downloads.add('materials/' + file)
    downloads.add('materials/' + file_vtf)

       
       
#Test Functions

def load():
    for play in PlayerIter("all"):
        kill_dict[play.userid] = 0
        has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
    userid = ev['userid']
    kill_dict[userid] = 0
    has_overlay[userid] = 0
   
@Event('player_death')
def player_death(ev):
    victim = ev['userid']
    attacker = ev['attacker']
    if attacker:
        attplayer = Player.from_userid(attacker)
    else:
        return
    vicplayer = Player.from_userid(victim)
    kill_dict[victim] = 0
    if has_overlay[victim] == 1:
        remove_overlay(vicplayer.index)
        has_overlay[victim] = 0
    kill_dict[attacker] += 1
    if str(kill_dict[attacker]) in cfg_list:
        num = str(kill_dict[attacker])
        cfg = ini.getConfigs
        message = cfg[num]['msg']
        if "%s" in message:
            message = message.replace("%s", attplayer.name)
        msgto = cfg[num]['msgto']
        snd = cfg[num]['snd']
        attover = cfg[num]['attover']
        if msgto == 'v':
            msgto = Player.from_userid(victim).index
        if msgto == 'a':
            msgto = Player.from_userid(attacker).index
        show_message_all(message)
        play_sound(snd)
        create_overlay(Player.from_userid(attacker).index, attover)


config/frag

Code: Select all

[3]
   msg = "%s has 3 kill in a row!"
   msgto = "v"
   snd = "79/3inarow.mp3"
   attover = ""
   
[4]
   msg = "%s has 4 kill in a row!"
   msgto = "v"
   snd = "79/4inarow.mp3"
   attover = ""
[5]
   msg = "%s has 5 kill in a row!"
   msgto = "v"
   snd = "79/5inarow.mp3"
   attover = ""
   
[6]
   msg = "%s has 6 kill in a row!"
   msgto = "v"
   snd = "79/6inarow.mp3"
   attover = ""
[7]
   msg = "%s has 7 kill in a row!"
   msgto = "v"
   snd = "79/7inarow.mp3"
   attover = ""
   
[8]
   msg = "%s has 8 kill in a row!"
   msgto = "v"
   snd = "79/8akills.mp3"
   attover = ""
[9]
   msg = "%s has 9 kill in a row!"
   msgto = "v"
   snd = "79/9inarow.mp3"
   attover = ""
   
[10]
   msg = "%s IS OUT OF CONTROL! WAKE UP BITCHES 2 KILLS IN A ROW!"
   msgto = "v"
   snd = "79/10inarow.mp3"
   attover = ""

[11]
   msg = "HEY ! %s IS GOING PoSt@L! Bitchslap him and claim the bonus kill reward!!"
   msgto = "v"
   snd = "79/11inarow.mp3"
   attover = ""

[12]
   msg = "%s is the PoSt@L !!!"
   msgto = "v"
   snd = "79/postal-hurricane.mp3"
   attover = "effects/combine_binocoverlay.vtf"

[24]
   msg = "%s is the Sensei !"
   msgto = "v"
   snd = "79/postal-queen.mp3"
   attover = "exile/exile.vmt"


I didnot add the attover yet, i removed them becouse they keep staying on and dont go away till you kill another, but will be added. 12 and 24 have them already tho.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: HL2DM - killmessage script

Postby Kami » Tue Dec 22, 2020 7:01 am

You can try this. Right now it removes the overlay after 3 sconds but you can change by changing remove_timer.

Syntax: Select all

from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
import core
from listeners.tick import Delay
from filters.players import PlayerIter

from path import path as Path
import sys
import os
from configobj import ConfigObj
from stringtables.downloads import Downloadables


downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0
#Helper Functions


def show_message(index, message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(255,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send(index)

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def test(index):
core.console_message(index)

def create_overlay(index, overlay):
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1


def remove_overlay(index):
player = Player(index)
player.client_command('r_screenoverlay 0')


def play_sound(sound):
for player in PlayerIter("all"):
player.play_sound(sound,1.0,0.0, download=True)

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)



#Test Functions

def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(ev):
victim = ev['userid']
attacker = ev['attacker']
if attacker:
attplayer = Player.from_userid(attacker)
else:
return
vicplayer = Player.from_userid(victim)
kill_dict[victim] = 0
if has_overlay[victim] == 1:
remove_overlay(vicplayer.index)
has_overlay[victim] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", attplayer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
attover = cfg[num]['attover']
if msgto == 'v':
msgto = Player.from_userid(victim).index
if msgto == 'a':
msgto = Player.from_userid(attacker).index
show_message_all(message)
play_sound(snd)
create_overlay(Player.from_userid(attacker).index, attover)
Delay(remove_timer, remove_overlay,(Player.from_userid(attacker).index,))
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Tue Dec 22, 2020 7:07 am

Kami wrote:You can try this. Right now it removes the overlay after 3 sconds but you can change by changing remove_timer.

Syntax: Select all

from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
import core
from listeners.tick import Delay
from filters.players import PlayerIter

from path import path as Path
import sys
import os
from configobj import ConfigObj
from stringtables.downloads import Downloadables


downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0
#Helper Functions


def show_message(index, message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(255,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send(index)

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def test(index):
core.console_message(index)

def create_overlay(index, overlay):
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1


def remove_overlay(index):
player = Player(index)
player.client_command('r_screenoverlay 0')


def play_sound(sound):
for player in PlayerIter("all"):
player.play_sound(sound,1.0,0.0, download=True)

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)



#Test Functions

def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(ev):
victim = ev['userid']
attacker = ev['attacker']
if attacker:
attplayer = Player.from_userid(attacker)
else:
return
vicplayer = Player.from_userid(victim)
kill_dict[victim] = 0
if has_overlay[victim] == 1:
remove_overlay(vicplayer.index)
has_overlay[victim] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", attplayer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
attover = cfg[num]['attover']
if msgto == 'v':
msgto = Player.from_userid(victim).index
if msgto == 'a':
msgto = Player.from_userid(attacker).index
show_message_all(message)
play_sound(snd)
create_overlay(Player.from_userid(attacker).index, attover)
Delay(remove_timer, remove_overlay,(Player.from_userid(attacker).index,))


OK will give it a try, thank you. :grin:
Works great, thanks alot,ur good at what you do. I had to get rid of eventscripts,,got sick of all the crashes it does to me,,now i got to get the big fire look after rpg death, the grenades smoke after death and the blue smoke after the orb kill. You guys are way better at this stuff,,,,,Stay very cool :cool: :cool: :cool:

Now i get this (so sorry),i do not know know why i keep getting them after you update it.

Code: Select all

2020-12-22 21:23:55 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\listeners\tick.py", line 80, in _tick
    self.pop(0).execute()
  File "..\addons\source-python\packages\source-python\listeners\tick.py", line 161, in execute
    return self.callback(*self.args, **self.kwargs)
  File "..\addons\source-python\plugins\killmessage\killmessage.py", line 69, in remove_overlay
    player = Player(index)
  File "..\addons\source-python\packages\source-python\entities\_base.py", line 132, in __call__
    obj = super().__call__(index)
  File "..\addons\source-python\packages\source-python\players\_base.py", line 96, in __init__
    PlayerMixin.__init__(self, index)

ValueError: Conversion from "Index" (3) to "BaseEntity" failed.


could you make the fire for the rpg this big? https://steamcommunity.com/sharedfiles/filedetails/?id=2029430338
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sat May 08, 2021 2:22 pm

Is there a way to have this so only the attacker or the other only hear it?
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2DM - killmessage script

Postby cssbestrpg » Sat May 08, 2021 2:50 pm

daren adler wrote:Is there a way to have this so only the attacker or the other only hear it?


Hi,
I have changed to attacker only hear it, but i didn't test it
Try this:

Syntax: Select all

from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
import core
from listeners.tick import Delay
from filters.players import PlayerIter

from path import path as Path
import sys
import os
from configobj import ConfigObj
from stringtables.downloads import Downloadables


downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0
#Helper Functions


def show_message(index, message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(255,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send(index)

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def test(index):
core.console_message(index)

def create_overlay(index, overlay):
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1


def remove_overlay(index):
try:
player = Player(index)
player.client_command('r_screenoverlay 0')
except ValueError:
pass

def play_sound(attacker, sound):
try:
player = Player.from_userid(attacker)
player.play_sound(sound,1.0,0.0, download=True)
except ValueError:
pass

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)



#Test Functions

def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(ev):
victim = ev['userid']
attacker = ev['attacker']
if attacker:
attplayer = Player.from_userid(attacker)
else:
return
vicplayer = Player.from_userid(victim)
kill_dict[victim] = 0
if has_overlay[victim] == 1:
remove_overlay(vicplayer.index)
has_overlay[victim] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", attplayer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
attover = cfg[num]['attover']
if msgto == 'v':
msgto = Player.from_userid(victim).index
if msgto == 'a':
msgto = Player.from_userid(attacker).index
show_message_all(message)
play_sound(attacker, snd)
create_overlay(Player.from_userid(attacker).index, attover)
Delay(remove_timer, remove_overlay,(Player.from_userid(attacker).index,))
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sat May 08, 2021 9:26 pm

ok will give it a try. thank you.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sat May 08, 2021 10:00 pm

I get this error

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/listeners/tick.py", line 80, in _tick
    self.pop(0).execute()
  File "../addons/source-python/packages/source-python/listeners/tick.py", line 161, in execute
    return self.callback(*self.args, **self.kwargs)
  File "../addons/source-python/plugins/killmessage/killmessage.py", line 69, in remove_overlay
    player = Player(index)
  File "../addons/source-python/packages/source-python/entities/_base.py", line 132, in __call__
    obj = super().__call__(index)
  File "../addons/source-python/packages/source-python/players/_base.py", line 96, in __init__
    PlayerMixin.__init__(self, index)

ValueError: Conversion from "Index" (4) to "BaseEntity" failed.
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2DM - killmessage script

Postby cssbestrpg » Sat May 08, 2021 10:27 pm

I tried fix the error, but again untested
Try this one:

Syntax: Select all

from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
import core
from listeners.tick import Delay
from filters.players import PlayerIter

from path import path as Path
import sys
import os
from configobj import ConfigObj
from stringtables.downloads import Downloadables


downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0
#Helper Functions


def show_message(index, message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(255,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send(index)

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def test(index):
core.console_message(index)

def create_overlay(index, overlay):
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1


def remove_overlay(Player):
try:
Player.client_command('r_screenoverlay 0')
except ValueError:
pass

def play_sound(attacker, sound):
try:
player = Player.from_userid(attacker)
player.play_sound(sound,1.0,0.0, download=True)
except ValueError:
pass

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)



#Test Functions

def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(ev):
victim = ev['userid']
attacker = ev['attacker']
if attacker:
attplayer = Player.from_userid(attacker)
else:
return
vicplayer = Player.from_userid(victim)
kill_dict[victim] = 0
if has_overlay[victim] == 1:
remove_overlay(Player.from_userid(victim))
has_overlay[victim] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", attplayer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
attover = cfg[num]['attover']
if msgto == 'v':
msgto = Player.from_userid(victim).index
if msgto == 'a':
msgto = Player.from_userid(attacker).index
show_message_all(message)
play_sound(attacker, snd)
create_overlay(Player.from_userid(attacker).index, attover)
Delay(remove_timer, remove_overlay,(Player.from_userid(attacker,)))
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sat May 08, 2021 11:17 pm

ok. thank you for your help. I will give this a try.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sun May 09, 2021 12:56 am

Code: Select all

2021-05-08 19:35:57 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/listeners/tick.py", line 80, in _tick
    self.pop(0).execute()
  File "../addons/source-python/packages/source-python/listeners/tick.py", line 161, in execute
    return self.callback(*self.args, **self.kwargs)

TypeError: remove_overlay() argument after * must be an iterable, not Player
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2DM - killmessage script

Postby cssbestrpg » Sun May 09, 2021 6:18 am

I have now cleaned the code, untested and fixed error

Syntax: Select all

import os
from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
from filters.players import PlayerIter
from path import path as Path
from configobj import ConfigObj
from stringtables.downloads import Downloadables

downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def create_overlay(index, overlay):
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1

def remove_overlay(index):
player = Player(index)
player.client_command('r_screenoverlay 0')

def play_sound(attacker, sound):
player = Player.from_userid(attacker)
player.play_sound(sound,1.0,0.0, download=True)

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)


def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(args):
userid = args['userid']
attacker = args['attacker']
if attacker > 0:
victim = Player.from_userid(userid)
killer = Player.from_userid(attacker)
kill_dict[userid] = 0
if has_overlay[userid] == 1:
remove_overlay(victim.index)
has_key[userid] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", killer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
attover = cfg[num]['attover']
if msgto == 'v':
msgto = victim.index
if msgto == 'a':
msgto = killer.index
show_message_all(message)
play_sound(attacker, snd)
create_overlay(killer.index, attover)
killer.delay(remove_timer, remove_overlay,(killer.index,))
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sun May 09, 2021 7:54 pm

Works great, the only thing it gives now is this

Code: Select all

2021-05-09 15:34:00 - 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/killmessage/killmessage.py", line 91, in player_death
    has_key[userid] = 0

NameError: name 'has_key' is not defined
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2DM - killmessage script

Postby cssbestrpg » Mon May 10, 2021 4:14 am

Fixed the error in this:

Syntax: Select all

import os
from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
from filters.players import PlayerIter
from path import path as Path
from configobj import ConfigObj
from stringtables.downloads import Downloadables

downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def create_overlay(index, overlay):
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1

def remove_overlay(index):
player = Player(index)
player.client_command('r_screenoverlay 0')

def play_sound(attacker, sound):
player = Player.from_userid(attacker)
player.play_sound(sound,1.0,0.0, download=True)

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)


def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(args):
userid = args['userid']
attacker = args['attacker']
if attacker > 0:
victim = Player.from_userid(userid)
killer = Player.from_userid(attacker)
kill_dict[userid] = 0
if has_overlay[userid] == 1:
remove_overlay(victim.index)
has_overlay[userid] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", killer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
attover = cfg[num]['attover']
if msgto == 'v':
msgto = victim.index
if msgto == 'a':
msgto = killer.index
show_message_all(message)
play_sound(attacker, snd)
create_overlay(killer.index, attover)
killer.delay(remove_timer, remove_overlay,(killer.index,))
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Tue May 11, 2021 5:57 am

Works great, Thank you.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Fri Jul 16, 2021 7:33 pm

In this killmessage, what can i do to not have the attover = on here ?, i tryed removing it and got error, please help.
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2DM - killmessage script

Postby cssbestrpg » Sat Jul 17, 2021 11:40 am

If you mean config option enable overlay/ disable try this one then(Untested):

Syntax: Select all

import os
from events import Event
from colors import Color
from players.entity import Player
from messages import HudMsg
from filters.players import PlayerIter
from path import path as Path
from configobj import ConfigObj
from stringtables.downloads import Downloadables

ENABLE_OVERLAY = 0 # 1 = Enable overlays, 0 = Disable overlays
downloads = Downloadables()

kill_dict = {}
has_overlay = {}
cfg_list = []
remove_timer = 3.0

def show_message_all(message):
HudMsg(
message=message,
x=0.01,
y=-0.88,
color1=Color(255,255,0),
color2=Color(205,0,0),
effect=2,
fade_in=0.01,
fade_out=1.5,
hold_time=8,
fx_time=1.0,
channel=2
).send()

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

def create_overlay(index, overlay):
if ENABLE_OVERLAY:
player = Player(index)
player.client_command('r_screenoverlay %s' % overlay)
has_overlay[player.userid] = 1

def remove_overlay(index):
if ENABLE_OVERLAY:
player = Player(index)
player.client_command('r_screenoverlay 0')

def play_sound(attacker, sound):
player = Player.from_userid(attacker)
player.play_sound(sound,1.0,0.0, download=True)

#Ini Class
class InI(object):
def __init__(self):
self.path = get_addon_path()

self.config = os.path.join(self.path, 'config', 'frag.ini')

@property
def getConfigs(self):
return ConfigObj(self.config)

ini = InI()
for x in ini.getConfigs:
cfg_list.append(x)
if ENABLE_OVERLAY:
file = ini.getConfigs[x]['attover']
file_vtf = file.replace('.vmt', '.vtf')
downloads.add('materials/' + file)
downloads.add('materials/' + file_vtf)


def load():
for play in PlayerIter("all"):
kill_dict[play.userid] = 0
has_overlay[play.userid] = 0

@Event('player_connect')
def player_connect(ev):
userid = ev['userid']
kill_dict[userid] = 0
has_overlay[userid] = 0

@Event('player_death')
def player_death(args):
userid = args['userid']
attacker = args['attacker']
if attacker > 0:
victim = Player.from_userid(userid)
killer = Player.from_userid(attacker)
kill_dict[userid] = 0
if ENABLE_OVERLAY:
if has_overlay[userid] == 1:
remove_overlay(victim.index)
has_overlay[userid] = 0
kill_dict[attacker] += 1
if str(kill_dict[attacker]) in cfg_list:
num = str(kill_dict[attacker])
cfg = ini.getConfigs
message = cfg[num]['msg']
if "%s" in message:
message = message.replace("%s", killer.name)
msgto = cfg[num]['msgto']
snd = cfg[num]['snd']
if ENABLE_OVERLAY:
attover = cfg[num]['attover']
create_overlay(killer.index, attover)
killer.delay(remove_timer, remove_overlay,(killer.index,))
if msgto == 'v':
msgto = victim.index
if msgto == 'a':
msgto = killer.index
show_message_all(message)
play_sound(attacker, snd)
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2DM - killmessage script

Postby daren adler » Sat Jul 17, 2021 4:49 pm

I gave it a try and still shows overlay, so i was thinking i had to do something, so changed this

Code: Select all

def create_overlay(index, overlay):
    if ENABLE_OVERLAY:
        player = Player(index)
        player.client_command('r_screenoverlay %s' % overlay)
        has_overlay[player.userid] = 0
I changed overlay[player.userid] = 1 to 0, still showed, did i do it wrong ? :frown:
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2DM - killmessage script

Postby cssbestrpg » Sat Jul 17, 2021 5:34 pm

daren adler wrote:I gave it a try and still shows overlay, so i was thinking i had to do something, so changed this

Code: Select all

def create_overlay(index, overlay):
    if ENABLE_OVERLAY:
        player = Player(index)
        player.client_command('r_screenoverlay %s' % overlay)
        has_overlay[player.userid] = 0
I changed overlay[player.userid] = 1 to 0, still showed, did i do it wrong ? :frown:

Just tested the plugin itself, when is ENABLE_OVERLAY = 0, it doesn't do any overlays or any downloads, when did change ENABLE_OVERLAY = 1, then it do overlays and downloads, so if get overlays then some other plugin do it, if you are using the latest one: https://forums.sourcepython.com/viewtopic.php?f=37&t=2442&p=15718#p15716

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 18 guests