Page 1 of 1
entity_edict.cpp question [How to respawn a player]
Posted: Thu Aug 30, 2012 11:40 pm
by BackRaw
I just looked at entity_edict.cpp (
hg/src/core/modules/entity/entity_edict.cpp) and there are these lines at the very end:
Syntax: Select all
CLASS_METHOD_TYPEDEF(DispatchSpawn,
&DispatchSpawn,
"Dispatches a message to spawn the entity."
)
Can we use that one to respawn a player? Something like
Syntax: Select all
from events import Event
from players import EasyPlayer
@Event
def player_death(GameEvent):
player = EasyPlayer(GameEvent.GetInt("userid"))
player.DispatchSpawn() # respawns the player
Posted: Thu Aug 30, 2012 11:42 pm
by your-name-here
BackRaw wrote:I just looked at entity_edict.cpp (
hg/src/core/modules/entity/entity_edict.cpp) and there are these lines at the very
Syntax: Select all
end:CLASS_METHOD_TYPEDEF(DispatchSpawn,
&DispatchSpawn,
"Dispatches a message to spawn the entity."
)
Can we use that one to respawn a player? Something like
Syntax: Select all
from events import Event
from players import EasyPlayer
@Event
def player_death(GameEvent):
player = EasyPlayer(GameEvent.GetInt("userid"))
player.DispatchSpawn() # respawns the player
I don't believe so because CCSPlayer has its own Respawn function you're supposed to call. I think DispatchSpawn is meant more for spawning entities into the map that you created via CreatEntityByName.
Posted: Thu Aug 30, 2012 11:43 pm
by BackRaw
your-name-here wrote:I don't believe so because CCSPlayer has its own Respawn function you're supposed to call. I think DispatchSpawn is meant more for spawning entities into the map that you created via CreatEntityByName.
Ah, thanks. Is this own respawn function available in the current revision?
Posted: Fri Aug 31, 2012 9:58 am
by ashbash1987
I tried using DispatchSpawn on player entities that died on a player_death event when I originally tested the code out, and all it did was remove the ragdolls and seemingly move the entity to a valid spawn location, but did not respawn the player fully.
Posted: Fri Aug 31, 2012 3:59 pm
by BackRaw
ashbash1987 wrote:I tried using DispatchSpawn on player entities that died on a player_death event when I originally tested the code out, and all it did was remove the ragdolls and seemingly move the entity to a valid spawn location, but did not respawn the player fully.
hhhmmm, okay thanks for the answer

I think we should wait until a fully functional method is being developed.
Posted: Sat Sep 01, 2012 11:33 am
by Kami
Couldn't it be that this command does something like es_spawnplayer did? So you had to set the Props:
'CCSPlayer.m_iPlayerState' 0
'CBasePlayer.m_lifeState' 512
and then use DispatchSpawn?
Posted: Sat Sep 01, 2012 6:19 pm
by Ayuto
Yeah, that's right. es_spawnplayer and es_spawnentity are using DispatchSpawn.
http://master.build.eventscripts.com/eventscripts/eventscripts2/file/6936a4bee74c/mattie_eventscripts.cpp#l3656I'm pretty sure that it would work, if you set these props.
Posted: Sat Sep 01, 2012 8:27 pm
by Monday
I'd be curious to see someone test this out.
Posted: Sun Sep 02, 2012 1:07 am
by satoon101
Yup, the following works on the newest unreleased version:
Syntax: Select all
from events import Event
from players import EasyPlayer
@Event
def player_say(GameEvent):
userid = GameEvent.GetInt('userid')
player = EasyPlayer(userid)
player.SetPropInt('CCSPlayer.m_iPlayerState', 0)
player.SetPropInt('CBasePlayer.m_lifeState', 512)
player.DispatchSpawn()
Satoon
Posted: Sun Sep 02, 2012 1:23 am
by Kami
Well then I hope the new release will come pretty soon! Thank you for testing it by the way

Posted: Sun Sep 02, 2012 2:30 pm
by Spiked
someone might want to rename this thread to "how to respawn a player" for easier finding in the future ^^
Posted: Mon Sep 03, 2012 1:00 am
by BackRaw
HA! I knew it !!!

Posted: Mon Sep 03, 2012 1:00 am
by BackRaw
Spiked wrote:someone might want to rename this thread to "how to respawn a player" for easier finding in the future ^^
Someone did it =)