#pragma semicolon 1
#include
#pragma newdecls required
#define g_maps StrEqual(maps, "c1m1_hotel", false) || StrEqual(maps, "c2m1_highway", false) || StrEqual(maps, "c3m1_plankcountry", false) || StrEqual(maps, "c4m1_milltown_a", false) || StrEqual(maps, "c5m1_waterfront", false) || StrEqual(maps, "c6m1_riverbank", false) || StrEqual(maps, "c7m1_docks", false) || StrEqual(maps, "c8m1_apartment", false) || StrEqual(maps, "c9m1_alleys", false) || StrEqual(maps, "c10m1_caves", false) || StrEqual(maps, "c11m1_greenhouse", false) || StrEqual(maps, "c12m1_hilltop", false) || StrEqual(maps, "c13m1_alpinecreek", false)
bool g_stop_event, g_stop_event2;
char maps[64];
Handle g_iEnable = null, g_iInterval = null, g_qInterval = null, g_iInterval2 = null, g_qInterval2 = null, g_iEnable_MissionLost = null;
Handle g_Timer = null, g_Timer2 = null;
public void OnPluginStart()
{
g_iEnable = CreateConVar("sm_enable_unlocked_tank","1", "0:Выкл. 1:Вкл.", FCVAR_NOTIFY);
g_iEnable_MissionLost = CreateConVar("sm_enable_mission_lost","1", "Вызвать танка если команда проиграла? 0:Выкл. 1:Вкл.", FCVAR_NOTIFY);
g_iInterval = CreateConVar("sm_interval_1","100.0", "Первое рандомное время.", FCVAR_NOTIFY);
g_qInterval = CreateConVar("sm_interval_2","200.0", "Второе рандомное время.", FCVAR_NOTIFY);
g_iInterval2 = CreateConVar("sm_interval2_1","70.0", "Первое рандомное время.", FCVAR_NOTIFY);
g_qInterval2 = CreateConVar("sm_interval2_2","140.0", "Второе рандомное время.", FCVAR_NOTIFY);
HookEvent("player_left_checkpoint", EventPlayerHook);
HookEvent("round_start", ResetBool);
HookEvent("round_end", ResetBool);
}
public void EventPlayerHook(Event event, const char[] name, bool dontBroadcast)
{
if(!GetConVarInt(g_iEnable) || (g_stop_event) || (g_stop_event2))return;
{
GetCurrentMap(maps, sizeof(maps));
if(g_maps)
{
if (g_Timer != null)
{
delete(g_Timer);
g_Timer = null;
}
g_Timer = CreateTimer(GetRandomInt(0, 1) ? GetConVarFloat(g_iInterval) : GetConVarFloat(g_qInterval), SpawnTank, _, TIMER_FLAG_NO_MAPCHANGE);
g_stop_event = true;
}
GetCurrentMap(maps, sizeof(maps));
if(g_maps)
{
if (g_Timer2 != null)
{
delete(g_Timer2);
g_Timer2 = null;
}
g_Timer2 = CreateTimer(GetRandomInt(0, 1) ? GetConVarFloat(g_iInterval2) : GetConVarFloat(g_qInterval2), SpawnWitch, _, TIMER_FLAG_NO_MAPCHANGE);
g_stop_event2 = true;
}
}
}
public void OnMapStart()
{
g_stop_event = true;
g_stop_event2 = true;
g_Timer = null;
g_Timer2 = null;
if (!IsModelPrecached("models/infected/hulk_dlc3.mdl")) PrecacheModel("models/infected/hulk_dlc3.mdl", true);
char map[64];
GetCurrentMap(map, sizeof(map));
}
public void OnMapEnd()
{
g_Timer = null;
g_Timer2 = null;
}
public void ResetBool(Event event, const char[] name, bool dontBroadcast)
{
if(!GetConVarInt(g_iEnable_MissionLost)) return;
{
g_stop_event = false;
g_stop_event2 = false;
}
}
public Action SpawnTank(Handle timer)
{
for (int i = 1; i <= MaxClients; ++i) if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
{
int flags = GetCommandFlags("z_spawn");
SetCommandFlags("z_spawn", flags & ~FCVAR_CHEAT);
FakeClientCommand(i, "z_spawn tank auto");
SetCommandFlags("z_spawn", flags);
break;
}
g_Timer = null;
return Plugin_Stop;
}
public Action SpawnWitch(Handle timer)
{
for (int i = 1; i <= MaxClients; ++i) if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
{
int flags = GetCommandFlags("z_spawn");
SetCommandFlags("z_spawn", flags & ~FCVAR_CHEAT);
FakeClientCommand(i, "z_spawn witch auto");
SetCommandFlags("z_spawn", flags);
break;
}
g_Timer2 = null;
return Plugin_Stop;
}