2018-07-23 10:59:45 +02:00
|
|
|
#include <sourcemod>
|
|
|
|
#include <cstrike>
|
|
|
|
#include <zombiereloaded>
|
|
|
|
|
2018-09-07 22:13:24 +02:00
|
|
|
bool G_bIsHuman[MAXPLAYERS+1];
|
|
|
|
bool G_bIsZombie[MAXPLAYERS+1];
|
2018-07-23 17:06:03 +02:00
|
|
|
|
2018-09-07 22:13:24 +02:00
|
|
|
ConVar G_hCvar_Difficulty_Humans;
|
|
|
|
ConVar G_hCvar_Difficulty_Zombies;
|
|
|
|
ConVar G_hCvar_Difficulty_Humans_BlockTime;
|
2018-09-07 18:38:22 +02:00
|
|
|
|
2018-09-07 22:13:24 +02:00
|
|
|
Handle g_hHumanPointsTimer;
|
2018-07-23 10:59:45 +02:00
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-07-23 10:59:45 +02:00
|
|
|
public Plugin:myinfo =
|
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
name = "HLstatsX CE Difficulty",
|
|
|
|
author = "zaCade + Neon",
|
2018-07-23 10:59:45 +02:00
|
|
|
description = "Grant points to the winning team. (zombies/humans)",
|
2018-09-07 18:38:22 +02:00
|
|
|
version = "1.2",
|
2018-07-23 17:06:03 +02:00
|
|
|
url = ""
|
2018-07-23 10:59:45 +02:00
|
|
|
};
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-07-23 10:59:45 +02:00
|
|
|
public OnPluginStart()
|
|
|
|
{
|
|
|
|
G_hCvar_Difficulty_Humans = CreateConVar("hlx_difficulty_humans", "0", "", 0, true, 0.0, true, 3.0);
|
|
|
|
G_hCvar_Difficulty_Zombies = CreateConVar("hlx_difficulty_zombies", "0", "", 0, true, 0.0, true, 3.0);
|
2018-09-07 18:38:22 +02:00
|
|
|
G_hCvar_Difficulty_Humans_BlockTime = CreateConVar("hlx_difficulty_humans_blocktime", "60", "", 0, true, 0.0, true, 180.0);
|
2018-07-23 17:06:03 +02:00
|
|
|
|
|
|
|
HookEvent("round_start", Event_RoundStart);
|
|
|
|
HookEvent("round_end", Event_RoundEnd);
|
|
|
|
|
2018-07-23 10:59:45 +02:00
|
|
|
AutoExecConfig(true, "plugin.hlstatsx_difficulty");
|
|
|
|
}
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-07-23 10:59:45 +02:00
|
|
|
public ZR_OnClientInfected(client, attacker, bool:motherinfect, bool:respawnoverride, bool:respawn)
|
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
G_bIsHuman[client] = false;
|
|
|
|
G_bIsZombie[client] = true;
|
2018-07-23 10:59:45 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public ZR_OnClientHumanPost(client, bool:respawn, bool:protect)
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
G_bIsHuman[client] = true;
|
|
|
|
G_bIsZombie[client] = false;
|
2018-07-23 10:59:45 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
2018-10-08 17:03:40 +02:00
|
|
|
if (g_hHumanPointsTimer != INVALID_HANDLE && CloseHandle(g_hHumanPointsTimer))
|
2018-09-07 22:13:24 +02:00
|
|
|
g_hHumanPointsTimer = INVALID_HANDLE;
|
|
|
|
|
|
|
|
g_hHumanPointsTimer = CreateTimer(G_hCvar_Difficulty_Humans_BlockTime.FloatValue, OnHumanPointsTimer);
|
2018-09-07 18:38:22 +02:00
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
for (new client = 1; client <= MaxClients; client++)
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
G_bIsHuman[client] = true;
|
|
|
|
G_bIsZombie[client] = false;
|
2018-07-23 10:59:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
switch(GetEventInt(event, "winner"))
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
case(CS_TEAM_CT): CreateTimer(0.2, OnHumansWin, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
|
|
|
case(CS_TEAM_T): CreateTimer(0.2, OnZombiesWin, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
2018-07-23 10:59:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-07 18:38:22 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-09-07 22:13:24 +02:00
|
|
|
public Action OnHumanPointsTimer(Handle timer)
|
2018-09-07 18:38:22 +02:00
|
|
|
{
|
2018-09-07 22:13:24 +02:00
|
|
|
g_hHumanPointsTimer = INVALID_HANDLE;
|
2018-09-07 18:38:22 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-07-23 10:59:45 +02:00
|
|
|
public Action:OnHumansWin(Handle:timer)
|
|
|
|
{
|
2018-09-07 22:13:24 +02:00
|
|
|
if (g_hHumanPointsTimer != INVALID_HANDLE)
|
2018-09-07 18:38:22 +02:00
|
|
|
{
|
|
|
|
PrintToChatAll("[SM] Round ended too fast. Humans will not be rewarded for the Win.");
|
|
|
|
return;
|
|
|
|
}
|
2018-09-07 22:13:24 +02:00
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
for (new client = 1; client <= MaxClients; client++)
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(client) && IsPlayerAlive(client) && !IsClientObserver(client) && !IsFakeClient(client))
|
|
|
|
{
|
|
|
|
if (G_bIsHuman[client] && !G_bIsZombie[client])
|
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
new String:sAuthid[64];
|
|
|
|
if (!GetClientAuthString(client, sAuthid, sizeof(sAuthid)))
|
|
|
|
Format(sAuthid, sizeof(sAuthid), "UNKNOWN");
|
|
|
|
|
2018-09-07 22:13:24 +02:00
|
|
|
LogToGame("\"%N<%d><%s><%s>\" triggered \"human_win_%i\"", client, GetClientUserId(client), sAuthid, "CT", G_hCvar_Difficulty_Humans.IntValue);
|
2018-07-23 10:59:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-23 17:06:03 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-07-23 10:59:45 +02:00
|
|
|
public Action:OnZombiesWin(Handle:timer)
|
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
for (new client = 1; client <= MaxClients; client++)
|
2018-07-23 10:59:45 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(client) && IsPlayerAlive(client) && !IsClientObserver(client) && !IsFakeClient(client))
|
|
|
|
{
|
|
|
|
if (G_bIsZombie[client] && !G_bIsHuman[client])
|
|
|
|
{
|
2018-07-23 17:06:03 +02:00
|
|
|
new String:sAuthid[64];
|
|
|
|
if (!GetClientAuthString(client, sAuthid, sizeof(sAuthid)))
|
|
|
|
Format(sAuthid, sizeof(sAuthid), "UNKNOWN");
|
|
|
|
|
2018-09-07 22:13:24 +02:00
|
|
|
LogToGame("\"%N<%d><%s><%s>\" triggered \"zombie_win_%i\"", client, GetClientUserId(client), sAuthid, "TERRORIST", G_hCvar_Difficulty_Zombies.IntValue);
|
2018-07-23 10:59:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-23 17:06:03 +02:00
|
|
|
}
|