#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
new Handle:Timer_Respawn[MAXPLAYERS+1] = {INVALID_HANDLE, ... },
Handle:Timer_Dissolve[MAXPLAYERS+1] = {INVALID_HANDLE, ... },
Handle:Timer_Protect[MAXPLAYERS+1] = {INVALID_HANDLE, ... };
public Plugin:myinfo =
{
name = "Knife DeathMatch",
author = "R1KO, remake by KorDen",
version = "1.0",
url = "http://dev.sky-play.ru"
};
public OnPluginStart()
{
CreateConVar("cssdm_version", "2.1.6-compat", "Fake cvar for monitors", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
HookEvent("player_death", OnPlayerDeath);
HookEvent("player_spawn", OnPlayerSpawn);
HookEvent("player_team", OnPlayerTeam);
}
public OnPlayerTeam(Handle:event, const String:name[], bool:silent)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client > 0)
{
new team = GetEventInt(event, "team");
if (team > 1 && GetEventInt(event, "oldteam") > 0)
Timer_Respawn[client] = CreateTimer(1.0, f_Respawn, client);
else
KillTimerS(client);
}
}
public OnPlayerSpawn(Handle:event, const String:name[], bool:silent)
{
new client = GetClientOfUserId(GetEventInt(event, "userid")), team=GetClientTeam(client);
if (client > 0)
{
SetEntProp(client, Prop_Data, "m_takedamage", 0);
if (team == 2) SetNewColor(client, 255, 75, 75, 200);
else if (team==3) SetNewColor(client, 75, 75, 255, 200);
Timer_Protect[client] = CreateTimer(1.0, ProtectTimer_CallBack, client);
}
}
public Action:ProtectTimer_CallBack(Handle:timer, any:client)
{
if (IsClientInGame(client) && IsPlayerAlive(client))
{
SetEntProp(client, Prop_Data, "m_takedamage", 2);
SetNewColor(client, 255, 255, 255, 255);
}
Timer_Protect[client] = INVALID_HANDLE;
}
SetNewColor(client, r, g, b, a)
{
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityRenderColor(client, r, g, b, a);
}
public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsValidEntity(client) && IsClientInGame(client))
{
new ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
if(ragdoll>0)
{
new Handle:datapack = INVALID_HANDLE;
Timer_Dissolve[client] = CreateDataTimer(2.0, f_Dissolve, datapack, TIMER_FLAG_NO_MAPCHANGE);
WritePackCell(datapack, ragdoll);
WritePackCell(datapack, client);
ResetPack(datapack);
}
}
Timer_Respawn[client] = CreateTimer(3.0, f_Respawn, client);
}
public Action:f_Dissolve(Handle:timer, Handle:datapack)
{
new ragdoll=ReadPackCell(datapack);
new client=ReadPackCell(datapack);
if(IsValidEntity(ragdoll))
AcceptEntityInput(ragdoll, "kill");
Timer_Dissolve[client] = INVALID_HANDLE;
}
public Action:f_Respawn(Handle:timer, any:client)
{
Timer_Respawn[client] = INVALID_HANDLE;
if (IsClientInGame(client) && !IsPlayerAlive(client))
CS_RespawnPlayer(client);
}
public OnClientDisconnect(client)
KillTimerS(client);
KillTimerS(client)
{
if (Timer_Respawn[client] != INVALID_HANDLE)
{
KillTimer(Timer_Respawn[client]);
Timer_Respawn[client] = INVALID_HANDLE;
}
if (Timer_Dissolve[client] != INVALID_HANDLE)
{
KillTimer(Timer_Dissolve[client]);
Timer_Dissolve[client] = INVALID_HANDLE;
}
if (Timer_Protect[client] != INVALID_HANDLE)
{
KillTimer(Timer_Protect[client]);
Timer_Protect[client] = INVALID_HANDLE;
}
}