Raised This Month: $ Target: $400
 0% 

How to Check if the player is dead?


Post New Thread Reply   
 
Thread Tools Display Modes
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 03-31-2008 , 15:07   Re: How to Check if the player is dead?
Reply With Quote #11

Code:
if ( ! is_user_alive ( index ) ) {
//

}
__________________

anakin_cstrike is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 03-31-2008 , 15:59   Re: How to Check if the player is dead?
Reply With Quote #12

Wrong foruom, anakin.
bl4nk is offline
franzcis066
Member
Join Date: Nov 2007
Old 03-31-2008 , 17:25   Re: How to Check if the player is dead?
Reply With Quote #13

Code:
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>

new ragdollOffset;

public Plugin:myinfo =
{
    name = "",
    author = "",
    description = "",
    version = "1.0",
    url = ""
}

public OnPluginStart()
{
    HookEvent("player_death", Event_Death);
    ragdollOffset = FindSendPropOffs("CCSPlayer","m_hRagdoll");
}

public Event_Death(Handle:Death_Event, const String:Death_Name[], bool:Death_Broadcast)
{    
    new Clientid = GetEventInt(Death_Event,"userid");
    new Client = GetClientOfUserId(Clientid);
    CreateTimer(2.0, RemoveRagdoll, any:Client);
    CreateTimer(30.0, RespawnClient, any:Client);
}

public Action:RemoveRagdoll(Handle:timer, any:Client)
{
    new playerRagdoll = GetEntDataEnt(Client, ragdollOffset);
    SetEntDataEnt(Client, ragdollOffset, 0, true);
    
    if(IsClientInGame(Client) && IsValidEntity(Client) && playerRagdoll > 0 )
    {
    RemoveEdict(playerRagdoll);
    }
}

public Action:RespawnClient(Handle:timer, any:Client)
{  
    if(IsPlayerAlive(Client)) 
    {
    /*Nothing*/
    }
    else
    {
    CS_RespawnPlayer(Client);
    }
}
This code works but that error is still a prob
Code:
L 06/05/2008 - 01:25:08: [SM] Native "GetEntDataEnt" reported: Entity 2 is invalid
This happens everytime when a client kills then drops from the server at the same time the ragdoll is counting for deletion..
I really dont know what to do now
franzcis066 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 03-31-2008 , 19:18   Re: How to Check if the player is dead?
Reply With Quote #14

stick this in there at the beginning of RemoveRagdoll

PHP Code:
if (!IsValidEntity(Client))
    return; 
bl4nk is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 04-01-2008 , 10:37   Re: How to Check if the player is dead?
Reply With Quote #15

Copy pasted code from my WarMod plugin

PHP Code:
public Action:RemoveRagdoll(Handle:timerany:victim)
{
    if (
IsValidEntity(victim) && !IsPlayerAlive(victim))
    {
        new 
player_ragdoll GetEntDataEnt2(victimg_i_ragdolls);
        if (
player_ragdoll != -1)
            
RemoveEdict(player_ragdoll);
    }

- Twelve-60
__________________

Last edited by Twelve-60; 04-01-2008 at 10:45.
Twelve-60 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 03:21.


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