forked from RainOrigami/BattleBitBaseModules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReconOnly.cs
More file actions
77 lines (69 loc) · 2.64 KB
/
Copy pathReconOnly.cs
File metadata and controls
77 lines (69 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using BattleBitAPI.Common;
using BattleBitAPI.Server;
using BBRAPIModules;
using System.Threading.Tasks;
//
// Author: mocfunky
// Module: ReconOnly
// Version: 1.2
// Module for BattleBit Modular API
//
namespace ReconOnly
{
[Module("This module forces players to become the Recon (Sniper) role.", "1.3")]
public class ReconOnly : BattleBitModule
{
// Allow players to select Recon even without being in a squad.
public override Task OnPlayerConnected(RunnerPlayer player)
{
player.SetNewRole(GameRole.Recon);
return Task.CompletedTask;
}
// Deny players from changing roles to anything but Recon.
public override async Task<bool> OnPlayerRequestingToChangeRole(RunnerPlayer player, GameRole requestedRole)
{
return GameRole.Recon == requestedRole;
}
// Switch the player's role to Recon when they leave or are kicked from a squad.
public override Task OnPlayerLeftSquad(RunnerPlayer player, Squad<RunnerPlayer> squad)
{
player.SetNewRole(GameRole.Recon);
return Task.CompletedTask;
}
// Switch the player's role to Recon when they join or create a squad.
public override Task OnPlayerJoinedSquad(RunnerPlayer player, Squad<RunnerPlayer> squad)
{
player.SetNewRole(GameRole.Recon);
return Task.CompletedTask;
}
// Disable spawning if not Recon.
public override async Task<OnPlayerSpawnArguments?> OnPlayerSpawning(RunnerPlayer player, OnPlayerSpawnArguments request)
{
// Check if the player is in the Recon role
if (player.Role != GameRole.Recon)
{
// Deny spawning for players who are not in the Recon role
return null;
}
// Allow spawning for players in the Recon role
return request;
}
// Customize server settings.
public override Task OnConnected()
{
this.Server.ServerSettings.SquadRequiredToChangeRole = false;
this.Server.ServerSettings.CanVoteDay = true;
this.Server.ServerSettings.CanVoteNight = false;
return Task.CompletedTask;
}
//
// Sets tickets to 2000 on round start. (Since recons are slow at killing)
//
public override Task OnRoundStarted()
{
this.Server.RoundSettings.TeamATickets = 2000;
this.Server.RoundSettings.TeamBTickets = 2000;
return Task.CompletedTask;
}
}
}