[HL2:DM] Headshot 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: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Wed Oct 19, 2016 10:53 am

Sorry but I'm not very good in English.

I have probably not understood everything.

What the nice scripters said when it comes to code language, it brakes with me but something more.
User avatar
D3CEPTION
Senior Member
Posts: 130
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: [HL2:DM] Headshot Help

Postby D3CEPTION » Thu Oct 20, 2016 2:52 am

so is there anything specific, that isnt working for you?
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Thu Oct 20, 2016 6:54 am

Ok I have reinstalled SP.
The headshot sound will sound again. (work)

But as I said no overlays and no body without head to see.
The whole corpse suddenly disappears.

I have all VTF, VMT and mdl files on the Gameserver and Fastdownload.

I could see in the client folder sounds and VTF, VMT were downloaded.

But the headless model unfortunately not.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

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

It would be really great if someone could help me.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

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

I think I have found the problem

Headshot overlay appears when I die
But it should appear when I kill someone
User avatar
iPlayer
Developer
Posts: 445
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: [HL2:DM] Headshot Help

Postby iPlayer » Wed Oct 26, 2016 8:29 pm

Just so you know, this is the code that fixed all issues. Head explosion (mysterious est_effect 11) is not included

Syntax: Select all

from contextlib import suppress

from engines.precache import Model
from engines.sound import Sound
from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from events import Event
from listeners.tick import Delay
from memory import make_object
from players.constants import HitGroup
from players.entity import Player
from stringtables.downloads import Downloadables


# =============================================================================
# >> CONFIGURATION
# =============================================================================
REMOVE_OVERLAY_TIME = 1.5
HEADSHOT_OVERLAY_VMT = "exae/rocksheadshot1.vmt"
HEADSHOT_OVERLAY_VTF = "exae/rocksheadshot1.vtf"

# Headshot but not dead sound + path
HEADSHOT_SOUND = 'exae/quake/human-hit-4.mp3'

# <weapon> : <headshot_sound>
WEAPON_FILES = {
'weapon_crossbow': 'exae/quake/headshot2.mp3',
'weapon_357' : 'exae/quake/headshot-2.mp3',
'weapon_smg1' : 'exae/quake/wife-headshot.mp3',
'weapon_ar2' : 'exae/quake/boomheadshot.mp3',
'weapon_pistol' : 'exae/quake/headshot-1.mp3',
'weapon_shotgun' : 'exae/quake/headshot2.mp3'
}

DEAD_MODEL_PATH = 'models/headless_body/metrocop.mdl'
DEAD_MODEL_DL_FILES = [
"models/headless_body/metrocop.dx80.vtx",
"models/headless_body/metrocop.dx90.vtx",
"models/headless_body/metrocop.mdl",
"models/headless_body/metrocop.phy",
"models/headless_body/metrocop.sw.vtx",
"models/headless_body/metrocop.vvd",
]
# =============================================================================
# >> END OF CONFIGURATION
# =============================================================================


HEADSHOT_SOUND = Sound(HEADSHOT_SOUND, download=True)
WEAPON_FILES = {x: Sound(y, download=True) for x, y in WEAPON_FILES.items()}
downloads = Downloadables()
for item in (HEADSHOT_OVERLAY_VMT, HEADSHOT_OVERLAY_VTF):
downloads.add('materials/' + item)
for item in DEAD_MODEL_DL_FILES:
downloads.add(item)

DEAD_MODEL = Model(
path=DEAD_MODEL_PATH,
preload=True,
)

_old_models = {}
_damage_weapons = {}


@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

victim = Player(victim.index)
info = make_object(TakeDamageInfo, stack_data[1])

# World damage?
if info.attacker == 0:
_damage_weapons[victim.userid] = 'worldspawn'

# Was a projectile used?
elif info.attacker != info.inflictor:
_damage_weapons[victim.userid] = Entity(info.inflictor).classname

# Not a projectile
else:
_damage_weapons[victim.userid] = Player(info.attacker).active_weapon.classname


@Event('player_hurt')
def player_hurt(game_event):
victim = Player.from_userid(game_event['userid'])
attacker_userid = game_event['attacker']

# Suicide?
if attacker_userid in (victim.userid, 0):
return

# Not a headshot?
if victim.hitgroup != HitGroup.HEAD:
return

# Victim still alive?
if game_event['health']:
HEADSHOT_SOUND.index = victim.index
HEADSHOT_SOUND.play(victim.index)
return

weapon_sound = WEAPON_FILES.get(_damage_weapons.get(victim.userid))
if weapon_sound is None:
return

# Play weapon specific headshot sound
weapon_sound.index = victim.index
weapon_sound.play()

# Set the victim's overlay
victim.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT
)
)
Delay(REMOVE_OVERLAY_TIME, _remove_overlay, victim.userid)

# Set the attacker's overlay
attacker = Player.from_userid(attacker_userid)
attacker.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT
)
)
Delay(REMOVE_OVERLAY_TIME, _remove_overlay, attacker_userid)

# Set the victim's model
_old_models[victim.userid] = victim.model
victim.model = DEAD_MODEL


@Event('player_spawn')
def _reset_model(game_event):
userid = game_event['userid']
old_model = _old_models.pop(userid, None)
if old_model is not None:
Player.from_userid(userid).model = old_model


def _remove_overlay(userid):
with suppress(Exception):
Player.from_userid(userid).client_command('r_screenoverlay 0')


From EST docs I can assume that CTEBloodStream will have similar effect.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • arcadmin • AdPurge

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

Re: [HL2:DM] Headshot Help

Postby Painkiller » Wed Oct 26, 2016 8:36 pm

Ok thanks. Works good.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Thu Nov 03, 2016 4:57 pm

Hello friends i have a problem with coop server.

I shout NPC`s

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/plugins/headshot/headshot.py", line 86, in _pre_take_damage
    _damage_weapons[victim.userid] = Player(info.attacker).active_weapon.classname

AttributeError: 'NoneType' object has no attribute 'classname'
User avatar
iPlayer
Developer
Posts: 445
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: [HL2:DM] Headshot Help

Postby iPlayer » Thu Nov 03, 2016 6:54 pm

What did you shoot them with? oO
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • arcadmin • AdPurge

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

Re: [HL2:DM] Headshot Help

Postby Painkiller » Fri Nov 04, 2016 8:57 am

With all.
User avatar
L'In20Cible
Project Leader
Posts: 914
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [HL2:DM] Headshot Help

Postby L'In20Cible » Fri Nov 04, 2016 9:31 am

That error is caused cause Player.active_weapon is failing to retrieve the weapon currently used by the player and returns None. I'm not entirely sure in what circumstances this can happens but I believe TakeDamageInfo.get_weapon could be useful here:

Syntax: Select all

@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

victim = Player(victim.index)
info = make_object(TakeDamageInfo, stack_data[1])

try:
index = info.weapon
except ValueError:
index = WORLD_ENTITY_INDEX

_damage_weapons[victim.userid] = BaseEntity(index).classname
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Sat Nov 05, 2016 7:07 am

Good morning, where do I have to paste?
User avatar
L'In20Cible
Project Leader
Posts: 914
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [HL2:DM] Headshot Help

Postby L'In20Cible » Sat Nov 05, 2016 11:54 am

Something like this:

Syntax: Select all

from contextlib import suppress

from engines.precache import Model
from engines.sound import Sound
from entities import TakeDamageInfo
from entities.constants import WORLD_ENTITY_INDEX
from entities.entity import BaseEntity
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from events import Event
from listeners.tick import Delay
from memory import make_object
from players.constants import HitGroup
from players.entity import Player
from stringtables.downloads import Downloadables


# =============================================================================
# >> CONFIGURATION
# =============================================================================
REMOVE_OVERLAY_TIME = 1.5
HEADSHOT_OVERLAY_VMT = "exae/rocksheadshot1.vmt"
HEADSHOT_OVERLAY_VTF = "exae/rocksheadshot1.vtf"

# Headshot but not dead sound + path
HEADSHOT_SOUND = 'exae/quake/human-hit-4.mp3'

# <weapon> : <headshot_sound>
WEAPON_FILES = {
'weapon_crossbow': 'exae/quake/headshot2.mp3',
'weapon_357' : 'exae/quake/headshot-2.mp3',
'weapon_smg1' : 'exae/quake/wife-headshot.mp3',
'weapon_ar2' : 'exae/quake/boomheadshot.mp3',
'weapon_pistol' : 'exae/quake/headshot-1.mp3',
'weapon_shotgun' : 'exae/quake/headshot2.mp3'
}

DEAD_MODEL_PATH = 'models/headless_body/metrocop.mdl'
DEAD_MODEL_DL_FILES = [
"models/headless_body/metrocop.dx80.vtx",
"models/headless_body/metrocop.dx90.vtx",
"models/headless_body/metrocop.mdl",
"models/headless_body/metrocop.phy",
"models/headless_body/metrocop.sw.vtx",
"models/headless_body/metrocop.vvd",
]
# =============================================================================
# >> END OF CONFIGURATION
# =============================================================================


HEADSHOT_SOUND = Sound(HEADSHOT_SOUND, download=True)
WEAPON_FILES = {x: Sound(y, download=True) for x, y in WEAPON_FILES.items()}
downloads = Downloadables()
for item in (HEADSHOT_OVERLAY_VMT, HEADSHOT_OVERLAY_VTF):
downloads.add('materials/' + item)
for item in DEAD_MODEL_DL_FILES:
downloads.add(item)

DEAD_MODEL = Model(
path=DEAD_MODEL_PATH,
preload=True,
)

_old_models = {}
_damage_weapons = {}


@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

victim = Player(victim.index)
info = make_object(TakeDamageInfo, stack_data[1])

try:
index = info.weapon
except ValueError:
index = WORLD_ENTITY_INDEX

_damage_weapons[victim.userid] = BaseEntity(index).classname


@Event('player_hurt')
def player_hurt(game_event):
victim = Player.from_userid(game_event['userid'])
attacker_userid = game_event['attacker']

# Suicide?
if attacker_userid in (victim.userid, 0):
return

# Not a headshot?
if victim.hitgroup != HitGroup.HEAD:
return

# Victim still alive?
if game_event['health']:
HEADSHOT_SOUND.index = victim.index
HEADSHOT_SOUND.play(victim.index)
return

weapon_sound = WEAPON_FILES.get(_damage_weapons.get(victim.userid))
if weapon_sound is None:
return

# Play weapon specific headshot sound
weapon_sound.index = victim.index
weapon_sound.play()

# Set the victim's overlay
victim.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT
)
)
victim.delay(REMOVE_OVERLAYTIME, victim.client_command, 'r_screenoverlay 0')

# Set the attacker's overlay
attacker = Player.from_userid(attacker_userid)
attacker.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT
)
)
victim.delay(REMOVE_OVERLAYTIME, attacker.client_command, 'r_screenoverlay 0')

# Set the victim's model
_old_models[victim.userid] = victim.model
victim.model = DEAD_MODEL


@Event('player_spawn')
def _reset_model(game_event):
userid = game_event['userid']
old_model = _old_models.pop(userid, None)
if old_model is not None:
Player.from_userid(userid).model = old_model
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Sat Nov 05, 2016 2:44 pm

.
Last edited by Painkiller on Wed Dec 28, 2016 12:18 am, edited 1 time in total.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Wed Dec 28, 2016 12:17 am

Hello someone could make the overlay so for attacker and Victime?

Thanks in Advance

This is The Actually Code was work:

Syntax: Select all

from contextlib import suppress

from engines.precache import Model
from engines.sound import Sound
from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from events import Event
from listeners.tick import Delay
from memory import make_object
from players.constants import HitGroup
from players.entity import Player
from stringtables.downloads import Downloadables


# =============================================================================
# >> CONFIGURATION
# =============================================================================
REMOVE_OVERLAY_TIME = 1.5
HEADSHOT_OVERLAY_VMT = "exae/rocksheadshot1.vmt"
HEADSHOT_OVERLAY_VTF = "exae/rocksheadshot1.vtf"

# Headshot but not dead sound + path
HEADSHOT_SOUND = 'exae/quake/human-hit-4.mp3'

# <weapon> : <headshot_sound>
WEAPON_FILES = {
'weapon_crossbow': 'exae/quake/headshot2.mp3',
'weapon_357' : 'exae/quake/headshot-2.mp3',
'weapon_smg1' : 'exae/quake/wife-headshot.mp3',
'weapon_ar2' : 'exae/quake/boomheadshot.mp3',
'weapon_pistol' : 'exae/quake/headshot-1.mp3',
'weapon_shotgun' : 'exae/quake/headshot2.mp3'
}

DEAD_MODEL_PATH = 'models/headless_body/metrocop.mdl'
DEAD_MODEL_DL_FILES = [
"models/headless_body/metrocop.dx80.vtx",
"models/headless_body/metrocop.dx90.vtx",
"models/headless_body/metrocop.mdl",
"models/headless_body/metrocop.phy",
"models/headless_body/metrocop.sw.vtx",
"models/headless_body/metrocop.vvd",
]
# =============================================================================
# >> END OF CONFIGURATION
# =============================================================================


HEADSHOT_SOUND = Sound(HEADSHOT_SOUND, download=True)
WEAPON_FILES = {x: Sound(y, download=True) for x, y in WEAPON_FILES.items()}
downloads = Downloadables()
for item in (HEADSHOT_OVERLAY_VMT, HEADSHOT_OVERLAY_VTF):
downloads.add('materials/' + item)
for item in DEAD_MODEL_DL_FILES:
downloads.add(item)

DEAD_MODEL = Model(
path=DEAD_MODEL_PATH,
preload=True,
)

_old_models = {}
_damage_weapons = {}


@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

victim = Player(victim.index)
info = make_object(TakeDamageInfo, stack_data[1])

# World damage?
if info.attacker == 0:
_damage_weapons[victim.userid] = 'worldspawn'

# Was a projectile used?
elif info.attacker != info.inflictor:
_damage_weapons[victim.userid] = Entity(info.inflictor).classname

# Not a projectile
else:
_damage_weapons[victim.userid] = Player(info.attacker).active_weapon.classname


@Event('player_hurt')
def player_hurt(game_event):
victim = Player.from_userid(game_event['userid'])
attacker_userid = game_event['attacker']

# Suicide?
if attacker_userid in (victim.userid, 0):
return

# Not a headshot?
if victim.hitgroup != HitGroup.HEAD:
return

# Victim still alive?
if game_event['health']:
HEADSHOT_SOUND.index = victim.index
HEADSHOT_SOUND.play(victim.index)
return

weapon_sound = WEAPON_FILES.get(_damage_weapons.get(victim.userid))
if weapon_sound is None:
return

# Play weapon specific headshot sound
weapon_sound.index = victim.index
weapon_sound.play()

# Set the victim's overlay
victim.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT
)
)
Delay(REMOVE_OVERLAY_TIME, _remove_overlay, victim.userid)

# Set the attacker's overlay
attacker = Player.from_userid(attacker_userid)
attacker.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT
)
)
Delay(REMOVE_OVERLAY_TIME, _remove_overlay, attacker_userid)

# Set the victim's model
_old_models[victim.userid] = victim.model
victim.model = DEAD_MODEL


@Event('player_spawn')
def _reset_model(game_event):
userid = game_event['userid']
old_model = _old_models.pop(userid, None)
if old_model is not None:
Player.from_userid(userid).model = old_model


def _remove_overlay(userid):
with suppress(Exception):
Player.from_userid(userid).client_command('r_screenoverlay 0')
User avatar
Ayuto
Project Leader
Posts: 1546
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Headshot Help

Postby Ayuto » Wed Dec 28, 2016 10:13 am

There was an update to the Delay class. This should fix your issue:

Syntax: Select all

from contextlib import suppress

from engines.precache import Model
from engines.sound import Sound
from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from events import Event
from listeners.tick import Delay
from memory import make_object
from players.constants import HitGroup
from players.entity import Player
from stringtables.downloads import Downloadables


# =============================================================================
# >> CONFIGURATION
# =============================================================================
REMOVE_OVERLAY_TIME = 1.5

HEADSHOT_OVERLAY_VMT_ATTACKER = "exae/rocksheadshot1.vmt"
HEADSHOT_OVERLAY_VTF_ATTACKER = "exae/rocksheadshot1.vtf"

HEADSHOT_OVERLAY_VMT_VICTIM = "exae/rocksheadshot1.vmt"
HEADSHOT_OVERLAY_VTF_VICTIM = "exae/rocksheadshot1.vtf"

# Headshot but not dead sound + path
HEADSHOT_SOUND = 'exae/quake/human-hit-4.mp3'

# <weapon> : <headshot_sound>
WEAPON_FILES = {
'weapon_crossbow': 'exae/quake/headshot2.mp3',
'weapon_357' : 'exae/quake/headshot-2.mp3',
'weapon_smg1' : 'exae/quake/wife-headshot.mp3',
'weapon_ar2' : 'exae/quake/boomheadshot.mp3',
'weapon_pistol' : 'exae/quake/headshot-1.mp3',
'weapon_shotgun' : 'exae/quake/headshot2.mp3'
}

DEAD_MODEL_PATH = 'models/headless_body/metrocop.mdl'
DEAD_MODEL_DL_FILES = [
"models/headless_body/metrocop.dx80.vtx",
"models/headless_body/metrocop.dx90.vtx",
"models/headless_body/metrocop.mdl",
"models/headless_body/metrocop.phy",
"models/headless_body/metrocop.sw.vtx",
"models/headless_body/metrocop.vvd",
]
# =============================================================================
# >> END OF CONFIGURATION
# =============================================================================


HEADSHOT_SOUND = Sound(HEADSHOT_SOUND, download=True)
WEAPON_FILES = {x: Sound(y, download=True) for x, y in WEAPON_FILES.items()}
downloads = Downloadables()
for item in (HEADSHOT_OVERLAY_VMT_ATTACKER, HEADSHOT_OVERLAY_VTF_ATTACKER,
HEADSHOT_OVERLAY_VMT_VICTIM, HEADSHOT_OVERLAY_VTF_VICTIM):
downloads.add('materials/' + item)

for item in DEAD_MODEL_DL_FILES:
downloads.add(item)

DEAD_MODEL = Model(
path=DEAD_MODEL_PATH,
preload=True,
)

_old_models = {}
_damage_weapons = {}


@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

victim = Player(victim.index)
info = make_object(TakeDamageInfo, stack_data[1])

# World damage?
if info.attacker == 0:
_damage_weapons[victim.userid] = 'worldspawn'

# Was a projectile used?
elif info.attacker != info.inflictor:
_damage_weapons[victim.userid] = Entity(info.inflictor).classname

# Not a projectile
else:
_damage_weapons[victim.userid] = Player(info.attacker).active_weapon.classname


@Event('player_hurt')
def player_hurt(game_event):
victim = Player.from_userid(game_event['userid'])
attacker_userid = game_event['attacker']

# Suicide?
if attacker_userid in (victim.userid, 0):
return

# Not a headshot?
if victim.hitgroup != HitGroup.HEAD:
return

# Victim still alive?
if game_event['health']:
HEADSHOT_SOUND.index = victim.index
HEADSHOT_SOUND.play(victim.index)
return

weapon_sound = WEAPON_FILES.get(_damage_weapons.get(victim.userid))
if weapon_sound is None:
return

attacker = Player.from_userid(attacker_userid)

# Play weapon specific headshot sound
weapon_sound.play(attacker.index)

# Set the victim's overlay
victim.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT_VICTIM
)
)
Delay(REMOVE_OVERLAY_TIME, _remove_overlay, [victim.userid])

# Set the attacker's overlay
attacker.client_command(
'r_screenoverlay {overlay}'.format(
overlay=HEADSHOT_OVERLAY_VMT_ATTACKER
)
)
Delay(REMOVE_OVERLAY_TIME, _remove_overlay, [attacker_userid])

# Set the victim's model
_old_models[victim.userid] = victim.model
victim.model = DEAD_MODEL


@Event('player_spawn')
def _reset_model(game_event):
userid = game_event['userid']
old_model = _old_models.pop(userid, None)
if old_model is not None:
Player.from_userid(userid).model = old_model


def _remove_overlay(userid):
with suppress(Exception):
Player.from_userid(userid).client_command('r_screenoverlay 0')

Edit: Also added constants to configure different overlays for attacker and victim.
Edit2: Sound is now played only to the attacker.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Wed Dec 28, 2016 4:19 pm

Thank you works good.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Wed Jan 04, 2017 12:38 pm

Its Completely done thanks on all and Kami for the headshot splatter effect.
User avatar
Painkiller
Senior Member
Posts: 204
Joined: Sun Mar 01, 2015 8:09 am
Contact:

Re: [HL2:DM] Headshot Help

Postby Painkiller » Mon Feb 20, 2017 8:50 pm

I have find an Error,
But I hear a lot in the game only on the when I'm killed no overlay and sound

Code: Select all

2017-02-20 19:01:30 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/plugins/headshot/headshot.py", line 98, in _pre_take_damage
    _damage_weapons[victim.userid] = Player(info.attacker).active_weapon.classname
  File "../addons/source-python/packages/source-python/entities/_base.py", line 116, in __getattr__
    raise AttributeError('Attribute "{0}" not found'.format(attr))

AttributeError: Attribute "active_weapon" not found

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 1 guest