Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leader Rework #299

Merged
merged 8 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,18 @@ zr_infect_shake_duration 5.0 // Duration of shaking effect
cs2f_leader_enable 0 // Whether to enable Leader features
cs2f_leader_vote_ratio 0.15 // Vote ratio needed for player to become a leader
cs2f_leader_actions_ct_only 1 // Whether to allow leader actions (like !beacon) only from human team
cs2f_leader_mute_ping_no_leader 1 // Whether to mute player pings whenever there's no leader
cs2f_leader_marker_ct_only 1 // Whether to have zombie leaders' player_pings spawn in particle markers or not
cs2f_leader_mute_player_pings 1 // Whether to mute player pings made by non-leaders
cs2f_leader_model_path "" // Path to player model to be used for leaders
cs2f_leader_defend_particle "particles/cs2fixes/leader_defend_mark.vpcf" // Path to defend particle to be used with c_defend
cs2f_leader_mark_particle "particles/cs2fixes/leader_defend_mark.vpcf" // Path to particle to be used when a ct leader using player_ping
cs2f_leader_can_target_players 0 // Whether a leader can target other players with leader commands (not including c_leader)
cs2f_leader_vote_multiple 1 // If 1, players can vote up to cs2f_max_leaders leaders. If 0, they may vote for a single leader
cs2f_leader_max_leaders 3 // Max amount of leaders set via c_vl or a leader using c_leader (doesn't impact admins)
cs2f_leader_max_markers 6 // Max amount of markers set by leaders (doesn't impact admins)
cs2f_leader_max_glows 3 // Max amount of glows set by leaders (doesn't impact admins)
cs2f_leader_max_tracers 3 // Max amount of tracers set by leaders (doesn't impact admins)
cs2f_leader_max_beacons 3 // Max amount of beacons set by leaders (doesn't impact admins)

// Idle Kick Settings
cs2f_idle_kick_time 0.0 // Amount of minutes before kicking idle players. 0 to disable afk kicking.
Expand Down
24 changes: 23 additions & 1 deletion src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "entity/lights.h"
#include "playermanager.h"
#include "adminsystem.h"
#include "leader.h"
#include "ctimer.h"
#include "httpmanager.h"
#include "discord.h"
Expand Down Expand Up @@ -345,8 +346,29 @@ bool CChatCommand::CheckCommandAccess(CCSPlayerController *pPlayer, uint64 flags
int slot = pPlayer->GetPlayerSlot();

ZEPlayer *pZEPlayer = g_playerManager->GetPlayer(slot);

if (!pZEPlayer)
return false;

if (!pZEPlayer->IsAdminFlagSet(flags))
if ((flags & FLAG_LEADER) == FLAG_LEADER)
{
if (!g_bEnableLeader)
return false;
if (!pZEPlayer->IsAdminFlagSet(FLAG_LEADER))
{
if (!pZEPlayer->IsLeader())
{
ClientPrint(pPlayer, HUD_PRINTTALK, CHAT_PREFIX "You must be a leader to use this command.");
return false;
}
else if (g_bLeaderActionsHumanOnly && pPlayer->m_iTeamNum != CS_TEAM_CT)
{
ClientPrint(pPlayer, HUD_PRINTTALK, CHAT_PREFIX "You must be a human to use this command.");
return false;
}
}
}
else if (!pZEPlayer->IsAdminFlagSet(flags))
{
ClientPrint(pPlayer, HUD_PRINTTALK, CHAT_PREFIX "You don't have access to this command.");
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "entity/ccsplayercontroller.h"
#include "convar.h"
#include "adminsystem.h"
#include "leader.h"
#include <vector>

#define CMDFLAG_NONE (0)
Expand Down Expand Up @@ -127,3 +128,4 @@ void ParseChatCommand(const char *, CCSPlayerController *);
void name##_callback(const CCommand &args, CCSPlayerController *player)

#define CON_COMMAND_CHAT(name, description) CON_COMMAND_CHAT_FLAGS(name, description, ADMFLAG_NONE)
#define CON_COMMAND_CHAT_LEADER(name, description) CON_COMMAND_CHAT_FLAGS(name, description, FLAG_LEADER)
Loading