Add Votekick functionality (#32005)
This commit is contained in:
@@ -1404,7 +1404,6 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<float> VoteSameTypeTimeout =
|
||||
CVarDef.Create("vote.same_type_timeout", 240f, CVar.SERVERONLY);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the duration of the map vote timer.
|
||||
/// </summary>
|
||||
@@ -1429,6 +1428,87 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<int>
|
||||
VoteTimerAlone = CVarDef.Create("vote.timeralone", 10, CVar.SERVERONLY);
|
||||
|
||||
/*
|
||||
* VOTEKICK
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Allows enabling/disabling player-started votekick for ultimate authority
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> VotekickEnabled =
|
||||
CVarDef.Create("votekick.enabled", true, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Config for when the votekick should be allowed to be called based on number of eligible voters.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> VotekickEligibleNumberRequirement =
|
||||
CVarDef.Create("votekick.eligible_number", 10, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Whether a votekick initiator must be a ghost or not.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> VotekickInitiatorGhostRequirement =
|
||||
CVarDef.Create("votekick.initiator_ghost_requirement", true, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Whether a votekick voter must be a ghost or not.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> VotekickVoterGhostRequirement =
|
||||
CVarDef.Create("votekick.voter_ghost_requirement", true, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Config for how many hours playtime a player must have to be able to vote on a votekick.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> VotekickEligibleVoterPlaytime =
|
||||
CVarDef.Create("votekick.voter_playtime", 100, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Config for how many seconds a player must have been dead to initiate a votekick / be able to vote on a votekick.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> VotekickEligibleVoterDeathtime =
|
||||
CVarDef.Create("votekick.voter_deathtime", 180, CVar.REPLICATED | CVar.SERVER);
|
||||
|
||||
/// <summary>
|
||||
/// The required ratio of eligible voters that must agree for a votekick to go through.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> VotekickRequiredRatio =
|
||||
CVarDef.Create("votekick.required_ratio", 0.6f, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to prevent the votekick from having any effect when there is an online admin.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> VotekickNotAllowedWhenAdminOnline =
|
||||
CVarDef.Create("votekick.not_allowed_when_admin_online", true, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// The delay for which two votekicks are allowed to be made by separate people, in seconds.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> VotekickTimeout =
|
||||
CVarDef.Create("votekick.timeout", 120f, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the duration of the votekick vote timer.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int>
|
||||
VotekickTimer = CVarDef.Create("votekick.timer", 60, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Config for how many hours playtime a player must have to get protection from the Raider votekick type when playing as an antag.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> VotekickAntagRaiderProtection =
|
||||
CVarDef.Create("votekick.antag_raider_protection", 10, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Default severity for votekick bans
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> VotekickBanDefaultSeverity =
|
||||
CVarDef.Create("votekick.ban_default_severity", "High", CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Duration of a ban caused by a votekick (in minutes).
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> VotekickBanDuration =
|
||||
CVarDef.Create("votekick.ban_duration", 180, CVar.SERVERONLY);
|
||||
|
||||
/*
|
||||
* BAN
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Lidgren.Network;
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Content.Shared.Voting
|
||||
public (ushort votes, string name)[] Options = default!;
|
||||
public bool IsYourVoteDirty;
|
||||
public byte? YourVote;
|
||||
public bool DisplayVotes;
|
||||
public int TargetEntity;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
||||
{
|
||||
@@ -31,6 +33,8 @@ namespace Content.Shared.Voting
|
||||
VoteInitiator = buffer.ReadString();
|
||||
StartTime = TimeSpan.FromTicks(buffer.ReadInt64());
|
||||
EndTime = TimeSpan.FromTicks(buffer.ReadInt64());
|
||||
DisplayVotes = buffer.ReadBoolean();
|
||||
TargetEntity = buffer.ReadVariableInt32();
|
||||
|
||||
Options = new (ushort votes, string name)[buffer.ReadByte()];
|
||||
for (var i = 0; i < Options.Length; i++)
|
||||
@@ -58,6 +62,8 @@ namespace Content.Shared.Voting
|
||||
buffer.Write(VoteInitiator);
|
||||
buffer.Write(StartTime.Ticks);
|
||||
buffer.Write(EndTime.Ticks);
|
||||
buffer.Write(DisplayVotes);
|
||||
buffer.WriteVariableInt32(TargetEntity);
|
||||
|
||||
buffer.Write((byte) Options.Length);
|
||||
foreach (var (votes, name) in Options)
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
namespace Content.Shared.Voting
|
||||
namespace Content.Shared.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// Standard vote types that players can initiate themselves from the escape menu.
|
||||
/// </summary>
|
||||
public enum StandardVoteType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard vote types that players can initiate themselves from the escape menu.
|
||||
/// Vote to restart the round.
|
||||
/// </summary>
|
||||
public enum StandardVoteType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Vote to restart the round.
|
||||
/// </summary>
|
||||
Restart,
|
||||
Restart,
|
||||
|
||||
/// <summary>
|
||||
/// Vote to change the game preset for next round.
|
||||
/// </summary>
|
||||
Preset,
|
||||
/// <summary>
|
||||
/// Vote to change the game preset for next round.
|
||||
/// </summary>
|
||||
Preset,
|
||||
|
||||
/// <summary>
|
||||
/// Vote to change the map for the next round.
|
||||
/// </summary>
|
||||
Map
|
||||
}
|
||||
/// <summary>
|
||||
/// Vote to change the map for the next round.
|
||||
/// </summary>
|
||||
Map,
|
||||
|
||||
/// <summary>
|
||||
/// Vote to kick a player.
|
||||
/// </summary>
|
||||
Votekick
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reasons available to initiate a votekick.
|
||||
/// </summary>
|
||||
public enum VotekickReasonType : byte
|
||||
{
|
||||
Raiding,
|
||||
Cheating,
|
||||
Spam
|
||||
}
|
||||
|
||||
30
Content.Shared/Voting/VotingEvents.cs
Normal file
30
Content.Shared/Voting/VotingEvents.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Voting;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VotePlayerListRequestEvent : EntityEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VotePlayerListResponseEvent : EntityEventArgs
|
||||
{
|
||||
public VotePlayerListResponseEvent((NetUserId, NetEntity, string)[] players, bool denied)
|
||||
{
|
||||
Players = players;
|
||||
Denied = denied;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The players available to have a votekick started for them.
|
||||
/// </summary>
|
||||
public (NetUserId, NetEntity, string)[] Players { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server will allow the user to start a votekick or not.
|
||||
/// </summary>
|
||||
public bool Denied;
|
||||
}
|
||||
Reference in New Issue
Block a user