Healing and Hopefully Better Questions
Posted: Sat Feb 02, 2013 11:05 pm
Is there a way to heal everyone on a specific team?
I swear I searched.
I swear I searched.
Syntax: Select all
from filters.players import PlayerIter
# This would be if you are doing this for CTs
# We use 'player' as the return_type to return a PlayerEntity instance
ct_players = PlayerIter(['ct', 'alive'], return_types='player')
# Randomly named function you wish to use to restore every players health on the team
def something():
# Iterate over all players who on alive CTs
for player in ct_players:
# Set the player's health
player.health = 100
Syntax: Select all
File '..\addons\source-python\_libs\filters\iterator.py', line 47, in __iter__
yield self.manager._return_types[self._return_types](item)
File '..\addons\source-python\_libs\filters\players.py', line 172, in _return_player
return PlayerEntity.get_instance_from_playerinfo(IPlayerInfo)
AttributeError: type object 'PlayerEntity' has no attribute 'get_instance_from_playerinfo'
Syntax: Select all
# Get player's current health
health = player.health
# Set player's current health
player.health = 100
# Add to player's current health
player.health += 50
paytonpenn wrote:Hmm.. Is there anyway I could heal a specific userid or attacker that doesn't isn't the "player", or how would I go about setting the "player" part for a specific player that triggered the event such as killing a player.
Syntax: Select all
from events import Event
@Event
def player_death(GameEvent):
victim_userid = GameEvent.GetInt('userid')
attack_userid = GameEvent.GetInt('attacker')
Syntax: Select all
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid
@Event
def player_death(GameEvent):
# Get the userid of the attacker
attacker = GameEvent.GetInt('attacker')
# Get the index of the attacker
index = index_from_userid(attacker)
# Get the attacker's PlayerEntity instance
player = PlayerEntity(index)
# Set the attacker's health
player.health = 100
Syntax: Select all
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid
from players.helpers import playerinfo_from_userid
@Event
def player_death(GameEvent):
# Get the userid of the attacker
attacker = GameEvent.GetInt('attacker')
# Get the userid of the victim
victim = GameEvent.GetInt('userid')
# Was this a suicide?
if attacker in (victim, 0):
# Do not increase health
return
# Get the index of the attacker
index = index_from_userid(attacker)
# Get the attacker's PlayerEntity instance
player = PlayerEntity(index)
# Get the victim's IPlayerInfo instance
vplayer = playerinfo_from_userid(victim)
# Was this a team kill?
if player.team == vplayer.GetTeamIndex():
# Do not increase health
return
# Set the attacker's health
player.health = 100
Syntax: Select all
ct_count = len(list(ct_players))
Syntax: Select all
# From ../_libs/_data/properties/player/csgo.ini
[health]
prop = "CBasePlayer.m_iHealth"
type = "Int"
satoon101 wrote:As they said, it would be much easier to help you if we could see the code/error instead of just guessing at what your issue could possibly be.
The only thing I could think it would be is that the health property uses an integer:So, you "must" pass an integer when setting the value.Syntax: Select all
# From ../_libs/_data/properties/player/csgo.ini
[health]
prop = "CBasePlayer.m_iHealth"
type = "Int"
Satoon
Syntax: Select all
@Event
def bomb_planted(GameEvent):
if sesharing == 1:
sesearch = PlayerIter(['t', 'alive'], return_types='player')
t_count = len(list(sesearch))
for player in sesearch:
sehealthbp2 = sehealthbp / t_count
health = player.health
sehealthalt = semaxhealth - sehealthbp2
Code: Select all
Boost.Python.ArgumentError: Python argument types in
edict_t.SetPropInt(edict_t, str, float)
did not match C++ signature:
SetPropInt(struct edict_t *, char const * szFullPath, int propValue)
Syntax: Select all
player.health = int(sehealthbp2)
Syntax: Select all
player.health = round(sehealthbp2)