Play Sound for Attacker
Posted: Wed Apr 11, 2018 12:19 pm
Hello,
iam trying to play a sound for the attacker.
Sadly i dont know where to start to debug since i don't get any error messages, etc.
Here my code so far:
There are currently two methods so far.
Player.play_sound
and
Sound.play(index)
am i right?
I would like to get both to work but it seems like it doesn't even work with the "radius" one.
Cheers,
CANi
iam trying to play a sound for the attacker.
Sadly i dont know where to start to debug since i don't get any error messages, etc.
Here my code so far:
Syntax: Select all
@EntityPreHook(EntityCondition.is_human_player, 'on_take_damage')
def _pre_take_damage(stack_data):
take_damage_info = make_object(TakeDamageInfo, stack_data[1])
attacker = Entity(take_damage_info.attacker)
victim = make_object(Entity, stack_data[0])
if attacker.classname != 'player':
take_damage_info.damage = 0
return
if victim.team_index == attacker.team_index:
return
attackerPlayer = Player(take_damage_info.attacker)
hitSound(attackerPlayer, take_damage_info.attacker)
def hitSound(attackingPlayer, index):
soundArr = [];
for file in os.listdir("./csgo/sound/instagib/"):
soundArr.append(os.path.join("instagib/", file))
randomSound = random.choice(soundArr)
attackingPlayer.play_sound(randomSound, volume=1.0, attenuation=5000)
print("played!")
There are currently two methods so far.
Player.play_sound
and
Sound.play(index)
am i right?
I would like to get both to work but it seems like it doesn't even work with the "radius" one.
Cheers,
CANi