// ReservedSlots: priority access when the server is nearly full. The last few slots (2 by default) are kept for the // players with the permission reservedslots.use (the vip group, and admins): when only reserved slots are left, anyone // else is refused with a message and can try again later. s&box has no waiting line on connection, so this is how a // "priority queue" works here: VIPs always find a slot, the others wait for one to free up. // Settings: plugins/config/ReservedSlots.json. Who is VIP: rl_perm add vip, or /group with Groups.cs. // Install: copy this file into the server's data folder, plugins/ReservedSlots.cs. // Script engine rules: test objects with != null, no static fields that change, callbacks with one parameter at most. using RustLegacy; public class ReservedSlotsConfig { /// Slots kept for players with reservedslots.use. public int Reserved { get; set; } = 2; public string Message { get; set; } = "The server is full for now: its last slots are reserved for VIP players. Try again in a few minutes."; } public class ReservedSlotsData { /// The vip group got reservedslots.use once: the server owner can take it back, it is not given again. public bool DefaultsGranted { get; set; } } public class ReservedSlots : RustPlugin { ReservedSlotsConfig _config; public override void OnLoaded() { _config = LoadConfig(); RegisterPermission( "reservedslots.use" ); var data = LoadData(); if ( !data.DefaultsGranted ) { CreateGroup( "vip" ); GrantPermission( "vip", "reservedslots.use" ); data.DefaultsGranted = true; SaveData( data ); } AddCommand( "slots", cmd => Reply( cmd.Player, Status() ), "Free and reserved slots" ); } string Status() => $"{PlayerCount}/{MaxPlayers} players, {_config.Reserved} slots reserved for VIP."; public override string CanConnect( PluginConnection c ) { if ( c.IsAdmin || HasPermission( c.SteamId, "reservedslots.use" ) ) return null; if ( PlayerCount < MaxPlayers - _config.Reserved ) return null; Puts( $"refused {c.Name} ({c.SteamId}): {Status()}" ); return _config.Message; } }