but it does not work there is no error message.
Can anybody help?
Syntax: Select all
from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from memory import make_object
from players.entity import Player
from weapons.manager import weapon_manager
DAMAGE_TRIGGERS = [
'weapon_frag',
'weapon_handgrenade',
'grenade_mp5',
'grenade_rpg',
'weapon_satchel',
'weapon_tripmine',
]
@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
info = make_object(TakeDamageInfo, stack_data[1])
try:
weapon_index = info.weapon
weapon = Entity(weapon_index).classname
except:
return
try:
if weapon in DAMAGE_TRIGGERS:
fragcloud(Player(victim.index))
except AttributeError:
pass
def fragcloud(victim):
entity = make_object(Entity, victim.give_named_item('env_ar2explosion'))
entity.set_key_value_string('material', 'particle/smokeball3.vmt')
entity.call_input('Explode')
entity.delay(8, entity.remove)