Skip to content

Commit 98f8ab4

Browse files
committed
added toggle command
1 parent dbb69c4 commit 98f8ab4

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

CommandHandlerToggle.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Smod2.Commands;
2+
3+
namespace LaterJoin
4+
{
5+
class CommandHandlerToggle : ICommandHandler
6+
{
7+
private Main plugin;
8+
9+
public CommandHandlerToggle(Main plugin)
10+
{
11+
this.plugin = plugin;
12+
}
13+
14+
public string GetCommandDescription()
15+
{
16+
return "toggles the late join feature.";
17+
}
18+
19+
public string GetUsage()
20+
{
21+
return "(NO ARGUMENTS)";
22+
}
23+
24+
public string[] OnCall(ICommandSender sender, string[] args)
25+
{
26+
if (plugin.LJenabled == false)
27+
{
28+
plugin.LJenabled = true;
29+
return new string[] { "Late Joins Toggled On!" };
30+
}
31+
else
32+
{
33+
plugin.LJenabled = false;
34+
return new string[] { "Late Joins Toggled Off!" };
35+
}
36+
}
37+
}
38+
}

EventHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,13 @@ private string spawnPlayer(Player player)
232232

233233
public void OnPlayerJoin(PlayerJoinEvent ev)
234234
{
235-
if (roundstarted && ((time >= PluginManager.Manager.Server.Round.Duration) || time == -1) && (!blacklist.Contains(ev.Player.SteamId)) && (ev.Player.TeamRole.Team == Smod2.API.Team.NONE || ev.Player.TeamRole.Team == Smod2.API.Team.SPECTATOR))
235+
if (plugin.LJenabled)
236236
{
237-
plugin.Info("Player " + RemoveSpecialCharacters(ev.Player.Name) + " joined late! Setting their class to " + spawnPlayer(ev.Player));
238-
blacklist.Add(ev.Player.SteamId);
237+
if (roundstarted && ((time >= PluginManager.Manager.Server.Round.Duration) || time == -1) && (!blacklist.Contains(ev.Player.SteamId)) && (ev.Player.TeamRole.Team == Smod2.API.Team.NONE || ev.Player.TeamRole.Team == Smod2.API.Team.SPECTATOR))
238+
{
239+
plugin.Info("Player " + RemoveSpecialCharacters(ev.Player.Name) + " joined late! Setting their class to " + spawnPlayer(ev.Player));
240+
blacklist.Add(ev.Player.SteamId);
241+
}
239242
}
240243
}
241244

Main.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ namespace LaterJoin
88
name = "LaterJoin",
99
description = "Allow those who join just after round start to spawn",
1010
id = "rex.laterjoin",
11-
version = "1.1.15",
11+
version = "1.1.16",
1212
SmodMajor = 3,
1313
SmodMinor = 2,
1414
SmodRevision = 0
1515
)]
1616
class Main : Plugin
1717
{
1818
public bool infAutoRespawn = false;
19+
public bool LJenabled = true;
1920

2021
public override void OnDisable()
2122
{
@@ -62,6 +63,7 @@ public override void Register()
6263
// Register Events
6364
this.AddEventHandlers(new EventHandler(this));
6465
this.AddCommands(new string[] { "lj_deathmatch" }, new CommandHandlerDeathmatch(this));
66+
this.AddCommands(new string[] { "lj_toggle" }, new CommandHandlerToggle(this));
6567

6668
this.AddConfig(new Smod2.Config.ConfigSetting("lj_time", 30, Smod2.Config.SettingType.NUMERIC, true, ""));
6769
this.AddConfig(new Smod2.Config.ConfigSetting("lj_FillerTeamQueue", new int[] {}, Smod2.Config.SettingType.NUMERIC_LIST, true, ""));

0 commit comments

Comments
 (0)