#include #include #include #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)); }