TacoServer/Classic/scripts/autoexec/ObserverCooldown.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2019-02-01 19:41:22 +00:00
// Made as a preventitive measure to ensure no rapid observer/spawning
//
//
package ObserverTimeout
{
function serverCmdClientMakeObserver( %client )
{
//10 second cooldown on becoming an observer
if( !%client.MakeObserverTimeout )
{
if ( isObject( Game ) && Game.kickClient != %client )
Game.forceObserver( %client, "playerChoose" );
%client.MakeObserverTimeout = true;
2019-02-15 08:37:24 +00:00
%client.ObserverProtectStart = getSimTime();
2019-02-01 19:41:22 +00:00
schedule(10000, 0, "ResetMakeObserverTimeout", %client );
}
//5 second cooldown on the notification
else if( !%client.ObserverCooldownMsgPlayed )
{
2019-02-15 08:37:24 +00:00
%wait = mFloor((10000 - (getSimTime() - %client.ObserverProtectStart)) / 1000);
messageClient(%client, 'MsgObserverCooldown', '\c3Observer Cooldown:\cr Please wait another %1 seconds.', %wait );
//messageClient(%client, 'MsgObserverCooldown', '\c2Observer is on cooldown.' );
2019-02-01 19:41:22 +00:00
%client.ObserverCooldownMsgPlayed = true;
2019-02-15 08:37:24 +00:00
schedule(2000, 0, "ResetObserverCooldownMsgPlayed", %client );
2019-02-01 19:41:22 +00:00
}
}
};
// Prevent package from being activated if it is already
if (!isActivePackage(ObserverTimeout))
activatePackage(ObserverTimeout);
//Allow client to become observer again
function ResetMakeObserverTimeout( %client )
{
%client.MakeObserverTimeout = false;
}
//Allow a notification again
function ResetObserverCooldownMsgPlayed( %client )
{
%client.ObserverCooldownMsgPlayed = false;
}