VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Vote Class Reference

The game's yes/no vote panel (F1/F2), with the ballots counted here. More...

#include <Vote.hpp>

Public Member Functions

 Vote (Interfaces &interfaces, EntitySystem &entities, PlayerManager &players, GameEvents &events, Scheduler &scheduler)
 
 Vote (const Vote &)=delete
 
Vote & operator= (const Vote &)=delete
 
bool Start (VoteRequest request)
 
void End (VoteEndReason reason)
 
bool InProgress () const
 
bool TryCastBallot (int slot, std::string_view option)
 

Detailed Description

The game's yes/no vote panel (F1/F2), with the ballots counted here.

One vote at a time, open to every connected human; bots get no panel and no ballot. Callbacks run on the game thread.

runtime.Vote.Start({.Title = "#SFUI_vote_changelevel", .Detail = map, .DurationMs = 20000,
.Passed = [](const VoltMod::VoteTally& tally) { return tally.Yes > tally.No; }});
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56

Definition at line 68 of file Vote.hpp.

Constructor & Destructor Documentation

◆ Vote() [1/2]

VoltMod::Vote::Vote ( Interfaces &  interfaces,
EntitySystem &  entities,
PlayerManager &  players,
GameEvents &  events,
Scheduler &  scheduler 
)

All five must outlive this service; the Runtime declares them above it.

Definition at line 84 of file Vote.cpp.

References VoltMod::ReadFile().

◆ Vote() [2/2]

VoltMod::Vote::Vote ( const Vote &  )
delete

Member Function Documentation

◆ End()

void VoltMod::Vote::End ( VoteEndReason  reason)

End the running vote early. No-op when none is running.

Definition at line 205 of file Vote.cpp.

References VoltMod::ReadFile().

◆ InProgress()

bool VoltMod::Vote::InProgress ( ) const
inline

Definition at line 84 of file Vote.hpp.

◆ operator=()

Vote & VoltMod::Vote::operator= ( const Vote &  )
delete

◆ Start()

bool VoltMod::Vote::Start ( VoteRequest  request)

Open request's vote. False when one is already running, it has no VoteRequest::Passed, or no human is connected.

Definition at line 109 of file Vote.cpp.

References VoltMod::PlayerManager::All(), VoltMod::AllTeams, VoltMod::Scheduler::Delay(), VoltMod::IsValidSlot(), VoltMod::ReadFile(), and VoltMod::YesNoIssueIndex.

◆ TryCastBallot()

bool VoltMod::Vote::TryCastBallot ( int  slot,
std::string_view  option 
)

The documentation for this class was generated from the following files: