Hlstats: Update server modules.
Add a ZE module, and change the ZR one slightly to be more similiar.
This commit is contained in:
parent
9034d4284a
commit
9f3e89514d
226
hlstatsx/scripting/hlstatsx_ze.sp
Normal file
226
hlstatsx/scripting/hlstatsx_ze.sp
Normal file
@ -0,0 +1,226 @@
|
||||
#include <cstrike>
|
||||
#include <loghelper>
|
||||
#include <sourcemod>
|
||||
#include <zombiereloaded>
|
||||
|
||||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
/* CONVARS */
|
||||
ConVar g_cvarStreakInterval = null;
|
||||
ConVar g_cvarMinimumStreak = null;
|
||||
ConVar g_cvarMaximumStreak = null;
|
||||
|
||||
ConVar g_cvarDifficultyHuman = null;
|
||||
ConVar g_cvarDifficultyZombie = null;
|
||||
ConVar g_cvarDifficultyDuration = null;
|
||||
|
||||
/* HANDLES */
|
||||
Handle g_tMinimalRoundDuration = INVALID_HANDLE;
|
||||
|
||||
/* INTERGERS */
|
||||
int g_iKillCount[MAXPLAYERS+1] = 0;
|
||||
|
||||
/* BOOLEANS */
|
||||
bool g_bMotherZM[MAXPLAYERS+1] = false;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "HLstatsX CE - Zombie Escape",
|
||||
author = "zaCade",
|
||||
description = "Create additional actions for the default HLstatsX",
|
||||
version = "1.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_cvarStreakInterval = CreateConVar("hlx_ze_killstreaks_interval", "1", "amount of kills required to progress to the next killstreak", 0, true, 1.0);
|
||||
g_cvarMinimumStreak = CreateConVar("hlx_ze_killstreaks_minimal", "2", "amount of kills required for the lowest killstreak", 0, true, 0.0);
|
||||
g_cvarMaximumStreak = CreateConVar("hlx_ze_killstreaks_maximal", "12", "amount of kills required for the highest killstreak", 0, true, 0.0);
|
||||
|
||||
g_cvarDifficultyHuman = CreateConVar("hlx_ze_difficulty_human", "0", "the difficulty level of the current map for humans", 0, true, 0.0);
|
||||
g_cvarDifficultyZombie = CreateConVar("hlx_ze_difficulty_zombie", "0", "the difficulty level of the current map for zombies", 0, true, 0.0);
|
||||
g_cvarDifficultyDuration = CreateConVar("hlx_ze_difficulty_duration", "60", "the minumum amount of time a round has to last in seconds", 0, true, 0.0, true, 180.0);
|
||||
|
||||
HookEvent("round_start", OnRoundStarting, EventHookMode_Pre);
|
||||
HookEvent("round_end", OnRoundEnding, EventHookMode_Pre);
|
||||
HookEvent("player_spawn", OnClientSpawn, EventHookMode_Pre);
|
||||
HookEvent("player_death", OnClientDeath, EventHookMode_Pre);
|
||||
|
||||
AutoExecConfig();
|
||||
GetTeams();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnMapStart()
|
||||
{
|
||||
GetTeams();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnMapEnd()
|
||||
{
|
||||
if (g_tMinimalRoundDuration != INVALID_HANDLE && CloseHandle(g_tMinimalRoundDuration))
|
||||
g_tMinimalRoundDuration = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundStarting(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
if (g_tMinimalRoundDuration != INVALID_HANDLE && CloseHandle(g_tMinimalRoundDuration))
|
||||
g_tMinimalRoundDuration = INVALID_HANDLE;
|
||||
|
||||
g_tMinimalRoundDuration = CreateTimer(g_cvarDifficultyDuration.FloatValue, OnRoundMinimalDuration);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnRoundMinimalDuration(Handle timer)
|
||||
{
|
||||
g_tMinimalRoundDuration = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||
{
|
||||
g_bMotherZM[client] = motherInfect;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
bool bAwardHumans = ((g_tMinimalRoundDuration == INVALID_HANDLE) && (hEvent.GetInt("winner") == CS_TEAM_CT));
|
||||
bool bAwardZombies = ((g_tMinimalRoundDuration == INVALID_HANDLE) && (hEvent.GetInt("winner") == CS_TEAM_T));
|
||||
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client))
|
||||
{
|
||||
if (bAwardHumans && ZR_IsClientHuman(client))
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_win_%d", g_cvarDifficultyHuman.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
else if (bAwardZombies && ZR_IsClientZombie(client))
|
||||
{
|
||||
if (g_bMotherZM[client])
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_m_win_%d", g_cvarDifficultyZombie.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_z_win_%d", g_cvarDifficultyZombie.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
EndKillStreak(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
ResetClient(client);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
int killer = GetClientOfUserId(hEvent.GetInt("attacker"));
|
||||
|
||||
EndKillStreak(client);
|
||||
|
||||
if (IsValidClient(killer))
|
||||
{
|
||||
g_iKillCount[killer] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EndKillStreak(int client)
|
||||
{
|
||||
if (g_iKillCount[client] >= g_cvarMinimumStreak.IntValue)
|
||||
{
|
||||
if (g_iKillCount[client] > g_cvarMaximumStreak.IntValue)
|
||||
g_iKillCount[client] = g_cvarMaximumStreak.IntValue;
|
||||
|
||||
if (ZR_IsClientHuman(client))
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_kill_streak_%d", RoundToFloor(float(g_iKillCount[client]) / float(g_cvarStreakInterval.IntValue)) * g_cvarStreakInterval.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
else if (ZR_IsClientZombie(client))
|
||||
{
|
||||
if (g_bMotherZM[client])
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_m_kill_streak_%d", RoundToFloor(float(g_iKillCount[client]) / float(g_cvarStreakInterval.IntValue)) * g_cvarStreakInterval.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_z_kill_streak_%d", RoundToFloor(float(g_iKillCount[client]) / float(g_cvarStreakInterval.IntValue)) * g_cvarStreakInterval.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ResetClient(client);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock void ResetClient(int client)
|
||||
{
|
||||
g_iKillCount[client] = 0;
|
||||
g_bMotherZM[client] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock bool IsValidClient(int client)
|
||||
{
|
||||
return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));
|
||||
}
|
@ -107,10 +107,10 @@ public void EndKillStreak(int client)
|
||||
if (g_iKillCount[client] > g_cvarMaximumStreak.IntValue)
|
||||
g_iKillCount[client] = g_cvarMaximumStreak.IntValue;
|
||||
|
||||
char sEvent[32];
|
||||
Format(sEvent, sizeof(sEvent), "zr_kill_streak_%d", RoundToFloor(float(g_iKillCount[client]) / float(g_cvarStreakInterval.IntValue)) * g_cvarStreakInterval.IntValue);
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "zr_kill_streak_%d", RoundToFloor(float(g_iKillCount[client]) / float(g_cvarStreakInterval.IntValue)) * g_cvarStreakInterval.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sEvent);
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
|
||||
ResetClient(client);
|
||||
|
Loading…
Reference in New Issue
Block a user