From 601a4fe4579e1ac2a2c50f6a77627a8b6b5d0f16 Mon Sep 17 00:00:00 2001 From: ineedbots Date: Wed, 30 Jun 2021 19:02:12 -0600 Subject: [PATCH] added spectatorkick script --- raw/scripts/spectatorKick.gsc | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 raw/scripts/spectatorKick.gsc diff --git a/raw/scripts/spectatorKick.gsc b/raw/scripts/spectatorKick.gsc new file mode 100644 index 0000000..b83991d --- /dev/null +++ b/raw/scripts/spectatorKick.gsc @@ -0,0 +1,43 @@ +#include common_scripts\utility; +#include maps\mp\_utility; +#include maps\mp\gametypes\_hud_util; + +init() +{ + setDvarIfUninitialized( "g_inactivitySpectator", 0.0 ); + level.inactivitySpectator = getDvarFloat("g_inactivitySpectator") * 1000; + + if (level.inactivitySpectator <= 0) + return; + + thread watchPlayers(); +} + +watchPlayers() +{ + for(;;) + { + wait 1.5; + + theTime = getTime(); + + for (i = 0; i < level.players.size; i++) + { + player = level.players[i]; + + if (player.hasSpawned) + continue; + + if (!isDefined(player.specTime)) + { + player.specTime = theTime; + continue; + } + + if ((theTime - player.specTime) < level.inactivitySpectator) + continue; + + kick( player getEntityNumber(), "EXE_PLAYERKICKED_INACTIVE" ); + } + } +}