Untitled diff
91 lines
#include <sourcemod>
#include <sourcemod>
#include <sdktools>
#include <sdktools>
#include <cstrike>
#include <cstrike>
#define DATA "1.1"
#define DATA "1.1"
#define RESPAWNT 0.5 // time for respawn
#define RESPAWNT 0.5 // time for respawn
public Plugin:myinfo =
public Plugin:myinfo =
{
{
name = "SM Franug Auto Respawn",
name = "AutoRespawn (iRespawner)",
author = "Franc1sco franug",
author = "Philip",
description = "",
description = "Auto Respawning dead players!",
version = DATA,
version = "0.1",
url = "http://steamcommunity.com/id/franug"
url = "http://steamcommunity.com/id/PhilipTheBoss321/"
};
};
bool enable = true;
bool enable = true;
new Float:g_fDeathTime[MAXPLAYERS+1];
new Float:g_fDeathTime[MAXPLAYERS+1];
public OnPluginStart()
public OnPluginStart()
{
{
//HookEvent("round_start", Restart);
//HookEvent("round_start", Restart);
HookEvent("player_death", Event_Playerd2);
HookEvent("player_death", Event_Playerd2);
AddCommandListener(OnJoinTeam, "jointeam");
AddCommandListener(OnJoinTeam, "jointeam");
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
}
}
public Action:Event_Playerd2(Handle:event, const String:name[], bool:dontBroadcast)
public Action:Event_Playerd2(Handle:event, const String:name[], bool:dontBroadcast)
{
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(enable) CreateTimer(RESPAWNT, Resp, client);
if(enable) CreateTimer(RESPAWNT, Resp, client);
}
}
public Action:Resp(Handle timer, int client)
public Action:Resp(Handle timer, int client)
{
{
if(IsClientInGame(client) && !IsPlayerAlive(client) && GetClientTeam(client) > 1 && enable) CS_RespawnPlayer(client)
if(IsClientInGame(client) && !IsPlayerAlive(client) && GetClientTeam(client) > 1 && enable) CS_RespawnPlayer(client)
}
}
public Action:OnJoinTeam(client, const String:command[], numArgs)
public Action:OnJoinTeam(client, const String:command[], numArgs)
{
{
if (!IsClientInGame(client) || numArgs < 1) return Plugin_Continue;
if (!IsClientInGame(client) || numArgs < 1) return Plugin_Continue;
if(!IsPlayerAlive(client))
if(!IsPlayerAlive(client))
if(enable) CreateTimer(RESPAWNT, Resp, client);
if(enable) CreateTimer(RESPAWNT, Resp, client);
return Plugin_Continue;
return Plugin_Continue;
}
}
public OnClientDisconnect(client)
public OnClientDisconnect(client)
{
{
g_fDeathTime[client] = 0.0;
g_fDeathTime[client] = 0.0;
}
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
{
enable = true;
enable = true;
PrintToChatAll(" \x08[\x07iRespawner\x08] \x0EAutoRespawn is now \x04Enabled\x07");
}
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
{
if (!enable)
if (!enable)
return;
return;
decl String:weapon[32];
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon));
GetEventString(event, "weapon", weapon, sizeof(weapon));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if (victim && !attacker && StrEqual(weapon, "trigger_hurt"))
if (victim && !attacker && StrEqual(weapon, "trigger_hurt"))
{
{
new Float:fGameTime = GetGameTime();
new Float:fGameTime = GetGameTime();
if (fGameTime - g_fDeathTime[victim] - RESPAWNT < 2.0)
if (fGameTime - g_fDeathTime[victim] - RESPAWNT < 2.0)
{
{
PrintToChatAll(" \x04Repeat killer detected. Disabling autorespawn for this round.");
PrintToChatAll(" \x08[\x07iRespawner\x08] \x0EAutoRespawn is now \x02Disabled\x07");
enable = false;
enable = false;
}
}
g_fDeathTime[victim] = fGameTime;
g_fDeathTime[victim] = fGameTime;
}
}
}
}