Raised This Month: $51 Target: $400
 12% 

REspawn cliet on death event


Post New Thread Reply   
 
Thread Tools Display Modes
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-20-2017 , 01:53   Re: REspawn cliet on death event
Reply With Quote #11

Quote:
Originally Posted by Neuro Toxin View Post
Dont parse client indices through timers/frames.

Use user ids
Is it really needed for frames?

I always assumed that once a client disconnects, that it would occur on the next time frame.
__________________

Last edited by Chaosxk; 04-20-2017 at 01:54.
Chaosxk is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-20-2017 , 03:13   Re: REspawn cliet on death event
Reply With Quote #12

Reserved slots might sneak in a new client over one frame.

It also avoids checking IsClientInGame in the callback.
__________________
Neuro Toxin is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 04-20-2017 , 05:17   Re: REspawn cliet on death event
Reply With Quote #13

Puuuh......no need for timers/requestframe , simply check the health on player_hurt , something like this:

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required


public void OnPluginStart() 
{
    HookEvent("player_hurt", Event_Hurt, EventHookMode_Post);
} 

public Action Event_Hurt(Event gEventHook, const char[] gEventName, bool iDontBroadcast) 
{
    int client = GetClientOfUserId(gEventHook.GetInt("userid"));
    
    int g_damage = GetEventInt(gEventHook, "health");

    if(g_damage < 1) 
    {
        CS_RespawnPlayer(client);
        PrintToChat(client, "Respawned!!!");
    }
}
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
pride95
Senior Member
Join Date: Aug 2015
Old 04-21-2017 , 09:08   Re: REspawn cliet on death event
Reply With Quote #14

Quote:
Originally Posted by andi67 View Post
Puuuh......no need for timers/requestframe , simply check the health on player_hurt , something like this:

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required


public void OnPluginStart() 
{
    HookEvent("player_hurt", Event_Hurt, EventHookMode_Post);
} 

public Action Event_Hurt(Event gEventHook, const char[] gEventName, bool iDontBroadcast) 
{
    int client = GetClientOfUserId(gEventHook.GetInt("userid"));
    
    int g_damage = GetEventInt(gEventHook, "health");

    if(g_damage < 1) 
    {
        CS_RespawnPlayer(client);
        PrintToChat(client, "Respawned!!!");
    }
}
and the death event is not broadcasted
pride95 is offline
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Old 04-22-2017 , 20:29   Re: REspawn cliet on death event
Reply With Quote #15

Quote:
Originally Posted by andi67 View Post
Puuuh......no need for timers/requestframe , simply check the health on player_hurt
Nice. This seems to get the as quick as possible
lugui is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-22-2017 , 21:46   Re: REspawn cliet on death event
Reply With Quote #16

The quickest way is to hook OnTakeDamageAlive.

Why is one frame so important?
__________________
Neuro Toxin is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 04-27-2017 , 04:17   Re: REspawn cliet on death event
Reply With Quote #17

Better in this way
Code:
#pragma newdecls required

#include <sdktools>
#include <cstrike>

public void OnPluginStart() 
{
    HookEvent("player_hurt", Event_Hurt, EventHookMode_Post);
} 

public void Event_Hurt(Event event, const char[] name, bool dontBroadcast) 
{
    if(event.GetInt(event, "health") < 1)
    {
        int client = GetClientOfUserId(event.GetInt("userid"));
        if(client)
        {
            CS_RespawnPlayer(client);
            PrintToChat(client, "Respawned!!!");
        }
    }
}
__________________

Last edited by Grey83; 04-27-2017 at 04:21.
Grey83 is offline
Reply



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 01:56.


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