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; }});

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 36 of file Vote.cpp.

References VoltMod::PlayerManager::Disconnected.

Referenced by operator=(), and Vote().

◆ Vote() [2/2]

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

References Vote().

Member Function Documentation

◆ End()

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

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

Definition at line 158 of file Vote.cpp.

◆ InProgress()

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

Definition at line 84 of file Vote.hpp.

◆ operator=()

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

References Vote().

◆ 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 62 of file Vote.cpp.

References VoltMod::AllTeams, VoltMod::VoteRequest::DurationMs, VoltMod::VoteTally::Eligible, VoltMod::IsValidSlot(), VoltMod::VoteRequest::Passed, 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: