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