Healing and Hopefully Better Questions
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
Healing and Hopefully Better Questions
Is there a way to heal everyone on a specific team?
I swear I searched.
I swear I searched.
You mean loop through all players on a specific team and setting their health to 100? If so: Satoon
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
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
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'
Sorry, just realized this is an issue with the current download. Unfortunately, until we can fix our Linux build issues, we cannot release a new build. There are many things in the newest _libs that utilize functionality in more recent builds, which makes me hesitant to release the old build with the newest _libs.
Satoon
Satoon
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
Unfortunately, since the site went down, we have not really gotten the Wiki back up, yet. "health" is just an attribute of the PlayerEntity object. You get it by simply calling player.health and not "setting" player.health:For the time being, you can look through the _data files to see what all is available for specific entity types. Note that since PlayerEntity inherits from BaseEntity, all "entity" properties, functions, offsets, and keyvalues are available for players as well.
Satoon
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
Satoon
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
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.
retrieve the player entity from userid.
Syntax: Select all
from events import Event
@Event
def player_death(GameEvent):
victim_userid = GameEvent.GetInt('userid')
attack_userid = GameEvent.GetInt('attacker')
-Tuck
I'm not 100% sure what you are asking, but it seems to me you want to set the health of the "attacker" on player_death. If that is right: Of course, you might also want to verify that the kill wasn't a suicide or team kill prior to setting the health:
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
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
Getting a team's player count? I feel there is an easier way than what I was trying to do.
http://www.eventscripts.com/pages/Es_getlivingplayercount
http://www.eventscripts.com/pages/Es_getlivingplayercount
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Hey paytonpenn,
Taking the example Satoon gave you:
L'In20Cible
Taking the example Satoon gave you:
Syntax: Select all
ct_count = len(list(ct_players))
L'In20Cible
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
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.
Satoon
The only thing I could think it would be is that the health property uses an integer:
Syntax: Select all
# From ../_libs/_data/properties/player/csgo.ini
[health]
prop = "CBasePlayer.m_iHealth"
type = "Int"
Satoon
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
As satoon101 pointed out check your math formel it might return a decimal instead of int
-Tuck
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
I would've posted the error earlier but there isn't easy copying and pasting.

Here's a snip of the code that involves that, pretty sure its because the output gives a decimal and not a whole integer, so.. how does one go about rounding or an alternative method.
The error comes in when I add sehealthbp2 to the player's current health or attempt force it.

Here's a snip of the code that involves that, pretty sure its because the output gives a decimal and not a whole integer, so.. how does one go about rounding or an alternative method.
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
The error comes in when I add sehealthbp2 to the player's current health or attempt force it.
Yeah, it is definitely due to you passing a float value instead of an integer. Notice in the error, this section:So, the first arguments match, as it wants an edict_t instance, and the second arguments match, as it wants a string (C++ char equals Python str). The third argument, however, should be an integer, but you pass it a float.
You can get an integer one of two ways. You can typecast the result you wish to pass as an integer:or if you wish to round the value, you would use the built-in round function:
Satoon
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)
You can get an integer one of two ways. You can typecast the result you wish to pass as an integer:
Syntax: Select all
player.health = int(sehealthbp2)
Syntax: Select all
player.health = round(sehealthbp2)
Satoon
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 71 guests