Apparently, it's weirder than I thought. When I type kill in my client console, I actually get respawned, but I'm not visible to other players and my name is greyed out in the scoreboard.
EDIT: <PlayerEntity>.dead_flag returns 0..
Respawn player (csgo)
Ayuto wrote:If yes, <godmode> is no longer available and should raise an error.
This is not true when setting an attribute, because we allow inheriting classes to set unknown attributes. Retrieving one, if it has not already been defined, on the other hand, will raise an error.
Using PlayerEntity.respawn() should work fine, unless you are using a class that inherits from PlayerEntity that defines its own respawn method. PlayerEntity's utilizes the CCSPlayer::RoundRespawn dynamic function, which does not require you to set any network properties:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/data/source-python/entities/orangebox/cstrike/CCSPlayer.ini#L27
Actually, now that I think about it, I am not 100% sure you can respawn directly after dying. Try using a 1 tick delay:
Syntax: Select all
from entities.constants import INVALID_ENTITY_INDEX
from events import Event
from listeners.tick import tick_delays
from players.entity import PlayerEntity
from players.helpers import index_from_userid
@Event('player_death')
def respawn_on_death(game_event):
tick_delays.delay(0, respawn_player, game_event.get_int('userid'))
def respawn_player(userid):
index = index_from_userid(userid, False)
if index != INVALID_ENTITY_INDEX:
PlayerEntity(index).respawn()
satoon101 wrote:Actually, now that I think about it, I am not 100% sure you can respawn directly after dying. Try using a 1 tick delay:Syntax: Select all
from entities.constants import INVALID_ENTITY_INDEX
from events import Event
from listeners.tick import tick_delays
from players.entity import PlayerEntity
from players.helpers import index_from_userid
@Event('player_death')
def respawn_on_death(game_event):
tick_delays.delay(0, respawn_player, game_event.get_int('userid'))
def respawn_player(userid):
index = index_from_userid(userid, False)
if index != INVALID_ENTITY_INDEX:
PlayerEntity(index).respawn()
You're right, it needed a delay. Everything's fine now. Thanks y'all :)
That depends on the game, I guess. Apparently, we only have respawn added to the data for CS:S, currently. I will get that added to CS:GO here shortly.
Wait, I'm a bit confused as to why you need a respawn function in a game that automatically always respawns players. Whatever your reasons are, maybe try the following:
If I remember right, that same functionality used to work for TF2 and DOD:S. Though, I don't know if I ever saw it confirmed to work with HL2:DM. With CS:S, it was a little more complicated than that without using a signature:
http://forums.sourcepython.com/showthread.php?121&p=799&viewfull=1#post799 - that code no longer works, but it's the jist of what you have to do extra in CS:S compared to other games.
Syntax: Select all
from entities.helpers import spawn_entity
def respawn_player(index):
spawn_entity(index)
If I remember right, that same functionality used to work for TF2 and DOD:S. Though, I don't know if I ever saw it confirmed to work with HL2:DM. With CS:S, it was a little more complicated than that without using a signature:
http://forums.sourcepython.com/showthread.php?121&p=799&viewfull=1#post799 - that code no longer works, but it's the jist of what you have to do extra in CS:S compared to other games.
I should also note that if you already have a Player instance, you can just use the spawn method, which is a wrapper that uses the exact same code.
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/entities/entity.py#L201
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/entities/entity.py#L201
I actually think that we shouldn't use the signature method if we can achieve the same thing without memory hacking.satoon101 wrote:With CS:S, it was a little more complicated than that without using a signature:
http://forums.sourcepython.com/showthread.php?121&p=799&viewfull=1#post799 - that code no longer works, but it's the jist of what you have to do extra in CS:S compared to other games.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 83 guests