entity_edict.cpp question [How to respawn a player]

All other Source.Python topics and issues.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

entity_edict.cpp question [How to respawn a player]

Postby BackRaw » Thu Aug 30, 2012 11:40 pm

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
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Thu Aug 30, 2012 11:42 pm

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.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Aug 30, 2012 11:43 pm

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?
User avatar
ashbash1987
Developer
Posts: 20
Joined: Tue Jul 10, 2012 12:01 pm
Location: Sheffield, UK
Contact:

Postby ashbash1987 » Fri Aug 31, 2012 9:58 am

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.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Aug 31, 2012 3:59 pm

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.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Postby Kami » Sat Sep 01, 2012 11:33 am

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?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sat Sep 01, 2012 6:19 pm

Yeah, that's right. es_spawnplayer and es_spawnentity are using DispatchSpawn. http://master.build.eventscripts.com/eventscripts/eventscripts2/file/6936a4bee74c/mattie_eventscripts.cpp#l3656
I'm pretty sure that it would work, if you set these props.
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sat Sep 01, 2012 8:27 pm

I'd be curious to see someone test this out.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Sep 02, 2012 1:07 am

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
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Postby Kami » Sun Sep 02, 2012 1:23 am

Well then I hope the new release will come pretty soon! Thank you for testing it by the way :)
User avatar
Spiked
Junior Member
Posts: 15
Joined: Mon Aug 27, 2012 8:00 pm
Location: Texas

Postby Spiked » Sun Sep 02, 2012 2:30 pm

someone might want to rename this thread to "how to respawn a player" for easier finding in the future ^^
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Mon Sep 03, 2012 1:00 am

HA! I knew it !!! :D
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Mon Sep 03, 2012 1:00 am

Spiked wrote:someone might want to rename this thread to "how to respawn a player" for easier finding in the future ^^


Someone did it =)

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 31 guests