Merge remote-tracking branch 'old/master'

This commit is contained in:
BotoX
2019-07-24 20:57:00 +02:00
191 changed files with 29564 additions and 465 deletions
+175
View File
@@ -0,0 +1,175 @@
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#undef REQUIRE_PLUGIN
#tryinclude <HappyHour>
#define REQUIRE_PLUGIN
#pragma newdecls required
bool g_bHHLoaded;
char g_sTeamList[16][64];
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "HLstatsX CE - LogHelper",
author = "Neon",
description = "Custom HLstatsX Logging",
version = "1.0.0"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int errorSize)
{
CreateNative("LH_LogPlayerEvent", Native_LogPlayerEvent);
RegPluginLibrary("HlstatsXLogHelper");
return APLRes_Success;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnAllPluginsLoaded()
{
g_bHHLoaded = LibraryExists("HappyHour");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnLibraryAdded(const char[] sName)
{
if (strcmp(sName, "HappyHour", false) == 0)
g_bHHLoaded = true;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnLibraryRemoved(const char[] sName)
{
if (strcmp(sName, "HappyHour", false) == 0)
g_bHHLoaded = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
GetTeams();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_LogPlayerEvent(Handle hPlugin, int numParams)
{
int iClient;
char sVerb[64];
char sEvent[256];
bool bHH;
iClient = GetNativeCell(1);
GetNativeString(2, sVerb, sizeof(sVerb));
GetNativeString(3, sEvent, sizeof(sEvent));
bHH = GetNativeCell(4);
if (iClient < 1 || iClient > MaxClients)
{
return ThrowNativeError(SP_ERROR_NATIVE, "Client index %d is invalid", iClient);
}
else if (!IsClientInGame(iClient))
{
return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not ingame", iClient);
}
LogPlayerEventCustom(iClient, sVerb, sEvent, bHH);
return true;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void LogPlayerEventCustom(int client, const char[] verb, const char[] event, bool hh)
{
if (!IsValidPlayer(client))
return;
char player_authid[32];
if (!GetClientAuthId(client, AuthId_Engine, player_authid, sizeof(player_authid), false))
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
char sEvent[256];
Format(sEvent, sizeof(sEvent), "%s", event);
if (g_bHHLoaded && HH_IsItHappyHour() && hh)
Format(sEvent, sizeof(sEvent), "%s_hh", sEvent);
char sLog[512];
Format(sLog, sizeof(sLog), "\"%N<%d><%s><%s>\" %s \"%s\"", client, GetClientUserId(client), player_authid, g_sTeamList[GetClientTeam(client)], verb, sEvent);
LogToGame(sLog);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void GetTeams(bool insmod = false)
{
if (!insmod)
{
int max_teams_count = GetTeamCount();
for (int team_index = 0; (team_index < max_teams_count); team_index++)
{
char team_name[64];
GetTeamName(team_index, team_name, sizeof(team_name));
if (strcmp(team_name, "") != 0)
{
g_sTeamList[team_index] = team_name;
}
}
}
else
{
// they really need to get their act together... GetTeamName() would be awesome since they can't even keep their team indexes consistent
char mapname[64];
GetCurrentMap(mapname, sizeof(mapname));
if (strcmp(mapname, "ins_karam") == 0 || strcmp(mapname, "ins_baghdad") == 0)
{
g_sTeamList[1] = "Iraqi Insurgents";
g_sTeamList[2] = "U.S. Marines";
}
else
{
g_sTeamList[1] = "U.S. Marines";
g_sTeamList[2] = "Iraqi Insurgents";
}
g_sTeamList[0] = "Unassigned";
g_sTeamList[3] = "SPECTATOR";
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
static stock bool IsValidPlayer(int client)
{
if (client > 0 && client <= MaxClients && IsClientInGame(client))
{
return true;
}
return false;
}
+269
View File
@@ -0,0 +1,269 @@
#include <cstrike>
#include <hlstatsx_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_bIsHuman[MAXPLAYERS+1] = false;
bool g_bIsZombie[MAXPLAYERS+1] = false;
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);
for (int client = 1; client <= MaxClients; client++)
{
if (IsValidClient(client))
{
g_bIsHuman[client] = ZR_IsClientHuman(client);
g_bIsZombie[client] = ZR_IsClientZombie(client);
}
}
AutoExecConfig();
}
//----------------------------------------------------------------------------------------------------
// 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_OnClientHumanPost(int client, bool respawn, bool protect)
{
g_bIsHuman[client] = true;
g_bIsZombie[client] = false;
g_bMotherZM[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
{
g_bIsHuman[client] = false;
g_bIsZombie[client] = true;
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));
int iAliveHumans;
int iAliveZombies;
for (int client = 1; client <= MaxClients; client++)
{
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT)
{
iAliveHumans++;
}
else if(IsValidClient(client) && GetClientTeam(client) == CS_TEAM_T)
{
iAliveZombies++;
}
}
for (int client = 1; client <= MaxClients; client++)
{
if (IsValidClient(client))
{
if (bAwardHumans && g_bIsHuman[client])
{
if (iAliveHumans == 1)
{
LH_LogPlayerEvent(client, "triggered", "ze_h_win_solo", true);
}
else
{
char sPlayerEvent[32];
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_win_%d", g_cvarDifficultyHuman.IntValue);
LH_LogPlayerEvent(client, "triggered", sPlayerEvent, true);
}
}
else if (bAwardZombies && g_bIsZombie[client])
{
if (iAliveZombies == 1)
{
LH_LogPlayerEvent(client, "triggered", "ze_z_win_solo", true);
}
else if (g_bMotherZM[client])
{
char sPlayerEvent[32];
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_m_win_%d", g_cvarDifficultyZombie.IntValue);
LH_LogPlayerEvent(client, "triggered", sPlayerEvent, true);
}
else
{
char sPlayerEvent[32];
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_z_win_%d", g_cvarDifficultyZombie.IntValue);
LH_LogPlayerEvent(client, "triggered", sPlayerEvent, true);
}
}
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 (g_bIsHuman[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);
LH_LogPlayerEvent(client, "triggered", sPlayerEvent, true);
}
else if (g_bIsZombie[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);
LH_LogPlayerEvent(client, "triggered", sPlayerEvent, true);
}
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);
LH_LogPlayerEvent(client, "triggered", sPlayerEvent, true);
}
}
}
ResetClient(client);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void ResetClient(int client)
{
g_bIsHuman[client] = true;
g_bIsZombie[client] = false;
g_bMotherZM[client] = false;
g_iKillCount[client] = 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool IsValidClient(int client)
{
return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));
}
+133
View File
@@ -0,0 +1,133 @@
#include <loghelper>
#include <sourcemod>
#include <zriot>
#pragma semicolon 1
#pragma newdecls required
/* CONVARS */
ConVar g_cvarStreakInterval = null;
ConVar g_cvarMinimumStreak = null;
ConVar g_cvarMaximumStreak = null;
/* INTERGERS */
int g_iKillCount[MAXPLAYERS+1] = 0;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "HLstatsX CE - Zombie Riot",
author = "zaCade",
description = "Create additional actions for the default HLstatsX",
version = "1.0.0"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
g_cvarStreakInterval = CreateConVar("hlx_zr_killstreaks_interval", "10", "amount of kills required to progress to the next killstreak", 0, true, 1.0);
g_cvarMinimumStreak = CreateConVar("hlx_zr_killstreaks_minimal", "10", "amount of kills required for the lowest killstreak", 0, true, 0.0);
g_cvarMaximumStreak = CreateConVar("hlx_zr_killstreaks_maximal", "200", "amount of kills required for the highest killstreak", 0, true, 0.0);
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 OnRoundEnding(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
for (int client = 1; client <= MaxClients; client++)
{
if (IsValidClient(client))
{
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 OnClientDisconnect(int client)
{
ResetClient(client);
}
//----------------------------------------------------------------------------------------------------
// 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;
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", sPlayerEvent);
}
ResetClient(client);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void ResetClient(int client)
{
g_iKillCount[client] = 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool IsValidClient(int client)
{
return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));
}
@@ -0,0 +1,38 @@
#if defined _HlstatsXLogHelper_included
#endinput
#endif
#define _HlstatsXLogHelper_included
/**
* Logs a custom player event to the game.
*
* @param client The client index.
* @param verb The verb to log.
* @param event The event to log.
* @param happyhour If event should be altered during happy hour.
*
* @return True on success, false otherwise.
* @error Invalid client index or not ingame.
*/
native bool LH_LogPlayerEvent(int client, char[] verb, char[] event, bool happyhour = false);
public SharedPlugin __pl_HlstatsXLogHelper =
{
name = "HlstatsXLogHelper",
file = "hlstatsx_loghelper.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_HlstatsXLogHelper_SetNTVOptional()
{
MarkNativeAsOptional("LH_LogPlayerEvent");
}
#endif