HLStats: move it to shared.
This commit is contained in:
parent
c5a272f496
commit
413a062eaa
2222
hlstatsx/scripting/hlstatsx.sp
Normal file
2222
hlstatsx/scripting/hlstatsx.sp
Normal file
File diff suppressed because it is too large
Load Diff
251
hlstatsx/scripting/hlstatsx_ze.sp
Normal file
251
hlstatsx/scripting/hlstatsx_ze.sp
Normal file
@ -0,0 +1,251 @@
|
||||
#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_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();
|
||||
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_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));
|
||||
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client))
|
||||
{
|
||||
if (bAwardHumans && g_bIsHuman[client])
|
||||
{
|
||||
char sPlayerEvent[32];
|
||||
Format(sPlayerEvent, sizeof(sPlayerEvent), "ze_h_win_%d", g_cvarDifficultyHuman.IntValue);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
else if (bAwardZombies && g_bIsZombie[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 (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);
|
||||
|
||||
LogPlayerEvent(client, "triggered", sPlayerEvent);
|
||||
}
|
||||
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);
|
||||
|
||||
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_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
hlstatsx/scripting/hlstatsx_zr.sp
Normal file
133
hlstatsx/scripting/hlstatsx_zr.sp
Normal 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));
|
||||
}
|
245
hlstatsx/scripting/include/loghelper.inc
Normal file
245
hlstatsx/scripting/include/loghelper.inc
Normal file
@ -0,0 +1,245 @@
|
||||
#define LOGHELPER_VERSION 5
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
|
||||
char g_team_list[16][64];
|
||||
|
||||
// Call this on map start to cache team names in g_team_list
|
||||
|
||||
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_team_list[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_team_list[1] = "Iraqi Insurgents";
|
||||
g_team_list[2] = "U.S. Marines";
|
||||
}
|
||||
else
|
||||
{
|
||||
g_team_list[1] = "U.S. Marines";
|
||||
g_team_list[2] = "Iraqi Insurgents";
|
||||
}
|
||||
g_team_list[0] = "Unassigned";
|
||||
g_team_list[3] = "SPECTATOR";
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogPlayerEvent(int client, const char[] verb, const char[] event, bool display_location = false, const char[] properties = "")
|
||||
{
|
||||
if (IsValidPlayer(client))
|
||||
{
|
||||
char player_authid[32];
|
||||
if (!GetClientAuthId(client, AuthId_Engine, player_authid, sizeof(player_authid), false))
|
||||
{
|
||||
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
if (display_location)
|
||||
{
|
||||
float player_origin[3];
|
||||
GetClientAbsOrigin(client, player_origin);
|
||||
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\"%s (position \"%d %d %d\")", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], verb, event, properties, RoundFloat(player_origin[0]), RoundFloat(player_origin[1]), RoundFloat(player_origin[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\"%s", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], verb, event, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogPlyrPlyrEvent(int client, int victim, const char[] verb, const char[] event, bool display_location = false, const char[] properties = "")
|
||||
{
|
||||
if (IsValidPlayer(client) && IsValidPlayer(victim))
|
||||
{
|
||||
char player_authid[32];
|
||||
if (!GetClientAuthId(client, AuthId_Engine, player_authid, sizeof(player_authid), false))
|
||||
{
|
||||
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
|
||||
}
|
||||
char victim_authid[32];
|
||||
if (!GetClientAuthId(victim, AuthId_Engine, victim_authid, sizeof(victim_authid), false))
|
||||
{
|
||||
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
if (display_location)
|
||||
{
|
||||
float player_origin[3];
|
||||
GetClientAbsOrigin(client, player_origin);
|
||||
|
||||
float victim_origin[3];
|
||||
GetClientAbsOrigin(victim, victim_origin);
|
||||
|
||||
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\" against \"%N<%d><%s><%s>\"%s (position \"%d %d %d\") (victim_position \"%d %d %d\")", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], verb, event, victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], properties, RoundFloat(player_origin[0]), RoundFloat(player_origin[1]), RoundFloat(player_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\" against \"%N<%d><%s><%s>\"%s", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], verb, event, victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogKill(int attacker, int victim, const char[] weapon, bool display_location = false, const char[] properties = "")
|
||||
{
|
||||
if (IsValidPlayer(attacker) && IsValidPlayer(victim))
|
||||
{
|
||||
char attacker_authid[32];
|
||||
if (!GetClientAuthId(attacker, AuthId_Engine, attacker_authid, sizeof(attacker_authid), false))
|
||||
{
|
||||
strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN");
|
||||
}
|
||||
char victim_authid[32];
|
||||
if (!GetClientAuthId(victim, AuthId_Engine, victim_authid, sizeof(victim_authid), false))
|
||||
{
|
||||
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
if (display_location)
|
||||
{
|
||||
float attacker_origin[3];
|
||||
GetClientAbsOrigin(attacker, attacker_origin);
|
||||
float victim_origin[3];
|
||||
GetClientAbsOrigin(victim, victim_origin);
|
||||
|
||||
LogToGame("\"%N<%d><%s><%s>\" killed \"%N<%d><%s><%s>\" with \"%s\"%s (attacker_position \"%d %d %d\") (victim_position \"%d %d %d\")", attacker, GetClientUserId(attacker), attacker_authid, g_team_list[GetClientTeam(attacker)], victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, properties, RoundFloat(attacker_origin[0]), RoundFloat(attacker_origin[1]), RoundFloat(attacker_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToGame("\"%N<%d><%s><%s>\" killed \"%N<%d><%s><%s>\" with \"%s\"%s", attacker, GetClientUserId(attacker), attacker_authid, g_team_list[GetClientTeam(attacker)], victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogSuicide(int victim, const char[] weapon, bool display_location = false, const char[] properties = "")
|
||||
{
|
||||
if (IsValidPlayer(victim))
|
||||
{
|
||||
char victim_authid[32];
|
||||
if (!GetClientAuthId(victim, AuthId_Engine, victim_authid, sizeof(victim_authid), false))
|
||||
{
|
||||
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
if (display_location)
|
||||
{
|
||||
float victim_origin[3];
|
||||
GetClientAbsOrigin(victim, victim_origin);
|
||||
|
||||
LogToGame("\"%N<%d><%s><%s>\" committed suicide with \"%s\"%s (victim_position \"%d %d %d\")", victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, properties, RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToGame("\"%N<%d><%s><%s>\" committed suicide with \"%s\"%s", victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For Psychostats "KTRAJ" kill trajectory log lines
|
||||
stock void LogPSKillTraj(int attacker, int victim, const char[] weapon)
|
||||
{
|
||||
if (IsValidPlayer(attacker) && IsValidPlayer(victim))
|
||||
{
|
||||
char attacker_authid[32];
|
||||
if (!GetClientAuthId(attacker, AuthId_Engine, attacker_authid, sizeof(attacker_authid), false))
|
||||
{
|
||||
strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN");
|
||||
}
|
||||
char victim_authid[32];
|
||||
if (!GetClientAuthId(victim, AuthId_Engine, victim_authid, sizeof(victim_authid), false))
|
||||
{
|
||||
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
float attacker_origin[3];
|
||||
GetClientAbsOrigin(attacker, attacker_origin);
|
||||
float victim_origin[3];
|
||||
GetClientAbsOrigin(victim, victim_origin);
|
||||
|
||||
LogToGame("[KTRAJ] \"%N<%d><%s><%s>\" killed \"%N<%d><%s><%s>\" with \"%s\" (attacker_position \"%d %d %d\") (victim_position \"%d %d %d\")", attacker, GetClientUserId(attacker), attacker_authid, g_team_list[GetClientTeam(attacker)], victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, RoundFloat(attacker_origin[0]), RoundFloat(attacker_origin[1]), RoundFloat(attacker_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
|
||||
}
|
||||
}
|
||||
|
||||
// Verb should always be "triggered" for this.
|
||||
stock void LogTeamEvent(int team, const char[] verb, const char[] event, const char[] properties = "")
|
||||
{
|
||||
if (team > -1)
|
||||
{
|
||||
LogToGame("Team \"%s\" %s \"%s\"%s", g_team_list[team], verb, event, properties);
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogKillLoc(int attacker, int victim)
|
||||
{
|
||||
if (attacker > 0 && victim > 0)
|
||||
{
|
||||
float attacker_origin[3];
|
||||
GetClientAbsOrigin(attacker, attacker_origin);
|
||||
float victim_origin[3];
|
||||
GetClientAbsOrigin(victim, victim_origin);
|
||||
|
||||
LogToGame("World triggered \"killlocation\" (attacker_position \"%d %d %d\") (victim_position \"%d %d %d\")", RoundFloat(attacker_origin[0]), RoundFloat(attacker_origin[1]), RoundFloat(attacker_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogTeamChange(int client, int newteam, const char[] properties = "")
|
||||
{
|
||||
if (IsValidPlayer(client))
|
||||
{
|
||||
char player_authid[32];
|
||||
if (!GetClientAuthId(client, AuthId_Engine, player_authid, sizeof(player_authid), false))
|
||||
{
|
||||
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
LogToGame("\"%N<%d><%s><%s>\" joined team \"%s\"%s", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], g_team_list[newteam], properties);
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogRoleChange(int client, const char[] role, const char[] properties = "")
|
||||
{
|
||||
if (IsValidPlayer(client))
|
||||
{
|
||||
char player_authid[32];
|
||||
if (!GetClientAuthId(client, AuthId_Engine, player_authid, sizeof(player_authid), false))
|
||||
{
|
||||
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
|
||||
}
|
||||
|
||||
LogToGame("\"%N<%d><%s><%s>\" changed role to \"%s\"%s", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], role, properties);
|
||||
}
|
||||
}
|
||||
|
||||
stock void LogMapLoad()
|
||||
{
|
||||
char map[64];
|
||||
GetCurrentMap(map, sizeof(map));
|
||||
LogToGame("Loading map \"%s\"", map);
|
||||
}
|
||||
|
||||
static stock bool IsValidPlayer(int client)
|
||||
{
|
||||
if (client > 0 && client <= MaxClients && IsClientInGame(client))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
138
hlstatsx/scripting/include/wstatshelper.inc
Normal file
138
hlstatsx/scripting/include/wstatshelper.inc
Normal file
@ -0,0 +1,138 @@
|
||||
#define HITGROUP_GENERIC 0
|
||||
#define HITGROUP_HEAD 1
|
||||
#define HITGROUP_CHEST 2
|
||||
#define HITGROUP_STOMACH 3
|
||||
#define HITGROUP_LEFTARM 4
|
||||
#define HITGROUP_RIGHTARM 5
|
||||
#define HITGROUP_LEFTLEG 6
|
||||
#define HITGROUP_RIGHTLEG 7
|
||||
|
||||
#define LOG_HIT_OFFSET 7
|
||||
|
||||
#define LOG_HIT_SHOTS 0
|
||||
#define LOG_HIT_HITS 1
|
||||
#define LOG_HIT_KILLS 2
|
||||
#define LOG_HIT_HEADSHOTS 3
|
||||
#define LOG_HIT_TEAMKILLS 4
|
||||
#define LOG_HIT_DAMAGE 5
|
||||
#define LOG_HIT_DEATHS 6
|
||||
#define LOG_HIT_GENERIC 7
|
||||
#define LOG_HIT_HEAD 8
|
||||
#define LOG_HIT_CHEST 9
|
||||
#define LOG_HIT_STOMACH 10
|
||||
#define LOG_HIT_LEFTARM 11
|
||||
#define LOG_HIT_RIGHTARM 12
|
||||
#define LOG_HIT_LEFTLEG 13
|
||||
#define LOG_HIT_RIGHTLEG 14
|
||||
|
||||
new Handle:g_weapon_trie = INVALID_HANDLE;
|
||||
|
||||
CreatePopulateWeaponTrie()
|
||||
{
|
||||
// Create a Trie
|
||||
g_weapon_trie = CreateTrie();
|
||||
|
||||
// Initial populate
|
||||
for (new i = 0; i < MAX_LOG_WEAPONS; i++)
|
||||
{
|
||||
if (g_weapon_list[i][0] == 0)
|
||||
{
|
||||
// some games have a couple blanks as place holders (so array indexes match with weapon ids)
|
||||
decl String:randomKey[6];
|
||||
Format(randomKey, sizeof(randomKey), "%c%c%c%c%c%c", GetURandomInt(), GetURandomInt(), GetURandomInt(), GetURandomInt(), GetURandomInt(), GetURandomInt());
|
||||
SetTrieValue(g_weapon_trie, randomKey, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
SetTrieValue(g_weapon_trie, g_weapon_list[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
dump_player_stats(client)
|
||||
{
|
||||
if (IsClientInGame(client) && IsClientConnected(client))
|
||||
{
|
||||
decl String: player_authid[64];
|
||||
if (!GetClientAuthString(client, player_authid, sizeof(player_authid)))
|
||||
{
|
||||
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
|
||||
}
|
||||
new player_team_index = GetClientTeam(client);
|
||||
|
||||
new player_userid = GetClientUserId(client);
|
||||
|
||||
new is_logged;
|
||||
for (new i = 0; (i < MAX_LOG_WEAPONS); i++)
|
||||
{
|
||||
#if defined INS
|
||||
if (g_weapon_stats[client][i][LOG_HIT_HITS] > 0)
|
||||
{
|
||||
LogToGame("\"%N<%d><%s><%s>\" triggered \"weaponstats\" (weapon \"weapon_%s\") (shots \"%d\") (hits \"%d\") (kills \"%d\") (headshots \"%d\") (tks \"%d\") (damage \"%d\") (deaths \"%d\")", client, player_userid, player_authid, g_team_list[player_team_index], g_weapon_list[i], g_weapon_stats[client][i][LOG_HIT_SHOTS], g_weapon_stats[client][i][LOG_HIT_HITS], g_weapon_stats[client][i][LOG_HIT_KILLS], g_weapon_stats[client][i][LOG_HIT_HEADSHOTS], g_weapon_stats[client][i][LOG_HIT_TEAMKILLS], g_weapon_stats[client][i][LOG_HIT_DAMAGE], g_weapon_stats[client][i][LOG_HIT_DEATHS]);
|
||||
LogToGame("\"%N<%d><%s><%s>\" triggered \"weaponstats2\" (weapon \"weapon_%s\") (head \"%d\") (chest \"%d\") (stomach \"%d\") (leftarm \"%d\") (rightarm \"%d\") (leftleg \"%d\") (rightleg \"%d\")", client, player_userid, player_authid, g_team_list[player_team_index], g_weapon_list[i], g_weapon_stats[client][i][LOG_HIT_HEAD], g_weapon_stats[client][i][LOG_HIT_CHEST], g_weapon_stats[client][i][LOG_HIT_STOMACH], g_weapon_stats[client][i][LOG_HIT_LEFTARM], g_weapon_stats[client][i][LOG_HIT_RIGHTARM], g_weapon_stats[client][i][LOG_HIT_LEFTLEG], g_weapon_stats[client][i][LOG_HIT_RIGHTLEG]);
|
||||
#else
|
||||
if (g_weapon_stats[client][i][LOG_HIT_SHOTS] > 0)
|
||||
{
|
||||
#if defined GES
|
||||
LogToGame("\"%N<%d><%s><%s>\" triggered \"weaponstats\" (weapon \"weapon_%s\") (shots \"%d\") (hits \"%d\") (kills \"%d\") (headshots \"%d\") (tks \"%d\") (damage \"%d\") (deaths \"%d\")", client, player_userid, player_authid, g_team_list[player_team_index], g_weapon_loglist[i], g_weapon_stats[client][i][LOG_HIT_SHOTS], g_weapon_stats[client][i][LOG_HIT_HITS], g_weapon_stats[client][i][LOG_HIT_KILLS], g_weapon_stats[client][i][LOG_HIT_HEADSHOTS], g_weapon_stats[client][i][LOG_HIT_TEAMKILLS], g_weapon_stats[client][i][LOG_HIT_DAMAGE], g_weapon_stats[client][i][LOG_HIT_DEATHS]);
|
||||
LogToGame("\"%N<%d><%s><%s>\" triggered \"weaponstats2\" (weapon \"weapon_%s\") (head \"%d\") (chest \"%d\") (stomach \"%d\") (leftarm \"%d\") (rightarm \"%d\") (leftleg \"%d\") (rightleg \"%d\")", client, player_userid, player_authid, g_team_list[player_team_index], g_weapon_loglist[i], g_weapon_stats[client][i][LOG_HIT_HEAD], g_weapon_stats[client][i][LOG_HIT_CHEST], g_weapon_stats[client][i][LOG_HIT_STOMACH], g_weapon_stats[client][i][LOG_HIT_LEFTARM], g_weapon_stats[client][i][LOG_HIT_RIGHTARM], g_weapon_stats[client][i][LOG_HIT_LEFTLEG], g_weapon_stats[client][i][LOG_HIT_RIGHTLEG]);
|
||||
#else
|
||||
LogToGame("\"%N<%d><%s><%s>\" triggered \"weaponstats\" (weapon \"%s\") (shots \"%d\") (hits \"%d\") (kills \"%d\") (headshots \"%d\") (tks \"%d\") (damage \"%d\") (deaths \"%d\")", client, player_userid, player_authid, g_team_list[player_team_index], g_weapon_list[i], g_weapon_stats[client][i][LOG_HIT_SHOTS], g_weapon_stats[client][i][LOG_HIT_HITS], g_weapon_stats[client][i][LOG_HIT_KILLS], g_weapon_stats[client][i][LOG_HIT_HEADSHOTS], g_weapon_stats[client][i][LOG_HIT_TEAMKILLS], g_weapon_stats[client][i][LOG_HIT_DAMAGE], g_weapon_stats[client][i][LOG_HIT_DEATHS]);
|
||||
LogToGame("\"%N<%d><%s><%s>\" triggered \"weaponstats2\" (weapon \"%s\") (head \"%d\") (chest \"%d\") (stomach \"%d\") (leftarm \"%d\") (rightarm \"%d\") (leftleg \"%d\") (rightleg \"%d\")", client, player_userid, player_authid, g_team_list[player_team_index], g_weapon_list[i], g_weapon_stats[client][i][LOG_HIT_HEAD], g_weapon_stats[client][i][LOG_HIT_CHEST], g_weapon_stats[client][i][LOG_HIT_STOMACH], g_weapon_stats[client][i][LOG_HIT_LEFTARM], g_weapon_stats[client][i][LOG_HIT_RIGHTARM], g_weapon_stats[client][i][LOG_HIT_LEFTLEG], g_weapon_stats[client][i][LOG_HIT_RIGHTLEG]);
|
||||
#endif
|
||||
#endif
|
||||
is_logged++;
|
||||
}
|
||||
}
|
||||
if (is_logged > 0)
|
||||
{
|
||||
reset_player_stats(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset_player_stats(client)
|
||||
{
|
||||
for (new i = 0; (i < MAX_LOG_WEAPONS); i++)
|
||||
{
|
||||
g_weapon_stats[client][i][LOG_HIT_SHOTS] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_HITS] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_KILLS] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_HEADSHOTS] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_TEAMKILLS] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_DAMAGE] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_DEATHS] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_GENERIC] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_HEAD] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_CHEST] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_STOMACH] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_LEFTARM] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_RIGHTARM] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_LEFTLEG] = 0;
|
||||
g_weapon_stats[client][i][LOG_HIT_RIGHTLEG] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
stock get_weapon_index(const String:weapon_name[])
|
||||
{
|
||||
new index = -1;
|
||||
GetTrieValue(g_weapon_trie, weapon_name, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
WstatsDumpAll()
|
||||
{
|
||||
for (new i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
dump_player_stats(i);
|
||||
}
|
||||
}
|
||||
|
||||
OnPlayerDisconnect(client)
|
||||
{
|
||||
if(client > 0 && IsClientInGame(client))
|
||||
{
|
||||
dump_player_stats(client);
|
||||
reset_player_stats(client);
|
||||
}
|
||||
}
|
473
hlstatsx/scripting/superlogs-css.sp
Normal file
473
hlstatsx/scripting/superlogs-css.sp
Normal file
@ -0,0 +1,473 @@
|
||||
/**
|
||||
* HLstatsX Community Edition - SourceMod plugin to generate advanced weapon logging
|
||||
* http://www.hlxcommunity.com
|
||||
* Copyright (C) 2009 Nicholas Hastings (psychonic)
|
||||
* Copyright (C) 2007-2008 TTS Oetzel & Goerz GmbH
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
|
||||
#define NAME "SuperLogs: CSS"
|
||||
#define VERSION "1.2.4"
|
||||
|
||||
#define MAX_LOG_WEAPONS 28
|
||||
#define IGNORE_SHOTS_START 25
|
||||
#define MAX_WEAPON_LEN 13
|
||||
|
||||
|
||||
new g_weapon_stats[MAXPLAYERS+1][MAX_LOG_WEAPONS][15];
|
||||
new const String:g_weapon_list[MAX_LOG_WEAPONS][MAX_WEAPON_LEN] = {
|
||||
"ak47",
|
||||
"m4a1",
|
||||
"awp",
|
||||
"deagle",
|
||||
"mp5navy",
|
||||
"aug",
|
||||
"p90",
|
||||
"famas",
|
||||
"galil",
|
||||
"scout",
|
||||
"g3sg1",
|
||||
"usp",
|
||||
"glock",
|
||||
"m249",
|
||||
"m3",
|
||||
"elite",
|
||||
"fiveseven",
|
||||
"mac10",
|
||||
"p228",
|
||||
"sg550",
|
||||
"sg552",
|
||||
"tmp",
|
||||
"ump45",
|
||||
"xm1014",
|
||||
"knife",
|
||||
"hegrenade",
|
||||
"smokegrenade",
|
||||
"flashbang"
|
||||
};
|
||||
|
||||
new Handle:g_cvar_wstats = INVALID_HANDLE;
|
||||
new Handle:g_cvar_headshots = INVALID_HANDLE;
|
||||
new Handle:g_cvar_actions = INVALID_HANDLE;
|
||||
new Handle:g_cvar_locations = INVALID_HANDLE;
|
||||
new Handle:g_cvar_ktraj = INVALID_HANDLE;
|
||||
new Handle:g_cvar_version = INVALID_HANDLE;
|
||||
|
||||
new bool:g_logwstats = true;
|
||||
new bool:g_logheadshots = true;
|
||||
new bool:g_logactions = true;
|
||||
new bool:g_loglocations = true;
|
||||
new bool:g_logktraj = false;
|
||||
|
||||
#include <loghelper>
|
||||
#include <wstatshelper>
|
||||
|
||||
|
||||
public Plugin:myinfo = {
|
||||
name = NAME,
|
||||
author = "psychonic",
|
||||
description = "Advanced logging for CSS. Generates auxilary logging for use with log parsers such as HLstatsX and Psychostats",
|
||||
version = VERSION,
|
||||
url = "http://www.hlxcommunity.com"
|
||||
};
|
||||
|
||||
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 3
|
||||
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
|
||||
#else
|
||||
public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
|
||||
#endif
|
||||
{
|
||||
decl String:game_description[64];
|
||||
GetGameDescription(game_description, sizeof(game_description), true);
|
||||
if (StrContains(game_description, "Counter-Strike", false) == -1)
|
||||
{
|
||||
decl String:game_folder[64];
|
||||
GetGameFolderName(game_folder, sizeof(game_folder));
|
||||
if (StrContains(game_folder, "cstrike", false) == -1)
|
||||
{
|
||||
strcopy(error, err_max, "This plugin is only supported on CS:S");
|
||||
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 3
|
||||
return APLRes_Failure;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 3
|
||||
return APLRes_Success;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
CreatePopulateWeaponTrie();
|
||||
|
||||
g_cvar_wstats = CreateConVar("superlogs_wstats", "1", "Enable logging of weapon stats (default on)", 0, true, 0.0, true, 1.0);
|
||||
g_cvar_headshots = CreateConVar("superlogs_headshots", "1", "Enable logging of headshot player action (default on)", 0, true, 0.0, true, 1.0);
|
||||
g_cvar_actions = CreateConVar("superlogs_actions", "1", "Enable logging of player actions (default on)", 0, true, 0.0, true, 1.0);
|
||||
g_cvar_locations = CreateConVar("superlogs_locations", "1", "Enable logging of location on player death (default on)", 0, true, 0.0, true, 1.0);
|
||||
g_cvar_ktraj = CreateConVar("superlogs_ktraj", "0", "Enable Psychostats \"KTRAJ\" logging (default off)", 0, true, 0.0, true, 1.0);
|
||||
|
||||
// cvars will have already existed if plugin was reloaded and might be set to non-default values
|
||||
g_logwstats = GetConVarBool(g_cvar_wstats);
|
||||
g_logheadshots = GetConVarBool(g_cvar_headshots);
|
||||
g_logactions = GetConVarBool(g_cvar_actions);
|
||||
g_loglocations = GetConVarBool(g_cvar_locations);
|
||||
g_logktraj = GetConVarBool(g_cvar_ktraj);
|
||||
|
||||
HookConVarChange(g_cvar_wstats, OnCvarWstatsChange);
|
||||
HookConVarChange(g_cvar_headshots, OnCvarHeadshotsChange);
|
||||
HookConVarChange(g_cvar_actions, OnCvarActionsChange);
|
||||
HookConVarChange(g_cvar_locations, OnCvarLocationsChange);
|
||||
HookConVarChange(g_cvar_ktraj, OnCvarKtrajChange);
|
||||
|
||||
g_cvar_version = CreateConVar("superlogs_css_version", VERSION, NAME, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
|
||||
|
||||
hook_wstats();
|
||||
hook_actions();
|
||||
HookEvent("player_death", Event_PlayerDeathPre, EventHookMode_Pre);
|
||||
HookEvent("player_death", Event_PlayerDeath);
|
||||
|
||||
CreateTimer(1.0, LogMap);
|
||||
|
||||
GetTeams();
|
||||
}
|
||||
|
||||
|
||||
public OnMapStart()
|
||||
{
|
||||
GetTeams();
|
||||
}
|
||||
|
||||
public OnConfigsExecuted()
|
||||
{
|
||||
decl String:version[255];
|
||||
GetConVarString(g_cvar_version, version, sizeof(version));
|
||||
SetConVarString(g_cvar_version, version);
|
||||
}
|
||||
|
||||
hook_wstats()
|
||||
{
|
||||
HookEvent("weapon_fire", Event_PlayerShoot);
|
||||
HookEvent("player_hurt", Event_PlayerHurt);
|
||||
HookEvent("player_spawn", Event_PlayerSpawn);
|
||||
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
|
||||
HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
|
||||
}
|
||||
|
||||
unhook_wstats()
|
||||
{
|
||||
UnhookEvent("weapon_fire", Event_PlayerShoot);
|
||||
UnhookEvent("player_hurt", Event_PlayerHurt);
|
||||
UnhookEvent("player_spawn", Event_PlayerSpawn);
|
||||
UnhookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
|
||||
UnhookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
|
||||
}
|
||||
|
||||
hook_actions()
|
||||
{
|
||||
HookEvent("round_mvp", Event_RoundMVP);
|
||||
}
|
||||
|
||||
unhook_actions()
|
||||
{
|
||||
UnhookEvent("round_mvp", Event_RoundMVP);
|
||||
}
|
||||
|
||||
public OnClientPutInServer(client)
|
||||
{
|
||||
reset_player_stats(client);
|
||||
}
|
||||
|
||||
|
||||
public Event_PlayerShoot(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
// "userid" "short"
|
||||
// "weapon" "string" // weapon name used
|
||||
|
||||
new attacker = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
if (attacker > 0)
|
||||
{
|
||||
decl String: weapon[MAX_WEAPON_LEN];
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
new weapon_index = get_weapon_index(weapon);
|
||||
if (weapon_index > -1 && weapon_index < IGNORE_SHOTS_START)
|
||||
{
|
||||
g_weapon_stats[attacker][weapon_index][LOG_HIT_SHOTS]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
// "userid" "short" // player index who was hurt
|
||||
// "attacker" "short" // player index who attacked
|
||||
// "health" "byte" // remaining health points
|
||||
// "armor" "byte" // remaining armor points
|
||||
// "weapon" "string" // weapon name attacker used, if not the world
|
||||
// "dmg_health" "byte" // damage done to health
|
||||
// "dmg_armor" "byte" // damage done to armor
|
||||
// "hitgroup" "byte" // hitgroup that was damaged
|
||||
|
||||
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
||||
|
||||
if (attacker > 0) {
|
||||
decl String: weapon[MAX_WEAPON_LEN];
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
new weapon_index = get_weapon_index(weapon);
|
||||
if (weapon_index > -1)
|
||||
{
|
||||
g_weapon_stats[attacker][weapon_index][LOG_HIT_HITS]++;
|
||||
g_weapon_stats[attacker][weapon_index][LOG_HIT_DAMAGE] += GetEventInt(event, "dmg_health");
|
||||
new hitgroup = GetEventInt(event, "hitgroup");
|
||||
if (hitgroup < 8)
|
||||
{
|
||||
g_weapon_stats[attacker][weapon_index][hitgroup + LOG_HIT_OFFSET]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Action:Event_PlayerDeathPre(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
// "userid" "short" // user ID who died
|
||||
// "attacker" "short" // user ID who killed
|
||||
// "weapon" "string" // weapon name killer used
|
||||
// "headshot" "bool" // signals a headshot
|
||||
|
||||
new attacker = GetEventInt(event, "attacker");
|
||||
if (g_loglocations)
|
||||
{
|
||||
LogKillLoc(GetClientOfUserId(attacker), GetClientOfUserId(GetEventInt(event, "userid")));
|
||||
}
|
||||
|
||||
if (g_logheadshots && GetEventBool(event, "headshot"))
|
||||
{
|
||||
LogPlayerEvent(GetClientOfUserId(attacker), "triggered", "headshot");
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
// this extents the original player_death by a new fields
|
||||
// "userid" "short" // user ID who died
|
||||
// "attacker" "short" // user ID who killed
|
||||
// "weapon" "string" // weapon name killer used
|
||||
// "headshot" "bool" // signals a headshot
|
||||
// "dominated" "short" // did killer dominate victim with this kill
|
||||
// "revenge" "short" // did killer get revenge on victim with this kill
|
||||
|
||||
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
||||
decl String: weapon[MAX_WEAPON_LEN];
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
|
||||
if (attacker <= 0 || victim <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_logwstats)
|
||||
{
|
||||
new weapon_index = get_weapon_index(weapon);
|
||||
if (weapon_index > -1)
|
||||
{
|
||||
g_weapon_stats[attacker][weapon_index][LOG_HIT_KILLS]++;
|
||||
if (GetEventBool(event, "headshot"))
|
||||
{
|
||||
g_weapon_stats[attacker][weapon_index][LOG_HIT_HEADSHOTS]++;
|
||||
}
|
||||
g_weapon_stats[victim][weapon_index][LOG_HIT_DEATHS]++;
|
||||
if (GetClientTeam(attacker) == GetClientTeam(victim))
|
||||
{
|
||||
g_weapon_stats[attacker][weapon_index][LOG_HIT_TEAMKILLS]++;
|
||||
}
|
||||
dump_player_stats(victim);
|
||||
}
|
||||
}
|
||||
if (g_logktraj)
|
||||
{
|
||||
LogPSKillTraj(attacker, victim, weapon);
|
||||
}
|
||||
if (g_logactions)
|
||||
{
|
||||
// these are only in Orangebox CS:S. These properties won't exist on ep1 css and should eval to 0/false.
|
||||
if (GetEventInt(event, "dominated"))
|
||||
{
|
||||
LogPlyrPlyrEvent(attacker, victim, "triggered", "domination");
|
||||
}
|
||||
else if (GetEventInt(event, "revenge"))
|
||||
{
|
||||
LogPlyrPlyrEvent(attacker, victim, "triggered", "revenge");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
// "userid" "short" // user ID on server
|
||||
|
||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
if (client > 0)
|
||||
{
|
||||
reset_player_stats(client);
|
||||
}
|
||||
|
||||
LogPlayerEvent(client, "triggered", "player_spawn");
|
||||
}
|
||||
|
||||
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
WstatsDumpAll();
|
||||
}
|
||||
|
||||
public Event_RoundMVP(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
LogPlayerEvent(GetClientOfUserId(GetEventInt(event, "userid")), "triggered", "round_mvp");
|
||||
}
|
||||
|
||||
public Action:Event_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
OnPlayerDisconnect(client);
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
|
||||
public Action:LogMap(Handle:timer)
|
||||
{
|
||||
// Called 1 second after OnPluginStart since srcds does not log the first map loaded. Idea from Stormtrooper's "mapfix.sp" for psychostats
|
||||
LogMapLoad();
|
||||
}
|
||||
|
||||
|
||||
public OnCvarWstatsChange(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
new bool:old_value = g_logwstats;
|
||||
g_logwstats = GetConVarBool(g_cvar_wstats);
|
||||
|
||||
if (old_value != g_logwstats)
|
||||
{
|
||||
if (g_logwstats)
|
||||
{
|
||||
hook_wstats();
|
||||
if (!g_logktraj && !g_logactions)
|
||||
{
|
||||
HookEvent("player_death", Event_PlayerDeath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unhook_wstats();
|
||||
if (!g_logktraj && !g_logactions)
|
||||
{
|
||||
UnhookEvent("player_death", Event_PlayerDeath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public OnCvarActionsChange(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
new bool:old_value = g_logactions;
|
||||
g_logactions = GetConVarBool(g_cvar_actions);
|
||||
|
||||
if (old_value != g_logactions)
|
||||
{
|
||||
if (g_logactions)
|
||||
{
|
||||
hook_actions();
|
||||
if (!g_logktraj && !g_logwstats)
|
||||
{
|
||||
HookEvent("player_death", Event_PlayerDeath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unhook_actions();
|
||||
if (!g_logktraj && !g_logwstats)
|
||||
{
|
||||
UnhookEvent("player_death", Event_PlayerDeath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public OnCvarHeadshotsChange(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
new bool:old_value = g_logheadshots;
|
||||
g_logheadshots = GetConVarBool(g_cvar_headshots);
|
||||
|
||||
if (old_value != g_logheadshots)
|
||||
{
|
||||
if (g_logheadshots && !g_loglocations)
|
||||
{
|
||||
HookEvent("player_death", Event_PlayerDeathPre, EventHookMode_Pre);
|
||||
}
|
||||
else if (!g_loglocations)
|
||||
{
|
||||
UnhookEvent("player_death", Event_PlayerDeathPre, EventHookMode_Pre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public OnCvarLocationsChange(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
new bool:old_value = g_loglocations;
|
||||
g_loglocations = GetConVarBool(g_cvar_locations);
|
||||
|
||||
if (old_value != g_loglocations)
|
||||
{
|
||||
if (g_loglocations && !g_logheadshots)
|
||||
{
|
||||
HookEvent("player_death", Event_PlayerDeathPre, EventHookMode_Pre);
|
||||
}
|
||||
else if (!g_logheadshots)
|
||||
{
|
||||
UnhookEvent("player_death", Event_PlayerDeathPre, EventHookMode_Pre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public OnCvarKtrajChange(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
new bool:old_value = g_logktraj;
|
||||
g_logktraj = GetConVarBool(g_cvar_ktraj);
|
||||
|
||||
if (old_value != g_logktraj)
|
||||
{
|
||||
if (g_logktraj && !g_logwstats && !g_logactions)
|
||||
{
|
||||
HookEvent("player_death", Event_PlayerDeath);
|
||||
}
|
||||
else if (!g_logwstats && !g_logactions)
|
||||
{
|
||||
UnhookEvent("player_death", Event_PlayerDeath);
|
||||
}
|
||||
}
|
||||
}
|
39
hlstatsx/scripting/superlogs-zr.sp
Normal file
39
hlstatsx/scripting/superlogs-zr.sp
Normal file
@ -0,0 +1,39 @@
|
||||
#include <sourcemod>
|
||||
#include <cstrike>
|
||||
|
||||
ConVar g_Cvar_HlxBonusHuman;
|
||||
ConVar g_Cvar_HlxBonusZombie;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "SuperLogs: Z:R",
|
||||
author = "BotoX",
|
||||
description = "HLstatsX CE Zombie:Reloaded extension",
|
||||
version = "1.0",
|
||||
url = ""
|
||||
};
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_Cvar_HlxBonusHuman = CreateConVar("hlx_bonus_human", "0", "", 0, true, 0.0, true, 1000.0);
|
||||
g_Cvar_HlxBonusZombie = CreateConVar("hlx_bonus_zombie", "0", "", 0, true, 0.0, true, 1000.0);
|
||||
|
||||
HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
|
||||
|
||||
AutoExecConfig(true, "plugin.superlogs-zr");
|
||||
}
|
||||
|
||||
public void Event_RoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
switch(hEvent.GetInt("winner"))
|
||||
{
|
||||
case(CS_TEAM_CT):
|
||||
{
|
||||
LogToGame("Team \"CT\" triggered \"Humans_Win\" (hlx_team_bonuspoints \"%d\")", g_Cvar_HlxBonusHuman.IntValue);
|
||||
}
|
||||
case(CS_TEAM_T):
|
||||
{
|
||||
LogToGame("Team \"TERRORIST\" triggered \"Zombies_Win\" (hlx_team_bonuspoints \"%d\")", g_Cvar_HlxBonusZombie.IntValue);
|
||||
}
|
||||
}
|
||||
}
|
1
includes/loghelper.inc
Normal file
1
includes/loghelper.inc
Normal file
@ -0,0 +1 @@
|
||||
../hlstatsx/scripting/include/loghelper.inc
|
1
includes/wstatshelper.inc
Normal file
1
includes/wstatshelper.inc
Normal file
@ -0,0 +1 @@
|
||||
../hlstatsx/scripting/include/wstatshelper.inc
|
Loading…
Reference in New Issue
Block a user