Yes, I use this code in player_hurt, but it can not be called twice, because I have a check for weapons, with which was damaged.
I use the following code to cause damage to the CS:GO of, as the other options do not work.
It does not cause any errors, just does not work. (I added virtual_function in ../engines/csgo/CBaseEntity.ini).
Syntax: Select all
def damage(victim_index, attacker_index, damage=-1, damage_type=32):
victim = BaseEntity(victim_index)
if damage == -1:
damage=victim.health
victim.damage(damage = int(damage), damage_type = damage_type, attacker = attacker_index, inflictor = victim_index)
Work, but a player dies from suicide.
Syntax: Select all
def damage(victim_index, attacker_index, damage=-1, damage_type=32):
victim = BaseEntity(victim_index)
if damage == -1:
damage = 2**16
victim.add_output("targetname mrdamage")
point = BaseEntity(create_entity("point_hurt"))
point.add_output("DamageTarget mrdamage")
point.add_output("damage "+str(damage))
point.add_output("damagetype "+str(damage_type))
point.add_output("classname weapon_awp")
point.call_input("Hurt", caller = attacker_index)
point.call_input("Kill")
victim.add_output("targetname mrhuman")
I tested this code in css, the player also die from suicide.
Code:
Syntax: Select all
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source Python
from events import Event
from players.helpers import index_from_userid
from players.entity import PlayerEntity
from entities.helpers import spawn_entity
from entities.helpers import create_entity
from entities.entity import BaseEntity
# =============================================================================
# >> EVENTS
# =============================================================================
@Event
def player_hurt(args):
vindex = index_from_userid(args.get_int("userid"))
aindex = args.get_int("attacker")
print("weapon ->", args.get_string("weapon"))
if aindex:
aindex = index_from_userid(aindex)
damage(vindex, aindex)
# =============================================================================
# >> FUNCTIONS
# =============================================================================
def damage(victim_index, attacker_index, damage=-1, damage_type=32):
victim = BaseEntity(victim_index)
if damage == -1:
damage = 2**16
victim.add_output("targetname mrdamage")
point = BaseEntity(create_entity("point_hurt"))
point.add_output("DamageTarget mrdamage")
point.add_output("damage "+str(damage))
point.add_output("damagetype "+str(damage_type))
point.add_output("classname weapon_awp")
point.call_input("Hurt", caller = attacker_index)
point.call_input("Kill")
victim.add_output("targetname mrhuman")
console:
Game: