Class Limits Plugin Script

Viserys

ex team lead
Movie Battles II Team Retired
Posts
798
Likes
868
Class Limit Plugin V2.3
Credits to @LoU for the idea and the original script​


Hello community. As some of you may know, I recently started writing a script that would allow for an automated way to limit the amount of players that are allowed to join a class in MovieBattles II Open Mode.

This script is external to MovieBattles II and functions as a plugin, similar to the RTV/RTM plugin.

As such, it does not have the optimal functionality (for example it cannot prevent people from selecting a class and can only display warning messages at a certain time). But that's ok, since it was meant as a quick way to introduce class limits in MBII gameplay, as a temporary solution until class limits are properly coded within MBII itself, at which point they should have all expected functionality.

The script works by reading the server log and sending svsay and forceteam commands to the server according to classes picked by the players.
If a player picks a class after its limit has been reached, he/she will receive a warning.
If the player doesn't switch classes in time to an available one, the script will forceteam him/her to spectator.

Due to the nature of the script, the time between warning and forceteam may be limited to a few seconds, so it's advisable that a player looks at which classes are available before a new round begins. This can be done by joining a team and pressing "TAB". The classes of the players in the team will be shown in the scoreboard.

The class limits themselves are announced by the script once they are enabled. For repeat announcements, it is advisable to use the embedded DisplayMessage functionality (see below).

This script can be used by any server owner and is currently used on OFFICIAL HARDCORE servers (COMPETITIVE mode) and BG Class Limits server (LIMITS mode).

The following files are attached in this thread:

ClassLimits.exe - This is the script itself
cl.cfg - an example configuration file, similar to rtvrtm.cfg for RTV
readme.txt - the readme
LimitsCalculator.exe - a quick app I put together that allows you to easily calculate the limits you want and creates the configuration string for cl.cfg

Please note that while the script has been extensively debugged, it may still have bugs that I am unaware of.

Credits for helping with the debugging to: @AaronAaron, @DaloLorn, @eksha, @fortiseven, @FRANK LAMPART, @HuntresS, @Liniyka_xddd, @Mcbober, @Nex, @NPC, @Quinto, @qwerty, @Threepwood




Mode explanation:


This script supports two modes: LIMITS and COMPETITIVE. A third option is to disabled all limits with DISABLED mode.

*****************************************************************************************************************
DISABLED Mode
*****************************************************************************************************************
To allow for class limits to be disabled without stopping this script, the Mode in cl.cfg can be changed to DISABLED.
This removes the need to start the script on an empty server if you want to enable COMPETITIVE mode, as all you have to do is start the script on an empty server once, then use DISABLED Mode to disable all limits until you want to enable them again.
You can then switch to COMPETITIVE mode while the server is populated.

*****************************************************************************************************************
LIMITS Mode
*****************************************************************************************************************
The LIMITS mode applies predefined limits for each class to the server.
These limits can be changed anytime on the cl.cfg script by editing the Limits variable.
The script will detect new limits every 5 seconds.
Supported limits range from 0 (class disabled) to 32 for all classes.

The class order on the Limits variable is: Reb Soldier, Jedi, Hero, Mandalorian, Wookiee, Droideka, Clone Trooper, Reb Commander, Super Battle Droid, Arc Trooper, Bounty Hunter, Imp Soldier, Sith, Imp Commander

For example, if Limits is defined as: Limits=00-00-01-00-00-00-00-00-00-00-00-00-00-01 then the script will allow 1 Hero and one Imp Commander. All other classes will be disabled.

WARNING: The script does not check if the defined limits allow all players to join a class. This means if your limits allows for 3 class spots in total but your server supports 12 players, then 9 players will not be able to play. It is up to you to define the limits correctly.

*****************************************************************************************************************
COMPETITIVE Mode
*****************************************************************************************************************
The COMPETITIVE mode functions on the premise that all classes have the same limit, which depends on the total number of people on the server.

The limit changes between the values of 1, 2 and 3 depending on the number of players in the server.
The number of players at which the limit will change to 2 or 3 is defined in the cl.cfg with the Limits2 and Limits3 variables.

These are checked to ensure that all players in the server can join the game. This means that Limits2 cannot be larger than 15 (as a limit of 1 supports up to 14 players) and Limits3 cannot be larger than 29 (as a limit of 2 supports up to 28 players).

*****************************************************************************************************************



Configuration:

Please enter the following values in cl.cfg:
  1. IP: Server IP
  2. Port: Server port
  3. RCON: Server rconpassword
  4. log_path: Absolute path to server log file
  5. DisplayMessage: Message you want to be repeated via svsay on the server (leave blank to disable). Make sure it doesn't contain an '=' character
  6. DisplayMessage2: Second message you want to be repeated via svsay on the server (leave blank to disable). Make sure it doesn't contain an '=' character
  7. RepeatInterval: How often the DisplayMessages will be repeated, in seconds (between 5 and 1800)
  8. Mode: LIMITS or COMPETITIVE or DISABLED
  9. Limits: The predefined Class Limits, in XX format, for all 14 classes separated by a -, for example: 00-00-01-00-00-00-00-00-00-00-00-00-00-01 (for LIMITS mode). Class order: Reb Soldier, Jedi, Hero, Mandalorian, Wookiee, Droideka, Clone Trooper, Reb Commander, Super Battle Droid, Arc Trooper, Bounty Hunter, Imp Soldier, Sith, Imp Commander
  10. Limits2: Number of players that must be connected to the server for Class Limit to increase to 2 (for COMPETITIVE mode)
  11. Limits3: Number of players that must be connected to the server for Class Limit to increase to 3 (for COMPETITIVE mode)




How to use:

The script is configured in the cl.cfg configuration file, which must be saved in the same directory as the executable. The script reads cl.cfg for any changes every 5 seconds.

  • Start this script after the server has been started and while the server is empty.
  • There is no requirement to clean the server log before starting this script.
  • If you only want to use LIMITS mode, the script can be activated when the server is populated.
  • COMPETITIVE mode will NOT work unless the script was started on empty server.
  • If the script was started on a populated server then COMPETITIVE mode will only start working properly when server becomes empty again.
  • Until that happens, the script won't count the population properly and the limits won't be changed when they should.
TIP: You can prevent players from joining the server while you start this script by temporarily setting a g_password.
TIP: To remove the g_password, set it to "none"

V2.1: The mode can now be also controlled via /smod say and /rcon say by typing "!mode <mode>" where <mode> is COMPETTIVE, LIMITS, or DISABLED. This will overwrite the mode defined in cl.cfg until cl.cfg mode is changed again.


KNOWN ISSUES:

  • This script sends rcon commands to the server. If a forceteam command happens to overlap with commands from another source (e.g. automessages, RTV, manual rcon commands), it is possible that the forceteam will NOT go through and therefore the script will allow that player to exceed the class limit until he either joins spectator or changes class. This is unlikely but may still happen.
  • RTV archiving may interfere with this script as a few lines (1 line probably) might NOT be written in the log while RTV archives. Unlikely that these lines will be important, but if they are related to a client disconnect this could cause a problem with the script.






Download here
 
Last edited:
Posts
143
Likes
96
Hey!
Some feedback: I played on the BG Class Limit server, and I noticed that the script replaces some "special" characters like the "é" character in my name to a question mark (?) when it gives notification about the class limit (for example: "Vit?z, Ok, your class is fine now").
Anyway, good job on this script, it works well, good to see some improvement for Open mode.
 

Viserys

ex team lead
Movie Battles II Team Retired
Posts
798
Likes
868
Updated script to V2.2.

It was reported to me that a bug caused an incorrect warning spam, even for disconnected players. So I looked it up and indeed found a bug that would cause the script to think that disconnected players were still in the server (I actually introduced it when I tried to fix the reconnect issue). However this would have only occured if the script crashed and restarted automatically, but the crash log doesn't report any script restarts.

So I'm puzzled, but fixed the bug anyway. I haven't had a chance to debug the fix extensively, so hopefully I didn't break something else with my midnight coding!

This still doesn't explain what happened yesterday, so there might be another underlying bug. If the script goes crazy again, please report it here!

Edit: now I'm pretty sure this is related to RTV archiving the logs but need to look into it further
 
Last edited:
  • Like
Reactions: Nex

Viserys

ex team lead
Movie Battles II Team Retired
Posts
798
Likes
868
ok so I managed to replicate what happens when RTV archives the logs. A log line could be lost while that happens so I've disabled RTV archiving for class limits servers (and replaced it with my own script). Still no idea what happened that day though
 
Posts
45
Likes
37
If possible, it would be nice to know when a class become available like "Hero slot is now available" so we don't have to check tab every time.
 

LoU

R2D2
Movie Battles II Team Retired
Posts
746
Likes
651
If possible, it would be nice to know when a class become available like "Hero slot is now available" so we don't have to check tab every time.

People change class too often, that's not needed, AFAIK script should post summary every few minutes tho.
 

DaloLorn

Movie Battles II Team Retired
Posts
408
Likes
261
People change class too often, that's not needed, AFAIK script should post summary every few minutes tho.

It might also be nice if you could ask the script to give you the summary early. (The response might have to go through PMs, to avoid spam.)
 
Posts
45
Likes
37
People change class too often, that's not needed, AFAIK script should post summary every few minutes tho.

I didn't think about that. Following DaloLorn idea, maybe we could ask the script to tell us when a specific class is available by private message then ?
 

Viserys

ex team lead
Movie Battles II Team Retired
Posts
798
Likes
868
there is no way to PM from the server and even if there were, the server sends too many messages as is. Every message adds delay to the script.
 

Viserys

ex team lead
Movie Battles II Team Retired
Posts
798
Likes
868
minor Update to 2.3, messages now don't display if limits are disabled
 

Puppytine

Slayed dreamer
Posts
2,237
Likes
1,487
Any chance of getting the source for Linux servers assuming Python?
Nope.
Unlike RTV, this is not a Python script, it's .NET application.
The only chance to run it on Linux is Mono.

e528c911e5b3.png
 
Posts
118
Likes
63
Hey!
Some feedback: I played on the BG Class Limit server, and I noticed that the script replaces some "special" characters like the "é" character in my name to a question mark (?) when it gives notification about the class limit (for example: "Vit?z, Ok, your class is fine now").
Anyway, good job on this script, it works well, good to see some improvement for Open mode.
Szia vitéz, a movie battles 2-n nem lehet olyat csinálni hogy "é", sajnálom. :) Vagy ha igen akkor elnézést kérem, ha megvan oldva a probléma akkor csak szólj. :)
 
Top