Skip to content

Commit

Permalink
Added variables to set max rounds, max rounds ot, game mode and knife…
Browse files Browse the repository at this point in the history
… round
  • Loading branch information
SmileYzn committed Aug 11, 2023
1 parent f8a5fd5 commit f6b4184
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 5 deletions.
32 changes: 28 additions & 4 deletions MatchStats/MatchStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ void CMatchStats::ServerActivate()
// Round Win Share: Extra amount added to player from winner team that defused the bomb
this->m_rws_c4_defused = gMatchUtil.CvarRegister("ms_rws_c4_defused", "30.0");

// Number of rounds in match
this->m_max_rounds = gMatchUtil.CvarRegister("ms_max_rounds", "30");

// Number of overtime rounds
this->m_max_rounds_ot = gMatchUtil.CvarRegister("ms_max_rounds_ot", "6");

// Game Mode: 0 Leaders Sorted, 1 Random Teams, 2 Not Sorted, 3 Skill Sorted, 4 Swap Teams, 5 Knife Round
this->m_game_mode = gMatchUtil.CvarRegister("ms_game_mode", "0");

// Match will have Knife Round
this->m_knife_round = gMatchUtil.CvarRegister("ms_knife_round", "0");

// Enable Stats Remote API (0 Disable, 1 Enable)
this->m_api_enable = gMatchUtil.CvarRegister("ms_api_enable", "0");

Expand Down Expand Up @@ -116,6 +128,18 @@ void CMatchStats::Cvar_DirectSet(struct cvar_s* var, const char* value)

// Set rounds played
this->m_Match.Rounds = 0;

// Number of rounds in match
this->m_Match.MaxRounds = (int)this->m_max_rounds->value;

// Number of overtime rounds
this->m_Match.MaxRoundsOT = (int)this->m_max_rounds_ot->value;

// Game Mode: 0 Leaders Sorted, 1 Random Teams, 2 Not Sorted, 3 Skill Sorted, 4 Swap Teams, 5 Knife Round
this->m_Match.GameMode = (int)this->m_game_mode->value;

// Match will have Knife Round
this->m_Match.KnifeRound = (int)this->m_knife_round->value;

// Loop each player
for (auto& Player : this->m_Player)
Expand Down Expand Up @@ -1115,10 +1139,10 @@ void CMatchStats::ExportData()
{"ScoreCTs", this->m_Match.Score[CT]},
{"Winner", this->m_Match.Winner},
{"Rounds", this->m_Match.Rounds},
{"MaxRounds", 0},
{"MaxRoundsOT", 0},
{"GameMode", 0},
{"KnifeRound", 0},
{"MaxRounds", this->m_Match.MaxRounds},
{"MaxRoundsOT", this->m_Match.MaxRoundsOT},
{"GameMode", this->m_Match.GameMode},
{"KnifeRound", this->m_Match.KnifeRound},
};

// Player
Expand Down
30 changes: 29 additions & 1 deletion MatchStats/MatchStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ typedef struct S_MATCH_STATS
// BETA: Rounds Played
int Rounds;

// Number of rounds in match
int MaxRounds;

// Number of overtime rounds
int MaxRoundsOT;

// Game Mode: 0 Leaders Sorted, 1 Random Teams, 2 Not Sorted, 3 Skill Sorted, 4 Swap Teams, 5 Knife Round
int GameMode;

// Match will have Knife Round
int KnifeRound;

// Reset
void Reset()
{
Expand All @@ -54,6 +66,10 @@ typedef struct S_MATCH_STATS
this->Score.fill(0);
this->Winner = 0;
this->Rounds = 0;
this->MaxRounds = 0;
this->MaxRoundsOT = 0;
this->GameMode = 0;
this->KnifeRound = 0;
}

// Swap Scores
Expand Down Expand Up @@ -144,7 +160,7 @@ typedef struct S_PLAYER_STATS
int OneShot; // BETA: One Shot Frags (Except for AWP)
int NoScope; // BETA: No Scope Frags
int FlyFrags; // BETA: Flying Frags
int WallFrags; // BETA: Wallbgang Frags
int WallFrags; // BETA: Wallbang Frags
int GodLikes; // TODO: Count of times when a player killed the other accompanied by the wall
int DoubleKill; // BETA: Double Kill

Expand Down Expand Up @@ -350,6 +366,18 @@ class CMatchStats
// Stats Remote API Bearer Token (Authentication Token or leave empty to disable)
cvar_t* m_api_bearer = nullptr;

// Number of rounds in match
cvar_t* m_max_rounds = nullptr;

// Number of overtime rounds
cvar_t* m_max_rounds_ot = nullptr;

// Game Mode: 0 Leaders Sorted, 1 Random Teams, 2 Not Sorted, 3 Skill Sorted, 4 Swap Teams, 5 Knife Round
cvar_t* m_game_mode = nullptr;

// Match will have Knife Round
cvar_t* m_knife_round = nullptr;

// Match State
int m_State = STATE_DEAD;

Expand Down
20 changes: 20 additions & 0 deletions cstrike/addons/matchstats.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ ms_rws_c4_explode "30.0"
// Default "30.0"
ms_rws_c4_defused "30.0"

// Number of rounds in match
//
// Default "30"
ms_max_rounds "30"

// Number of overtime rounds
//
// Default "6"
ms_max_rounds_ot "6"

// Game Mode: 0 Leaders Sorted, 1 Random Teams, 2 Not Sorted, 3 Skill Sorted, 4 Swap Teams, 5 Knife Round
//
// Default "0"
ms_game_mode "0"

// Match will have Knife Round
//
// Default "0"
ms_knife_round "0"

// Enable Stats Remote API
//
// 0 Disable
Expand Down

0 comments on commit f6b4184

Please sign in to comment.