diff --git a/Pongbot/TF2/Entity/Player.cpp b/Pongbot/TF2/Entity/Player.cpp index 15b6198..3209334 100644 --- a/Pongbot/TF2/Entity/Player.cpp +++ b/Pongbot/TF2/Entity/Player.cpp @@ -62,10 +62,20 @@ bool Player::IsReloading() const bool Player::IsDead() const { - return _IIPlayerInfo->IsDead(); + return Exists() ? _IIPlayerInfo->IsDead() : true; } bool Player::Exists() const { return Entity::Exists() && IsPlayer(); +} + +bool Player::IsBot() const +{ + return Exists() ? _IIPlayerInfo->IsFakeClient() : false; +} + +IPlayerInfo* Player::GetPlayerInfo() const +{ + return _IIPlayerInfo; } \ No newline at end of file diff --git a/Pongbot/TF2/Entity/Player.h b/Pongbot/TF2/Entity/Player.h index 801c958..bd6b7cb 100644 --- a/Pongbot/TF2/Entity/Player.h +++ b/Pongbot/TF2/Entity/Player.h @@ -17,6 +17,8 @@ class Player : public Entity bool IsReloading() const; bool IsDead() const; bool Exists() const; + bool IsBot() const; + IPlayerInfo* GetPlayerInfo() const; private: IPlayerInfo* _IIPlayerInfo; diff --git a/Pongbot/Waypoint/WaypointManager.cpp b/Pongbot/Waypoint/WaypointManager.cpp index 582c330..ecb26e6 100644 --- a/Pongbot/Waypoint/WaypointManager.cpp +++ b/Pongbot/Waypoint/WaypointManager.cpp @@ -293,12 +293,19 @@ void WaypointManager::OnGameFrame() static IPlayerInfo* _CheckCommandTargetPlayerExists() { - edict_t* playerEdict = Engine->PEntityOfEntIndex(1); - IPlayerInfo* playerInfo = IIPlayerInfoManager->GetPlayerInfo(playerEdict); - if (!playerEdict || !playerInfo || !playerInfo->IsPlayer()) + IPlayerInfo* playerInfo = nullptr; + for (Player player : Util::GetAllPlayers()) + { + if (player.Exists()) + { + playerInfo = player.GetPlayerInfo(); + break; + } + } + + if (!playerInfo) { Util::Log("No player found!"); - return nullptr; } return playerInfo; }