From 001170e092c27d41bac31e81d3282f6bee2125b8 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sun, 20 Aug 2023 18:08:11 +0700 Subject: [PATCH] Add `IsSpectator()` check for `EPlayer` --- sources/Players/EPlayer.uc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sources/Players/EPlayer.uc b/sources/Players/EPlayer.uc index 8eed122..bb2f928 100644 --- a/sources/Players/EPlayer.uc +++ b/sources/Players/EPlayer.uc @@ -422,6 +422,19 @@ public final function bool IsAdmin() return (GetAdminStatus() != AS_None); } +/// Checks if player is a spectator, i.e. observes game without actively +/// participating. +public final function bool IsSpectator() +{ + local PlayerReplicationInfo myReplicationInfo; + + myReplicationInfo = GetRI(); + if (myReplicationInfo == none) { + return true; + } + return myReplicationInfo.bOnlySpectator; +} + /** * Changes admin status of the caller `EPlayer`. * Can only fail if caller `EPlayer` has already disconnected.