2019-09-13 19:34:03 +00:00
|
|
|
// Observer Cooldown Script
|
|
|
|
|
//
|
|
|
|
|
// Made as a preventative measure to ensure no rapid observer/spawning
|
|
|
|
|
// Limits how fast a client can spawn and go to observer
|
2019-02-01 19:41:22 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
package ObserverTimeout
|
|
|
|
|
{
|
|
|
|
|
|
2022-05-13 18:55:25 +00:00
|
|
|
function serverCmdClientMakeObserver(%client)
|
2019-02-01 19:41:22 +00:00
|
|
|
{
|
2022-05-13 18:55:25 +00:00
|
|
|
//10 second cooldown on becoming an observer
|
2020-09-03 23:17:15 +00:00
|
|
|
%timeDif = getSimTime() - %client.observerTimeout;
|
|
|
|
|
%timeDif1 = getSimTime() - %client.observerMsg;
|
|
|
|
|
if(%timeDif > 10000 || !%client.observerTimeout || %client.isAdmin)
|
|
|
|
|
{
|
|
|
|
|
%client.observerProtectStart = getSimTime();
|
|
|
|
|
%client.observerTimeout = getSimTime();
|
2022-05-13 18:55:25 +00:00
|
|
|
|
|
|
|
|
if (isObject(Game) && Game.kickClient != %client)
|
|
|
|
|
Game.forceObserver(%client, "playerChoose");
|
|
|
|
|
if($Host::TournamentMode) //Added to clear FIRE centerPrint
|
|
|
|
|
ClearCenterPrint(%client);
|
2019-02-15 08:38:41 +00:00
|
|
|
}
|
2020-09-03 23:17:15 +00:00
|
|
|
//1 second cooldown on message
|
|
|
|
|
else if((%timeDif1 > 1000 || !%client.observerMsg))
|
2019-02-01 19:41:22 +00:00
|
|
|
{
|
2020-09-03 23:17:15 +00:00
|
|
|
%wait = mFloor((10000 - (getSimTime() - %client.observerProtectStart)) / 1000);
|
2019-02-15 08:37:24 +00:00
|
|
|
messageClient(%client, 'MsgObserverCooldown', '\c3Observer Cooldown:\cr Please wait another %1 seconds.', %wait );
|
2022-05-13 18:55:25 +00:00
|
|
|
|
2020-09-03 23:17:15 +00:00
|
|
|
%client.observerMsg = getSimTime();
|
2019-02-01 19:41:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Prevent package from being activated if it is already
|
|
|
|
|
if (!isActivePackage(ObserverTimeout))
|
2020-09-03 23:17:15 +00:00
|
|
|
activatePackage(ObserverTimeout);
|