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.