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

One connected player, owned by PlayerManager for the length of the connection. More...

#include <Player.hpp>

Public Member Functions

 Player (int slot, int64_t steamId, std::string connectName, std::string ip, EntitySystem *entities)
 Player (const Player &)=delete
Player & operator= (const Player &)=delete
int Slot () const noexcept
int64_t SteamId () const noexcept
bool IsBot () const noexcept
bool IsSourceTV () const
PlayerRef Ref () const noexcept
std::string Name () const
std::string_view Ip () const noexcept
std::chrono::seconds Playtime () const
VoltMod::Controller Controller () const
VoltMod::Pawn Pawn () const

Detailed Description

One connected player, owned by PlayerManager for the length of the connection.

A Player& stays valid while the player is connected. Store a PlayerRef across anything that can outlive that, and resolve it with runtime.Players.Get(ref). Identity only: keep plugin state in your own managers, keyed by SteamID.

Definition at line 22 of file Player.hpp.

Constructor & Destructor Documentation

◆ Player() [1/2]

VoltMod::Player::Player ( int slot,
int64_t steamId,
std::string connectName,
std::string ip,
EntitySystem * entities )
inline

Definition at line 27 of file Player.hpp.

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

◆ Player() [2/2]

VoltMod::Player::Player ( const Player & )
delete

References Player().

Member Function Documentation

◆ Controller()

VoltMod::Controller VoltMod::Player::Controller ( ) const

This player's entities, valid for this frame; falsy when there are none. Include <VoltMod/Entities/EntitySystem.hpp> or <VoltMod/Api.hpp> to use them.

Definition at line 7 of file Player.cpp.

References VoltMod::Controller::Controller().

Referenced by IsSourceTV().

◆ Ip()

std::string_view VoltMod::Player::Ip ( ) const
inlinenoexcept

The IP the player connected from, captured at connect because the engine offers it only there. Empty for bots.

Definition at line 60 of file Player.hpp.

◆ IsBot()

bool VoltMod::Player::IsBot ( ) const
inlinenoexcept

True for engine bots and the SourceTV relay, which connect without a real SteamID; IsSourceTV tells them apart.

Definition at line 45 of file Player.hpp.

Referenced by IsSourceTV().

◆ IsSourceTV()

bool VoltMod::Player::IsSourceTV ( ) const

True for the SourceTV relay: it takes a player slot, but nobody plays it. Read from the controller, so false until the relay has one.

Definition at line 17 of file Player.cpp.

References Controller(), and IsBot().

◆ Name()

std::string VoltMod::Player::Name ( ) const

The scoreboard name, read from the controller. Falls back to the connect-time name while there is no controller yet - between ClientConnected and the first spawn.

Definition at line 22 of file Player.cpp.

References VoltMod::Controller::Controller().

◆ operator=()

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

References Player().

◆ Pawn()

VoltMod::Pawn VoltMod::Player::Pawn ( ) const

Definition at line 12 of file Player.cpp.

◆ Playtime()

std::chrono::seconds VoltMod::Player::Playtime ( ) const
inline

How long this connection has lasted.

Definition at line 63 of file Player.hpp.

References VoltMod::Time::Now().

◆ Ref()

PlayerRef VoltMod::Player::Ref ( ) const
inlinenoexcept

This player as a storable reference.

Definition at line 52 of file Player.hpp.

Referenced by VoltMod::CommandRouter::Dispatch(), VoltMod::PlayerManager::GetRef(), and VoltMod::EngineArgBinder::Resolve().

◆ Slot()

int VoltMod::Player::Slot ( ) const
inlinenoexcept

◆ SteamId()

int64_t VoltMod::Player::SteamId ( ) const
inlinenoexcept

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