From e05a9ac0b439a3466770b6ab91f5fa3d5362eade Mon Sep 17 00:00:00 2001 From: BotoX Date: Fri, 4 Aug 2017 03:07:07 +0200 Subject: [PATCH] Disable entWatch4 autobuild. Fix gitignore and missing include folders compile script python backwards compat. --- .gitignore | 6 +- AdvancedTargeting/scripting/.gitignore | 1 - .../scripting/entWatch-core.sp | 0 .../scripting/entWatch-interface.sp | 0 .../scripting/entWatch-logs.sp | 0 .../scripting/entWatch-messages.sp | 0 .../scripting/entWatch-restrictions.sp | 0 .../scripting/include/entWatch.inc | 0 .../scripting/include/entWatch_core.inc | 0 .../include/entWatch_restrictions.inc | 0 compile-all.py | 4 +- compile.py | 2 +- hlstatsx/scripting/include/loghelper.inc | 201 ++++++++++++++++++ hlstatsx/scripting/include/wstatshelper.inc | 138 ++++++++++++ 14 files changed, 345 insertions(+), 7 deletions(-) delete mode 100644 AdvancedTargeting/scripting/.gitignore rename {entWatch4 => _entWatch4}/scripting/entWatch-core.sp (100%) rename {entWatch4 => _entWatch4}/scripting/entWatch-interface.sp (100%) rename {entWatch4 => _entWatch4}/scripting/entWatch-logs.sp (100%) rename {entWatch4 => _entWatch4}/scripting/entWatch-messages.sp (100%) rename {entWatch4 => _entWatch4}/scripting/entWatch-restrictions.sp (100%) rename {entWatch4 => _entWatch4}/scripting/include/entWatch.inc (100%) rename {entWatch4 => _entWatch4}/scripting/include/entWatch_core.inc (100%) rename {entWatch4 => _entWatch4}/scripting/include/entWatch_restrictions.inc (100%) create mode 100644 hlstatsx/scripting/include/loghelper.inc create mode 100644 hlstatsx/scripting/include/wstatshelper.inc diff --git a/.gitignore b/.gitignore index 1b3c44fd..b0f1d39d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -include -spcomp -spcomp.exe +/include +/spcomp +/spcomp.exe *.secret diff --git a/AdvancedTargeting/scripting/.gitignore b/AdvancedTargeting/scripting/.gitignore deleted file mode 100644 index 1e7109b6..00000000 --- a/AdvancedTargeting/scripting/.gitignore +++ /dev/null @@ -1 +0,0 @@ -SteamAPI.secret diff --git a/entWatch4/scripting/entWatch-core.sp b/_entWatch4/scripting/entWatch-core.sp similarity index 100% rename from entWatch4/scripting/entWatch-core.sp rename to _entWatch4/scripting/entWatch-core.sp diff --git a/entWatch4/scripting/entWatch-interface.sp b/_entWatch4/scripting/entWatch-interface.sp similarity index 100% rename from entWatch4/scripting/entWatch-interface.sp rename to _entWatch4/scripting/entWatch-interface.sp diff --git a/entWatch4/scripting/entWatch-logs.sp b/_entWatch4/scripting/entWatch-logs.sp similarity index 100% rename from entWatch4/scripting/entWatch-logs.sp rename to _entWatch4/scripting/entWatch-logs.sp diff --git a/entWatch4/scripting/entWatch-messages.sp b/_entWatch4/scripting/entWatch-messages.sp similarity index 100% rename from entWatch4/scripting/entWatch-messages.sp rename to _entWatch4/scripting/entWatch-messages.sp diff --git a/entWatch4/scripting/entWatch-restrictions.sp b/_entWatch4/scripting/entWatch-restrictions.sp similarity index 100% rename from entWatch4/scripting/entWatch-restrictions.sp rename to _entWatch4/scripting/entWatch-restrictions.sp diff --git a/entWatch4/scripting/include/entWatch.inc b/_entWatch4/scripting/include/entWatch.inc similarity index 100% rename from entWatch4/scripting/include/entWatch.inc rename to _entWatch4/scripting/include/entWatch.inc diff --git a/entWatch4/scripting/include/entWatch_core.inc b/_entWatch4/scripting/include/entWatch_core.inc similarity index 100% rename from entWatch4/scripting/include/entWatch_core.inc rename to _entWatch4/scripting/include/entWatch_core.inc diff --git a/entWatch4/scripting/include/entWatch_restrictions.inc b/_entWatch4/scripting/include/entWatch_restrictions.inc similarity index 100% rename from entWatch4/scripting/include/entWatch_restrictions.inc rename to _entWatch4/scripting/include/entWatch_restrictions.inc diff --git a/compile-all.py b/compile-all.py index b8183c70..c45c64e0 100755 --- a/compile-all.py +++ b/compile-all.py @@ -15,7 +15,7 @@ if __name__ == "__main__": Plugins = [] Path, Directories, Files = next(os.walk(".")) for Directory in Directories: - if not Directory.startswith(".") and Directory != "include" and Directory != "includes" and Directory != "plugins": + if not Directory.startswith(".") and not Directory.startswith("_") and Directory != "include" and Directory != "includes" and Directory != "plugins": Plugins.append(Directory) for Plugin in Plugins: @@ -38,7 +38,7 @@ if __name__ == "__main__": Compiler.append("-o" + OutPath) try: - subprocess.run(Compiler, check=True) + subprocess.call(Compiler) except Exception: sys.exit(1) diff --git a/compile.py b/compile.py index a9efdff3..ffe789f3 100755 --- a/compile.py +++ b/compile.py @@ -35,7 +35,7 @@ if __name__ == "__main__": Compiler.append("-o" + OutPath) try: - subprocess.run(Compiler, check=True) + subprocess.call(Compiler) except Exception: sys.exit(1) diff --git a/hlstatsx/scripting/include/loghelper.inc b/hlstatsx/scripting/include/loghelper.inc new file mode 100644 index 00000000..aafe0c5d --- /dev/null +++ b/hlstatsx/scripting/include/loghelper.inc @@ -0,0 +1,201 @@ +#define LOGHELPER_VERSION 3 + +#include +#include + +new String:g_team_list[16][64]; + +// Call this on map start to cache team names in g_team_list + +stock GetTeams(bool:insmod = false) +{ + if (!insmod) + { + new max_teams_count = GetTeamCount(); + for (new team_index = 0; (team_index < max_teams_count); team_index++) + { + decl String: 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 + decl String: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 LogPlayerEvent(client, const String:verb[], const String:event[], bool:display_location = false, const String:properties[] = "", iTeam=-1) +{ + if (IsValidPlayer(client)) + { + decl String:player_authid[32]; + if (!GetClientAuthString(client, player_authid, sizeof(player_authid))) + { + strcopy(player_authid, sizeof(player_authid), "UNKNOWN"); + } + + if(iTeam == -1) + iTeam = GetClientTeam(client); + + if (display_location) + { + decl 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[iTeam], 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[iTeam], verb, event, properties); + } + } +} + +stock LogPlyrPlyrEvent(client, victim, const String:verb[], const String:event[], bool:display_location = false, const String:properties[] = "") +{ + if (IsValidPlayer(client) && IsValidPlayer(victim)) + { + decl String:player_authid[32]; + if (!GetClientAuthString(client, player_authid, sizeof(player_authid))) + { + strcopy(player_authid, sizeof(player_authid), "UNKNOWN"); + } + decl String:victim_authid[32]; + if (!GetClientAuthString(victim, victim_authid, sizeof(victim_authid))) + { + strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN"); + } + + if (display_location) + { + decl Float:player_origin[3]; + GetClientAbsOrigin(client, player_origin); + + decl 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 LogKill(attacker, victim, const String:weapon[], bool:display_location = false, const String:properties[] = "") +{ + if (IsValidPlayer(attacker) && IsValidPlayer(victim)) + { + decl String:attacker_authid[32]; + if (!GetClientAuthString(attacker, attacker_authid, sizeof(attacker_authid))) + { + strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN"); + } + decl String:victim_authid[32]; + if (!GetClientAuthString(victim, victim_authid, sizeof(victim_authid))) + { + strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN"); + } + + if (display_location) + { + decl Float:attacker_origin[3]; + GetClientAbsOrigin(attacker, attacker_origin); + decl 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); + } + } +} + +// For Psychostats "KTRAJ" kill trajectory log lines +stock LogPSKillTraj(attacker, victim, const String:weapon[]) +{ + if (IsValidPlayer(attacker) && IsValidPlayer(victim)) + { + decl String:attacker_authid[32]; + if (!GetClientAuthString(attacker, attacker_authid, sizeof(attacker_authid))) + { + strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN"); + } + decl String:victim_authid[32]; + if (!GetClientAuthString(victim, victim_authid, sizeof(victim_authid))) + { + strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN"); + } + + decl Float:attacker_origin[3]; + GetClientAbsOrigin(attacker, attacker_origin); + decl 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 LogTeamEvent(team, const String:verb[], const String:event[], const String:properties[] = "") +{ + if (team > -1) + { + LogToGame("Team \"%s\" %s \"%s\"%s", g_team_list[team], verb, event, properties); + } +} + +stock LogKillLoc(attacker, victim) +{ + if (attacker > 0 && victim > 0) + { + decl Float:attacker_origin[3]; + GetClientAbsOrigin(attacker, attacker_origin); + decl 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 LogRoleChange(client, const String:role[], const String:properties[] = "") +{ + LogPlayerEvent( client, "changed role to", role, false, properties ); +} + +stock LogMapLoad() +{ + decl String:map[64]; + GetCurrentMap(map, sizeof(map)); + LogToGame("Loading map \"%s\"", map); +} + +stock IsValidPlayer(client) +{ + if (client > 0 && client <= MaxClients && IsClientInGame(client)) + { + return true; + } + return false; +} \ No newline at end of file diff --git a/hlstatsx/scripting/include/wstatshelper.inc b/hlstatsx/scripting/include/wstatshelper.inc new file mode 100644 index 00000000..d0a9b1eb --- /dev/null +++ b/hlstatsx/scripting/include/wstatshelper.inc @@ -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); + } +} \ No newline at end of file