Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,55 @@ Grafana:
<h6>Default</h6>
<pre><code>false</code></pre></li></ul>
</details>

<details>
<summary>EnforceSquadLeaderKit</summary>
<h2>EnforceSquadLeaderKit</h2>
<p>The <code>EnforceSquadLeaderKit</code> plugin ensures that squad leaders select the correct Squad Leader kit. It will warn players who do not comply and disband their squad if they fail to switch after multiple warnings.</p>

<h3>Options</h3>
<ul>
<li>
<h4>warningMessage</h4>
<h6>Description</h6>
<p>Message displayed to squad leaders warning them to take the correct kit.</p>
<h6>Default</h6>
<pre><code>You must take the Squad Leader kit, or your squad will be disbanded!</code></pre>
</li>

<li>
<h4>checkInterval</h4>
<h6>Description</h6>
<p>Interval (in seconds) to check all squad leaders for the correct kit.</p>
<h6>Default</h6>
<pre><code>30</code></pre>
</li>

<li>
<h4>maxWarnings</h4>
<h6>Description</h6>
<p>Number of warnings a squad leader receives before their squad is disbanded.</p>
<h6>Default</h6>
<pre><code>3</code></pre>
</li>
</ul>

<h3>Behavior</h3>
<ul>
<li>Automatically monitors squad leaders at the specified interval.</li>
<li>Warns squad leaders if they do not have the correct kit.</li>
<li>Disbands a squad after a configurable number of warnings.</li>
<li>Resets warnings if the player takes the correct kit.</li>
</ul>

<h3>Example Configuration</h3>
<pre><code>{
"plugin": "EnforceSquadLeaderKit",
"enabled": true,
"warningMessage": "You must take the Squad Leader kit, or your squad will be disbanded!",
"checkInterval": 30,
"maxWarnings": 3
}</code></pre>
</details>
<details>
<summary>FogOfWar</summary>
<h2>FogOfWar</h2>
Expand Down
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@
"channelID": "",
"color": 16761867,
"disableCBL": false
},
{
"plugin": "EnforceSquadLeaderKit",
"enabled": true,
"warningMessage": "You must take the Squad Leader kit, or your squad will be disbanded!",
"warningTimeout": 30,
"checkInterval": 30,
"maxWarnings": 10
},
{
"plugin": "FogOfWar",
Expand Down
70 changes: 70 additions & 0 deletions squad-server/plugins/enforce-squad-leader-kit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import BasePlugin from './base-plugin.js';

export default class EnforceSquadLeaderKit extends BasePlugin {
static get description() {
return 'Ensures squad leaders take the correct Squad Leader kit, warns them if they do not, and disbands the squad if they fail to comply.';
}

static get defaultEnabled() {
return true;
}

static get optionsSpecification() {
return {
warningMessage: {
required: false,
description: 'Warning message for squad leaders without the correct kit.',
default: 'You must take the Squad Leader kit, or your squad will be disbanded!'
},
checkInterval: {
required: false,
description: 'Interval (in seconds) to check all squad leaders.',
default: 30
},
maxWarnings: {
required: false,
description: 'Number of warnings before disbanding the squad.',
default: 3
}
};
}

constructor(server, options, connectors) {
super(server, options, connectors);
this.warningCounts = {};
this.checkSquadLeaders = this.checkSquadLeaders.bind(this);
}

async mount() {
this.checkInterval = setInterval(this.checkSquadLeaders, this.options.checkInterval * 1000);
}

async unmount() {
clearInterval(this.checkInterval);
}

async checkSquadLeaders() {
for (const player of this.server.players) {
if (player.isLeader) {
if (!player.role.includes('SL')) {
this.issueWarning(player);
} else if (this.warningCounts[player.steamID]) {
this.server.rcon.warn(player.steamID, "Thank you for taking the correct kit!");
this.warningCounts[player.steamID] = 0;
}
}
}
}

async issueWarning(player) {
const warnings = this.warningCounts[player.steamID] || 0;
this.warningCounts[player.steamID] = warnings + 1;

this.server.rcon.warn(player.steamID, `${this.options.warningMessage} (${warnings + 1}/${this.options.maxWarnings})`);

if (this.warningCounts[player.steamID] >= this.options.maxWarnings) {
this.server.rcon.execute(`AdminDisbandSquad ${player.teamID} ${player.squadID}`);
this.warningCounts[player.steamID] = 0;
}
}
}