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
 
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.

◆ Player() [2/2]

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

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::EntitySystem::Controller().

◆ 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 55 of file Player.hpp.

◆ IsBot()

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

True for engine bots, which connect without a real SteamID.

Definition at line 44 of file Player.hpp.

◆ 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 17 of file Player.cpp.

References VoltMod::EntitySystem::Controller(), and VoltMod::ReadFile().

◆ operator=()

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

◆ Pawn()

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

Definition at line 12 of file Player.cpp.

References VoltMod::EntitySystem::Pawn().

◆ Playtime()

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

How long this connection has lasted.

Definition at line 58 of file Player.hpp.

References VoltMod::Time::Now().

◆ Ref()

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

This player as a storable reference.

Definition at line 47 of file Player.hpp.

References VoltMod::PlayerRef::Slot.

◆ Slot()

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

Definition at line 40 of file Player.hpp.

Referenced by VoltMod::CommandRouter::Dispatch().

◆ SteamId()

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

Definition at line 41 of file Player.hpp.

Referenced by VoltMod::BindPlayerOrSteamId().


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