Files
HeroesStone_PRC8/_module/nss/_anti_rush_inc.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

61 lines
2.2 KiB
Plaintext

// Anti-Rushing Script Library
//::///////////////////////////////////////////
// _anti_rush_inc
//
// #include this library at the top of your OnClientEnter script.
// Have your OnClientEnter script call the function AntiRush() as the very first
// thing it does right after the void main. If the function returns TRUE then make
// your OnClientEnter script return. Like so:
//
// #include _anti_rush_inc
//
// ...
//
// void main()
// { if( AntiRush()) return;
// ...
//
//
// Next, add a variable to your Module Properties (don't forget this it is important)
//
// Name Type Value
// -------------------------------
// AntiRush int 1
//
//
// Finally, add the following line into your OnModuleLoad script as shown:
//
// void main()
// { DelayCommand( 120.0, DeleteLocalInt( GetModule(), "AntiRush"));
// ...
//
// Tweak the 120.0 second delay to match how long it takes your module to load up. Two
// minutes is usually more than enough.
//::////////////////////////////////////////////
int AntiRush()
{ object oPC = GetEnteringObject();
if( !GetIsPC( oPC)) return TRUE;
if( !GetLocalInt( GetModule(), "AntiRush"))
{ // Let the next guy in. Tweak the 6.0 second delay to specify how often each player
// will be able to enter the module. One player per round should be ok but you might
// want to lengthen or shorten it depending upon what your module does with joining
// players. It determines how frequently players will be allowed to enter the module
// and run thru the OnClientEnter code which is usually the place where problems occur.
// It should be at least as long as it takes the module to settle down after a player
// joins (i.e. finishes initializing the player). Often modules will use one or more
// DelayCommands on new players for various reasons. The following delay should take
// all those into account such that all delayed commands added to a joining player will
// complete before the timer below expires.
SetLocalInt( GetModule(), "AntiRush", TRUE);
DelayCommand( 6.0, DeleteLocalInt( GetModule(), "AntiRush"));
return FALSE;
}
// Too soon this guy must wait and try again.
BootPC( oPC);
return TRUE;
}