[HL2:DM] Killsound

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: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[HL2:DM] Killsound

Postby Painkiller » Mon Apr 13, 2020 9:08 am

Hello SourcePython Team and Community,

could somebody turn that into SP for me?
If possible, the burning corpse option should be excluded.

Syntax: Select all

# =============================================================================
# >> CONFIG (Start)
# =============================================================================
# Waffen, die einen Effekt erzeugen sollen. Bsp.:
# '<Klassenname der Waffe>: (<0 oder 1>, <None oder Soundpfad>),
# Die 0 bzw. 1 gibt an, ob die Leiche brennen soll. None gibt an, dass kein
# Sound abgespielt werden soll. Wenn einer abgespielt werden soll, einfach den
# Pfad zum Sound angeben. Der Soundordner wird nicht mit angegeben. Also
# statt 'sound/ambient/...' musst du 'ambient/...' eintragen.
WEAPONS = {
'grenade_frag': (0, 'effects/levelup2.mp3'),
'slam': (0, 'effects/levelup2.mp3'),
'pistol': (0, 'effects/bonus.mp3'),
'rpg_missile': (0, 'effects/rocket.mp3'),
'combine_ball': (0, 'effects/perfects.mp3'),
}

# Soundlautstaerke
VOLUME = 1.0

# Soundreichweite - 0.0 == Ueberall auf der Map, 1.0 nur der tote Spieler
ATTENUATION = 0.5

# =============================================================================
# >> CONFIG (ENDE)
# =============================================================================
import es

info = es.AddonInfo()
info.name = "RocKs Player Level"
info.version = "1.0"
info.author = "Ayuto"
info.url = "www.rocks-clan.de"
info.description = "RocKs Player Level"

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

def player_death(ev):
weapon = ev['weapon']
if weapon not in WEAPONS:
return

userid = ev['userid']
burn, sound = WEAPONS[weapon]
if sound:
es.emitsound('player', userid, sound, VOLUME, ATTENUATION)

if not burn:
return

handle = es.getplayerhandle(userid)
classname, playerprop = ragdoll.getRagdollData()
for index in es.getEntityIndexes(classname):
if handle != es.getindexprop(index, playerprop):
continue

es.setentityname(index, index)
es.fire(userid, index, 'Ignite')
break

class Ragdoll(object):
ragdolldata = None

def getRagdollData(self):
if self.ragdolldata:
return self.ragdolldata

for index, entity in es.createentitylist().iteritems():
classname = entity['classname']
if not classname.endswith('_ragdoll'):
continue

for prop in entity:
if not prop.endswith('m_hPlayer'):
continue

data = self.ragdolldata = (classname, prop)
return data

raise NameError('Cannot find player property')

raise NameError('Cannot find game ragdoll')

ragdoll = Ragdoll()


Thanks in Advance.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Killsound

Postby Painkiller » Sun Aug 02, 2020 1:44 pm

push
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [HL2:DM] Killsound

Postby VinciT » Thu Aug 06, 2020 2:15 am

Here you go, without the burning ragdolls:

Syntax: Select all

# ../killsound/killsound.py

# Source.Python
from events import Event
from players.entity import Player


VOLUME = 1.0
# How quickly does the sound fade based on distance?
# (0: no fading at all, can be heard across the whole map)
ATTENUATION = 0.5


WEAPONS = {
'combine_ball': 'effects/perfects.mp3',
'grenade_frag': 'effects/levelup2.mp3',
'rpg_missile': 'effects/rocket.mp3',
'pistol': 'effects/bonus.mp3',
'slam': 'effects/levelup2.mp3'
}


@Event('player_death')
def player_death(event):
try:
sound_path = WEAPONS[event['weapon']]
except KeyError:
return

Player.from_userid(event['userid']).emit_sound(
sample=sound_path,
volume=VOLUME,
attenuation=ATTENUATION
)
ImageImageImageImageImage
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Killsound

Postby Painkiller » Thu Aug 06, 2020 8:23 am

This error appears in the log

Code: Select all

2020-08-06 10:19:17 - 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/effect_sound/effect_sound.py", line 37, in player_death
    attenuation=ATTENUATION
  File "../addons/source-python/packages/source-python/entities/_base.py", line 972, in emit_sound
    sound_time, speaker_entity, download)
  File "../addons/source-python/packages/source-python/engines/sound.py", line 149, in __init__
    self._sample = sample.replace('\\', '/')

AttributeError: 'tuple' object has no attribute 'replace'
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Killsound

Postby satoon101 » Thu Aug 06, 2020 10:57 am

Did you edit WEAPONS in the script to match what was in the original? If you did, you should undo that. I don't see any way the script he posted would cause that error without you having made that change.
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Killsound

Postby Painkiller » Thu Aug 06, 2020 1:10 pm

the only thing i did, i added a 1 or 0 before the sound to turn it on and off

Is that wrong?

Syntax: Select all

WEAPONS = {
'rpg_missile': (0, 'effects/earthquake.mp3'),
'crowbar': (0, 'effects/psycho.wav'),
'stunstick': (0, 'effects/lichtkeule.wav'),
'grenade_frag': (0, 'effects/earthquake.mp3'),
'smg1_grenade': (0, 'effects/earthquake.mp3'),
'combine_ball': (0, 'effects/death_combine.mp3'),
'slam': (1, 'effects/earthquake.mp3'),
'crossbow_bolt': (0, 'effects/wpn_crossbow_fire_02.wav'),
'pistol': (0, 'effects/sonicrings.wav'),
}


i made the numbers go away and it works.

It's a pity the numbers don't work anymore.

Thanks VinciT
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Killsound

Postby satoon101 » Thu Aug 06, 2020 1:53 pm

Unless I am reading it wrong, the 1/0 in the original script were to enable/disable the fire and had nothing to do with the sound.
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Killsound

Postby Painkiller » Thu Aug 06, 2020 2:17 pm

You're right. It's been so long since I've been able to get through this.

But fire is not what I need in this script. I have that in another script.
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [HL2:DM] Killsound

Postby VinciT » Thu Aug 06, 2020 7:38 pm

Painkiller wrote:the only thing i did, i added a 1 or 0 before the sound to turn it on and off
If you want to use the numbers as a toggle for the sounds, give this a try:

Syntax: Select all

# ../killsound/killsound.py

# Source.Python
from events import Event
from players.entity import Player


VOLUME = 1.0
# How quickly does the sound fade based on distance?
# (0: no fading at all, can be heard across the whole map)
ATTENUATION = 0.5


WEAPONS = {
'rpg_missile': (0, 'effects/earthquake.mp3'),
'crowbar': (0, 'effects/psycho.wav'),
'stunstick': (0, 'effects/lichtkeule.wav'),
'grenade_frag': (0, 'effects/earthquake.mp3'),
'smg1_grenade': (0, 'effects/earthquake.mp3'),
'combine_ball': (0, 'effects/death_combine.mp3'),
'slam': (1, 'effects/earthquake.mp3'),
'crossbow_bolt': (0, 'effects/wpn_crossbow_fire_02.wav'),
'pistol': (0, 'effects/sonicrings.wav')
}


@Event('player_death')
def player_death(event):
try:
should_play, sound_path = WEAPONS[event['weapon']]
except KeyError:
return

if should_play:
Player.from_userid(event['userid']).emit_sound(
sample=sound_path,
volume=VOLUME,
attenuation=ATTENUATION
)
ImageImageImageImageImage
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Killsound

Postby Painkiller » Thu Aug 06, 2020 8:14 pm

ty

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 17 guests