[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
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

[HL2:DM] Deathmsg Help

Postby Painkiller » Sat Oct 08, 2016 1:43 pm

Hello, this plugin does not work with the latest SP version.

Could someone help me to repair?

Syntax: Select all

from colors import Color
from cvars.public import PublicConVar
from events import Event
from messages import HudMsg
from players.entity import Player
from players.helpers import index_from_userid
from plugins.info import PluginInfo

info = PluginInfo()
info.name = 'deathmsg'
info.author = 'RocKs'
info.version = 'version (Final)'
info.basename = 'deathmessage'
info.variable = info.basename + '_version'
info.url = 'http://www.rocks-clan.de'
info.convar = PublicConVar(info.variable, info.version, info.name + ' Version')


@Event('player_death')
def player_death(game_event):
victim_userid = game_event.get_int('userid')
victim = Player(index_from_userid(victim_userid))

attacker_userid = game_event.get_int('attacker')
if attacker_userid in (victim_userid, 0):
return
attacker = Player(index_from_userid(attacker_userid))

distance = attacker.origin.get_distance(victim.origin)

kdr = attacker.kills / attacker.deaths if attacker.deaths != 0 else 0
kdr = "%.3f" % kdr
HudMsg(
"Attacker info:\n "
"Name: %s\n"
"Health: %s\n"
"Armor: %s\n"
"Distance: %s units\n"
"KDR: %s" % (
attacker.name,
attacker.health,
attacker.armor,
round(distance, 2),
kdr
),
-1, 0.3,
Color(255, 0, 0),
Color(255, 255, 0),
0, 0.05, 1.5, 8, 1.0, 4
).send(victim.index)


[code][/code]


Thanks in Advance
User avatar
satoon101
Project Leader
Posts: 2387
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Deathmsg Help

Postby satoon101 » Sat Oct 08, 2016 3:24 pm

I don't see any reason this wouldn't work with the newest SP version. I have not tested this, but I cleaned up the plugin a little bit:

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


# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = PluginInfo()
info.name = 'deathmsg'
info.author = 'RocKs'
info.version = 'version (Final)'
info.basename = 'deathmessage'
info.variable = info.basename + '_version'
info.url = 'http://www.rocks-clan.de'
info.convar = PublicConVar(info.variable, info.version, info.name + ' Version')


# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
if attacker in (victim.userid, 0):
return
killer = Player.from_userid(attacker)

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}'
),
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, player=killer, distance=distance, kdr=kdr)
Image
User avatar
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Sat Oct 08, 2016 3:40 pm

Now work the script

But no ad hp suit distance etc.
User avatar
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Oct 26, 2016 1:42 pm

Hello mates,
that's my problem

Image
User avatar
iPlayer
Developer
Posts: 545
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: [HL2:DM] Deathmsg Help

Postby iPlayer » Wed Oct 26, 2016 7:17 pm

I suspect the formatting only takes place when the string is a translatable object. When it's just a str object, it's not formatted.

Since we decided not to make HudMsg instance global, but to create it on demand, we can format the string right away:

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


# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = PluginInfo()
info.name = 'deathmsg'
info.author = 'RocKs'
info.version = 'version (Final)'
info.basename = 'deathmessage'
info.variable = info.basename + '_version'
info.url = 'http://www.rocks-clan.de'
info.convar = PublicConVar(info.variable, info.version, info.name + ' Version')


# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def player_death(game_event):
victim = Player.from_userid(game_event['userid'])

attacker = game_event['attacker']
if attacker in (victim.userid, 0):
return
killer = Player.from_userid(attacker)

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)
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Oct 26, 2016 7:24 pm

Thanks this work

I will keep watching
User avatar
satoon101
Project Leader
Posts: 2387
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Deathmsg Help

Postby satoon101 » Thu Oct 27, 2016 8:29 pm

iPlayer wrote:I suspect the formatting only takes place when the string is a translatable object. When it's just a str object, it's not formatted.

Good point! Though, I think we should probably update the messages package to format the string with the given tokens even when it isn't a TranslationStrings instance.
Image
User avatar
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Wed Nov 16, 2016 6:48 pm

Could someone please insert me there with

Or even individually as it is better for you many thanks.
It shows a game_text at the top of the screen
Every time a kill etc. happens
Only the headshot is missing in this script, maybe you can paste in with.

Syntax: Select all

import es
import playerlib
import math
import gamethread
import time

info = es.AddonInfo()
info.name = "RocKs Death Message"
info.version = "3.0"
info.author = "Kami"
info.url = "www.rocks-clan.de"
info.description = "RocKs Death Message"

es.ServerVar(info.name, info.version, info.description).makepublic()

SAME_TIME_LIMIT = 1

killdict = {}
players = dict()

def es_map_start(ev):
es.reload('deathmsg')

def load():
for userid in es.getUseridList():
killdict[userid] = {}
killdict[userid]['kills'] = 0
killdict[userid]['killstreak'] = 0
killdict[userid]['slamkills'] = 0

def unload():
for userid in es.getUseridList():
del killdict[userid]

def player_activate(ev):
userid = int(ev['userid'])
killdict[userid] = {}
killdict[userid]['kills'] = 0
killdict[userid]['killstreak'] = 0

def showMessage1(message, userid):
index = es.createentity('game_text', 'MyMsgEntity')
es.entitysetvalue(index, 'origin', '0 0 0')
es.entitysetvalue(index, 'spawnflags', 0)
es.entitysetvalue(index, 'channel', 4)
es.entitysetvalue(index, 'fxtime', 1.0)
es.entitysetvalue(index, 'holdtime', 8)
es.entitysetvalue(index, 'fadeout', 1.5)
es.entitysetvalue(index, 'fadein', 0.05)
es.entitysetvalue(index, 'color2', '255 255 0')
es.entitysetvalue(index, 'color', '255 0 0')
es.entitysetvalue(index, 'effect', 0)
es.entitysetvalue(index, 'y', 0.5)
es.entitysetvalue(index, 'x', -1)
es.entitysetvalue(index, 'message', message)
es.server.insertcmd(
'es_spawnentity %s;'% index + \
'es_fire %s MyMsgEntity Display;'% userid + \
'es_fire %s MyMsgEntity Kill'% userid
)

def showMessage2(message):
userid = es.getuserid()
if not userid:
return
index = es.createentity('game_text', 'MyMsgEntity')
es.entitysetvalue(index, 'origin', '0 0 0')
es.entitysetvalue(index, 'spawnflags', 1)
es.entitysetvalue(index, 'channel', 2)
es.entitysetvalue(index, 'fxtime', 1.0)
es.entitysetvalue(index, 'holdtime', 8)
es.entitysetvalue(index, 'fadeout', 1.5)
es.entitysetvalue(index, 'fadein', 0.01)
es.entitysetvalue(index, 'color2', '255 255 0')
es.entitysetvalue(index, 'color', '205 0 0')
es.entitysetvalue(index, 'effect', 2)
es.entitysetvalue(index, 'y', -0.88)
es.entitysetvalue(index, 'x', 0.01)
es.entitysetvalue(index, 'message', message)
es.server.insertcmd(
'es_xspawnentity %i;'% index + \
'es_xfire %i MyMsgEntity Display;'% userid + \
'es_xfire %i MyMsgEntity Kill'% userid
)


killdict[userid]['slamkills'] = 0
killdict[userid]['killstreak'] = 0
weapon = ev['weapon']
if weapon == "rpg_missile": name = "RPG"
elif weapon == "combine_ball": name = "Combine Ball"
elif weapon == "smg1_grenade": name = "Smg Grenade"
elif weapon == "ar2": name = "AR2"
elif weapon == "crossbow_bolt": name = "Crossbow"
elif weapon == "physcannon": name = "Physcannon"
elif weapon == "pistol": name = "Pistol"
elif weapon == "shotgun": name = "Shotgun"
elif weapon == "smg1": name = "SMG"
elif weapon == "357": name = "357"
elif weapon == "crowbar": name = "a Crowbar"
elif weapon == "stunstick": name = "a Stunstick"
elif weapon == "slam": name = "a Slam"
elif weapon == "grenade_frag": name = "a Grenade"
elif weapon == "physics":
if ev['es_attackerweapon'] == "weapon_physcannon":
name = "Physcannon"
if not ev['es_attackerweapon'] == "weapon_physcannon":
name = "a Barrel"
gamethread.delayed(1, resetkills, (attacker))
now = time.time()
killer, then_time = players.get(attacker, (None, 0))
killdict[attacker]['killstreak'] += 1
if userid != attacker:
killdict[attacker]['kills'] += 1
if userid != attacker:
message = ('%s killed %s with %s'% (ev['es_attackername'], ev['es_username'], name))
if userid == attacker:
message = ('%s commited suicide' % (ev['es_attackername']))
if killdict[attacker]['kills'] >= 2:
message = ('%s killed %s with %s \n%s Multikill!!!' % (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
if killer == userid and now - then_time <= SAME_TIME_LIMIT:
message = ('%s and %s killed eachother at the same time!' % (ev['es_attackername'], ev['es_username']))
if weapon == 'slam':
killdict[attacker]['slamkills'] += 1
if killdict[attacker]['slamkills'] >= 3:
killdict[userid]['slamkills'] = 0
message = ('%s killed %s with %s \n%s is a Slamwhore and will be frozen for 10 seconds!'% (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
if killdict[attacker]['killstreak'] == 12:
message = ('%s killed %s with %s \n%s is Postal!' % (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
if killdict[attacker]['killstreak'] == 24:
message = ('%s killed %s with %s \n%s is Sensei!' % (ev['es_attackername'], ev['es_username'], name, ev['es_attackername']))
showMessage2(message)
players[userid] = (attacker, now)

def resetkills(attacker):
killdict[attacker]['kills'] = 0



Example Video:
https://www.youtube.com/watch?v=KBGHbmKiR6k
Last edited by Ayuto on Wed Nov 16, 2016 6:50 pm, edited 1 time in total.
Reason: code -> python
User avatar
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Mon Nov 21, 2016 6:33 pm

nobody can help me?
User avatar
Painkiller
Senior Member
Posts: 290
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Deathmsg Help

Postby Painkiller » Mon Nov 28, 2016 9:25 am

Hi mates,

Can someone please insert this?

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 1 guest