Raised This Month: $404 Target: $400
 101% 

How To: Respawn a player


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-20-2008 , 12:36   Re: How To: Respawn a player
Reply With Quote #11

It's really in fakemeta_util. But I just wanted to show the iuser part. That's all.
__________________
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-20-2008 , 12:45   Re: How To: Respawn a player
Reply With Quote #12

Ok, things are cleared up now.

Is it really needed (and why) to spawn twice (with the 0.5 delay) ?


And also, what about the spectator bug ? ( csdm module has its own respawn to avoid this bug right ? )
__________________
- tired and retired -
ConnorMcLeod is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-20-2008 , 15:19   Re: How To: Respawn a player
Reply With Quote #13

@ Orangutanz - Yea, you can spawn it instantly with proper HUD.
Without hamsandwich that is the best methode...like in fakemeta_util, but replace _Spawn with _Think, _Spawn works perfect when player is alive but when is dead has that HUD bug. (can be fixed like i said below)

@ connorr - Yea, is needed to spawn twice. Why ?! Because first time will spawn you with HUD bug, then second time player will be alive and the HUD will be restored.
Alka is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 08-20-2008 , 19:03   Re: How To: Respawn a player
Reply With Quote #14

code optimized to yall's liking I'm sure.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 08-20-2008 , 21:13   Re: How To: Respawn a player
Reply With Quote #15

Quote:
Originally Posted by Alka View Post
@ Orangutanz - Yea, you can spawn it instantly with proper HUD.
Without hamsandwich that is the best methode...like in fakemeta_util, but replace _Spawn with _Think, _Spawn works perfect when player is alive but when is dead has that HUD bug. (can be fixed like i said below)

@ connorr - Yea, is needed to spawn twice. Why ?! Because first time will spawn you with HUD bug, then second time player will be alive and the HUD will be restored.
Can you elaborate about this HUD bug, since I've never actually come across it AFAIK?
Orangutanz is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 08-20-2008 , 21:14   Re: How To: Respawn a player
Reply With Quote #16

Quote:
Originally Posted by GHW_Chronic View Post
code optimized to yall's liking I'm sure.
Code:
        //Spawn player         spawn(id) // WHAT IS THIS???         dllfunc(DLLFunc_Spawn,id)
Orangutanz is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 08-21-2008 , 09:24   Re: How To: Respawn a player
Reply With Quote #17

Quote:
Originally Posted by Orangutanz View Post
spawn(id) // WHAT IS THIS???
A nativ from fun
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 08-21-2008 at 09:27.
fxfighter is offline
Send a message via MSN to fxfighter
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 08-22-2008 , 11:39   Re: How To: Respawn a player
Reply With Quote #18

Quote:
Originally Posted by fxfighter View Post
If that is the case it shouldn't be used!

What idiot wrote this for that native:
Quote:
If spawning a player, spawn should be used twice to avoid a bug with HL.
That is the cause of the player ghost bug! 1 spawn is enough you just have to get the other edict data setup correctly before you call it.

Last edited by Orangutanz; 08-22-2008 at 11:42.
Orangutanz is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 08-29-2008 , 20:34   Re: How To: Respawn a player
Reply With Quote #19

I've been testing this in both CS and CZ, and I think the best method to respawn dead players (besides using Hamsandwich, of course) is definitely the "DEAD_RESPAWNABLE + THINK" one. I agree there is no need to call it more than once. Also, it doesn't matter what your pev_iuser# values are set to, as long as you're dead.

Using DLLFunc_Spawn on players (or Fun's spawn() native, which is basically the same thing) isn't reliable since you can get different results depending on when it's called, listed below:

Alive
Details: Your dead flag is DEAD_NO (0).
First call: You get teleported to one of your team spawns (info_player_start for CTs, info_player_deathmatch for Terrorists). You don't get stripped from your guns.
Successive calls: Same as first.

Dying
Details: Your dead flag is DEAD_DYING (1) and the death sequence of your model is being played. Your camera points in direction to your attacker.
First call: You do respawn correctly here.
Successive calls: Same as alive.

Died
Details: The camera is still following your attacker, but your dead flag is now DEAD_DEAD (2). Your pev_iuser values are: 2, [victim id], [attacker id], and 0, respectively.
First call: You respawn with the so called "HUD bug". You can't see your crosshair, use the flashlight, nor switch your weapons by using slot1, slot2, etc. Also, you don't get a knife.
Second call: The HUD bug gets fixed, but you still don't have a knife.
Successive calls: Same as alive.

Dead
Details: You have control of your camera to spectate other players. Your dead flag is DEAD_DEAD.
First call: You seem to become alive to the engine, but your camera is still in spectator mode as if you were dead and you can't control yourself. If you switch to Free Look and navigate to where you were supposed to spawn, you'll see a static model in your place. If you wait until the next round, you'll spawn with no weapons at all.
Second call: The aforementioned bug gets fixed and you respawn, but you aren't given any weapons.
Successive calls: Same as alive.

Joining a team for the first time
Details: When you don't spawn right away. Instead, you have to wait for the next round, even though your dead flag is DEAD_RESPAWNABLE (3).
First call: You do respawn correctly, which makes some sense.
Successive calls: Same as alive.

I made several attempts to get the bugs fixed by setting a different dead flag and/or editing the pev_iuser fields of players before calling DLLFunc_Spawn. All to no avail.


To conclude, here's the code I use to respawn players without hamsandwich. Works for human players as well as bots.
Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> new cvar_respawndelay public plugin_init() {     register_plugin("Player", "Respawn", "Test")     register_event("DeathMsg", "event_deathmsg", "a")     cvar_respawndelay = register_cvar("amx_respawndelay", "5.0") // Delay before respawning } public event_deathmsg() {     // read_data(2) = victim     set_task(get_pcvar_float(cvar_respawndelay), "respawn_player", read_data(2)) } public respawn_player(id) {     // Disconnected, already spawned, or switched to Spectator     if (!is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)         return;         // (Debug only)     client_print(0, print_chat, "Player %d is being respawned", id)         // Try to spawn the player setting the appropiate dead flag and forcing a think     set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)     dllfunc(DLLFunc_Think, id)         // Fix for CZ Bots: DLLFunc_Think won't work on them,     // but DLLFunc_Spawn does the job without any bugs.     // (for some reason I'm not suprised...)     if (is_user_bot(id) && pev(id, pev_deadflag) == DEAD_RESPAWNABLE)     {         dllfunc(DLLFunc_Spawn, id)     } }
__________________
MeRcyLeZZ is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: La Plata, Bs As, Argenti
Old 08-30-2008 , 13:59   Re: How To: Respawn a player
Reply With Quote #20

Thank MeRcyLeZZ
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:41.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode