From 8aeefc3fcab74813b788db959600ef62deaa3047 Mon Sep 17 00:00:00 2001 From: OciXCrom Date: Sat, 25 Aug 2018 20:52:48 +0200 Subject: [PATCH] Add constants for stats functions (#509) * Add constants for stats functions * Changed STATS_ to STATSX_ and added 2 more defines * Added constants for all games * Add csstats_const.inc and add _MAX_ constats to enum * Change bodyhits --- modules/cstrike/csx/msvc12/csx.vcxproj | 1 + .../cstrike/csx/msvc12/csx.vcxproj.filters | 3 ++ plugins/include/amxconst.inc | 17 +++++++++ plugins/include/csstats.inc | 38 ++++++++++++++----- plugins/include/csstats_const.inc | 29 ++++++++++++++ plugins/include/dodconst.inc | 14 +++++++ plugins/include/dodstats.inc | 18 ++++----- plugins/include/tfcstats.inc | 14 +++---- plugins/include/tsstats.inc | 16 ++++---- support/PackageScript | 1 + 10 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 plugins/include/csstats_const.inc diff --git a/modules/cstrike/csx/msvc12/csx.vcxproj b/modules/cstrike/csx/msvc12/csx.vcxproj index 6a6d695b..2badf907 100644 --- a/modules/cstrike/csx/msvc12/csx.vcxproj +++ b/modules/cstrike/csx/msvc12/csx.vcxproj @@ -160,6 +160,7 @@ + diff --git a/modules/cstrike/csx/msvc12/csx.vcxproj.filters b/modules/cstrike/csx/msvc12/csx.vcxproj.filters index e0865b43..cc5eab35 100644 --- a/modules/cstrike/csx/msvc12/csx.vcxproj.filters +++ b/modules/cstrike/csx/msvc12/csx.vcxproj.filters @@ -60,6 +60,9 @@ Pawn Includes + + Pawn Includes + Pawn Includes diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index 1e7ac379..ca5011ee 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -151,6 +151,7 @@ public stock const Float:NULL_VECTOR[3]; #define HIT_LEFTLEG 6 #define HIT_RIGHTLEG 7 #define HIT_SHIELD 8 // CS only +#define MAX_BODYHITS 8 /** * @section emit_sound() constants @@ -516,4 +517,20 @@ enum FindPlayerFlags (<<= 1) FindPlayer_IncludeConnecting // Include connecting clients } +/** + * Constants for client statistics + */ +enum +{ + STATSX_KILLS = 0, + STATSX_DEATHS, + STATSX_HEADSHOTS, + STATSX_TEAMKILLS, + STATSX_SHOTS, + STATSX_HITS, + STATSX_DAMAGE, + STATSX_RANK, + STATSX_MAX_STATS +} + #include // To keep backward compatibility diff --git a/plugins/include/csstats.inc b/plugins/include/csstats.inc index 96e168ef..84b7a4da 100755 --- a/plugins/include/csstats.inc +++ b/plugins/include/csstats.inc @@ -12,6 +12,8 @@ #endif #define _csstats_included +#include + /** * Retrieves the client's current weapon statistics. * @@ -19,6 +21,8 @@ * amxconst.inc, this function also works on custom weapons. * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -39,7 +43,7 @@ * @error If an invalid client index or weapon id is provided, an * error will be thrown. */ -native get_user_wstats(index, wpnindex, stats[8], bodyhits[8]); +native get_user_wstats(index, wpnindex, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]); /** * Retrieves the client's weapon statistics from the current round. @@ -48,6 +52,8 @@ native get_user_wstats(index, wpnindex, stats[8], bodyhits[8]); * amxconst.inc, this function also works on custom weapons. * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -68,7 +74,7 @@ native get_user_wstats(index, wpnindex, stats[8], bodyhits[8]); * @error If an invalid client index or weapon id is provided, an * error will be thrown. */ -native get_user_wrstats(index, wpnindex, stats[8], bodyhits[8]); +native get_user_wrstats(index, wpnindex, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]); /** * Retrieves the client's weapon statistics from the permanent storage on the @@ -80,6 +86,8 @@ native get_user_wrstats(index, wpnindex, stats[8], bodyhits[8]); * deaths/teamkills. * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -99,13 +107,15 @@ native get_user_wrstats(index, wpnindex, stats[8], bodyhits[8]); * @error If an invalid client index is provided, an error will be * thrown. */ -native get_user_stats(index, stats[8], bodyhits[8]); +native get_user_stats(index, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]); /** * Retrieves the client's statistics from the current round. * * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -123,7 +133,7 @@ native get_user_stats(index, stats[8], bodyhits[8]); * @error If an invalid client index is provided, an error will be * thrown. */ -native get_user_rstats(index, stats[8], bodyhits[8]); +native get_user_rstats(index, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]); /** * Retrieves the client's statistics inflicted upon another client from the @@ -131,6 +141,8 @@ native get_user_rstats(index, stats[8], bodyhits[8]); * * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -153,7 +165,7 @@ native get_user_rstats(index, stats[8], bodyhits[8]); * @error If an invalid client index is provided, an error will be * thrown. */ -native get_user_vstats(index, victim, stats[8], bodyhits[8], wpnname[] = "", len = 0); +native get_user_vstats(index, victim, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS], wpnname[] = "", len = 0); /** * Retrieves the client's statistics received from another client from the @@ -161,6 +173,8 @@ native get_user_vstats(index, victim, stats[8], bodyhits[8], wpnname[] = "", len * * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -183,7 +197,7 @@ native get_user_vstats(index, victim, stats[8], bodyhits[8], wpnname[] = "", len * @error If an invalid client index is provided, an error will be * thrown. */ -native get_user_astats(index, wpnindex, stats[8], bodyhits[8], wpnname[] = "", len = 0); +native get_user_astats(index, wpnindex, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS], wpnname[] = "", len = 0); /** * Resets the current round weapon, attacker and victim statistics. @@ -206,6 +220,8 @@ native reset_user_wstats(index); * deaths/teamkills. * @note For a list of possible body hitplaces see the HIT_* constants in * amxconst.inc + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - Kills * 1 - Deaths @@ -227,7 +243,7 @@ native reset_user_wstats(index); * @return Next rank index (> 0 and > index), or 0 if no more * statistics exist */ -native get_stats(index, stats[8], bodyhits[8], name[], len, authid[] = "", authidlen = 0); +native get_stats(index, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS], name[], len, authid[] = "", authidlen = 0); /** * Returns the number of all entries in the permanent statistics storage. @@ -240,6 +256,8 @@ native get_statsnum(); * Retrieves the client's objective statistics from the permanent storage. * * @note The permanent storage is updated on every respawn or client disconnect. + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - total defusions * 1 - bomb defused @@ -254,13 +272,15 @@ native get_statsnum(); * @error If an invalid client index is provided, an error will be * thrown. */ -native get_user_stats2(index, stats[4]); +native get_user_stats2(index, stats[STATSX_MAX_OBJECTIVE]); /** * Retrieves objective statistics from the permanent storage on the server via * iterative, incremental access. * * @note The permanent storage is updated on every respawn or client disconnect. + * @note For a list of possible stat constants see the STATSX_* constants in + * amxconst.inc * @note The fields in the statistics are: * 0 - total defusions * 1 - bomb defused @@ -275,4 +295,4 @@ native get_user_stats2(index, stats[4]); * @return Next rank index (> 0 and > index), or 0 if no more * statistics exist */ -native get_stats2(index, stats[4], authid[] = "", authidlen = 0); +native get_stats2(index, stats[STATSX_MAX_OBJECTIVE], authid[] = "", authidlen = 0); diff --git a/plugins/include/csstats_const.inc b/plugins/include/csstats_const.inc new file mode 100644 index 00000000..a392d1bb --- /dev/null +++ b/plugins/include/csstats_const.inc @@ -0,0 +1,29 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// +// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). +// Copyright (C) The AMX Mod X Development Team. +// +// This software is licensed under the GNU General Public License, version 3 or higher. +// Additional exceptions apply. For full license details, see LICENSE.txt or visit: +// https://alliedmods.net/amxmodx-license + +// +// Counter-Strike Functions +// + +#if defined _csstats_const_included + #endinput +#endif +#define _csstats_const_included + +/** + * Constants for objective based statistics + */ +enum +{ + STATSX_TOTAL_DEFUSIONS = 0, + STATSX_BOMBS_DEFUSED, + STATSX_BOMBS_PLANTED, + STATSX_BOMB_EXPLOSIONS, + STATSX_MAX_OBJECTIVE +} diff --git a/plugins/include/dodconst.inc b/plugins/include/dodconst.inc index ca53e802..14807e53 100755 --- a/plugins/include/dodconst.inc +++ b/plugins/include/dodconst.inc @@ -136,3 +136,17 @@ enum { DODC_PIAT, //DODC_BRIT_MORTAR, }; + +/* DoD stats constants */ +enum { + DODX_KILLS = 0, + DODX_DEATHS, + DODX_HEADSHOTS, + DODX_TEAMKILLS, + DODX_SHOTS, + DODX_HITS, + DODX_DAMAGE, + DODX_POINTS, + DODX_RANK, + DODX_MAX_STATS +} diff --git a/plugins/include/dodstats.inc b/plugins/include/dodstats.inc index a250a2ba..381496a2 100755 --- a/plugins/include/dodstats.inc +++ b/plugins/include/dodstats.inc @@ -28,34 +28,34 @@ * 6 - damage * 7 - score * For body hits fields see amxconst.inc. */ -native get_user_wstats(index,wpnindex,stats[9],bodyhits[8]); +native get_user_wstats(index,wpnindex,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets round stats from given weapon index.*/ -native get_user_wrstats(index,wpnindex,stats[9],bodyhits[8]); +native get_user_wrstats(index,wpnindex,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets life (from spawn to spawn) stats from given weapon index.*/ -native get_user_wlstats(index,wpnindex,stats[9],bodyhits[8]); +native get_user_wlstats(index,wpnindex,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets overall stats which are stored in file on server * and updated on every respawn or user disconnect. * Function returns the position in stats by diff. kills to deaths. */ -native get_user_stats(index,stats[9],bodyhits[8]); +native get_user_stats(index,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets round stats of player. */ -native get_user_rstats(index,stats[9],bodyhits[8]); +native get_user_rstats(index,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets life (from spawn to spawn) stats of player. */ -native get_user_lstats(index,stats[9],bodyhits[8]); +native get_user_lstats(index,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets stats with which user have killed/hurt his victim. If victim is 0 * then stats are from all victims. If victim has not been hurt, function * returns 0 in other case 1. User stats are reset on his respawn. */ -native get_user_vstats(index,victim,stats[9],bodyhits[8],wpnname[]="",len=0); +native get_user_vstats(index,victim,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0); /* Gets stats with which user have been killed/hurt. If killer is 0 * then stats are from all attacks. If killer has not hurt user, function * returns 0 in other case 1. User stats are reset on his respawn. */ -native get_user_astats(index,wpnindex,stats[9],bodyhits[8],wpnname[]="",len=0); +native get_user_astats(index,wpnindex,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0); /* Resets life, weapon, victims and attackers user stats. */ native reset_user_wstats(index); @@ -63,7 +63,7 @@ native reset_user_wstats(index); /* Gets overall stats which stored in stats.dat file in amx folder * and updated on every mapchange or user disconnect. * Function returns next index of stats entry or 0 if no more exists. */ -native get_stats(index,stats[9],bodyhits[8],name[],len); +native get_stats(index,stats[DODX_MAX_STATS],bodyhits[MAX_BODYHITS],name[],len); /* Returns number of all entries in stats. */ native get_statsnum(); diff --git a/plugins/include/tfcstats.inc b/plugins/include/tfcstats.inc index 9417a0f6..367406a3 100755 --- a/plugins/include/tfcstats.inc +++ b/plugins/include/tfcstats.inc @@ -27,28 +27,28 @@ * 5 - hits * 6 - damage * For body hits fields see amxconst.inc. */ -native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]); +native get_user_wstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets round stats from given weapon index.*/ -native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]); +native get_user_wrstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets overall stats which are stored in file on server * and updated on every respawn or user disconnect. * Function returns the position in stats by diff. kills to deaths. */ -native get_user_stats(index,stats[8],bodyhits[8]); +native get_user_stats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets round stats of player. */ -native get_user_rstats(index,stats[8],bodyhits[8]); +native get_user_rstats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets stats with which user have killed/hurt his victim. If victim is 0 * then stats are from all victims. If victim has not been hurt, function * returns 0 in other case 1. User stats are reset on his respawn. */ -native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0); +native get_user_vstats(index,victim,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0); /* Gets stats with which user have been killed/hurt. If killer is 0 * then stats are from all attacks. If killer has not hurt user, function * returns 0 in other case 1. User stats are reset on his respawn. */ -native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0); +native get_user_astats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0); /* Resets life, weapon, victims and attackers user stats. */ native reset_user_wstats(index); @@ -56,7 +56,7 @@ native reset_user_wstats(index); /* Gets overall stats which stored in stats.dat file in amx folder * and updated on every mapchange or user disconnect. * Function returns next index of stats entry or 0 if no more exists. */ -native get_stats(index,stats[8],bodyhits[8],name[],len); +native get_stats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],name[],len); /* Returns number of all entries in stats. */ native get_statsnum(); diff --git a/plugins/include/tsstats.inc b/plugins/include/tsstats.inc index 4b43a784..dd2ba60a 100755 --- a/plugins/include/tsstats.inc +++ b/plugins/include/tsstats.inc @@ -27,31 +27,31 @@ * 5 - hits * 6 - damage * For body hits fields see amxconst.inc. */ -native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]); +native get_user_wstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets round stats from given weapon index.*/ -native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]); +native get_user_wrstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets life (from spawn to spawn) stats from given weapon index.*/ -native get_user_wlstats(index,wpnindex,stats[8],bodyhits[8]); +native get_user_wlstats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets overall stats which are stored in file on server * and updated on every respawn or user disconnect. * Function returns the position in stats by diff. kills to deaths. */ -native get_user_stats(index,stats[8],bodyhits[8]); +native get_user_stats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets round stats of player. */ -native get_user_rstats(index,stats[8],bodyhits[8]); +native get_user_rstats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS]); /* Gets stats with which user have killed/hurt his victim. If victim is 0 * then stats are from all victims. If victim has not been hurt, function * returns 0 in other case 1. User stats are reset on his respawn. */ -native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0); +native get_user_vstats(index,victim,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0); /* Gets stats with which user have been killed/hurt. If killer is 0 * then stats are from all attacks. If killer has not hurt user, function * returns 0 in other case 1. User stats are reset on his respawn. */ -native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0); +native get_user_astats(index,wpnindex,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],wpnname[]="",len=0); /* Resets life, weapon, victims and attackers user stats. */ native reset_user_wstats(index); @@ -59,7 +59,7 @@ native reset_user_wstats(index); /* Gets overall stats which stored in stats.dat file in amx folder * and updated on every mapchange or user disconnect. * Function returns next index of stats entry or 0 if no more exists. */ -native get_stats(index,stats[8],bodyhits[8],name[],len); +native get_stats(index,stats[STATSX_MAX_STATS],bodyhits[MAX_BODYHITS],name[],len); /* Returns number of all entries in stats. */ native get_statsnum(); diff --git a/support/PackageScript b/support/PackageScript index fb754562..fe70fe8f 100644 --- a/support/PackageScript +++ b/support/PackageScript @@ -275,6 +275,7 @@ scripting_files = [ 'include/amxmodx.inc', 'include/core.inc', 'include/csstats.inc', + 'include/csstats_const.inc', 'include/cstrike.inc', 'include/cstrike_const.inc', 'include/csx.inc',