Skip to content

Commit

Permalink
implement warden mute
Browse files Browse the repository at this point in the history
  • Loading branch information
destoer committed May 2, 2024
1 parent 3c55faa commit b395096
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 28 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For further config and feature info please see the wiki

https://github.com/destoer/Cs2Jailbreak/wiki

also please see https://github.com/destoer/JailServiceTest for example API usage

# Installation
Download the latest release from the releases tab and copy it into the counterstrikesharp plugin folder

Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"warden.swap_guard_cmd": "swap_guard",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.mute_cmd": "wm",
"warden.force_open_cmd": "force_open",
"warden.force_close_cmd": "force_close",
"warden.sd_cmd": "wsd",
Expand Down
1 change: 1 addition & 0 deletions lang/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"warden.swap_guard_cmd": "swap_guard",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.mute_cmd": "wm",
"warden.force_open_cmd": "force_open",
"warden.force_close_cmd": "force_close",
"warden.sd_cmd": "wsd",
Expand Down
1 change: 1 addition & 0 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"warden.swap_guard_cmd": "swap_guard",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.mute_cmd": "wm",
"warden.force_open_cmd": "force_open",
"warden.force_close_cmd": "force_close",
"warden.sd_cmd": "wsd",
Expand Down
1 change: 1 addition & 0 deletions lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"warden.swap_guard_cmd": "swap_guard",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.mute_cmd": "wm",
"warden.force_open_cmd": "force_open",
"warden.force_close_cmd": "force_close",
"warden.sd_cmd": "wsd",
Expand Down
1 change: 1 addition & 0 deletions lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"warden.swap_guard_cmd": "ct_al",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.mute_cmd": "wm",
"warden.force_open_cmd": "zorla_ac",
"warden.force_close_cmd": "zorla_kapat",
"warden.sd_cmd": "komutcu_ozelgun",
Expand Down
2 changes: 2 additions & 0 deletions src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ void RegisterCommands()
AddLocalizedCmd("warden.countdown_cmd","start a countdown",warden.CountdownCmd);
AddLocalizedCmd("warden.countdown_abort_cmd","abort a countdown",warden.CountdownAbortCmd);

AddLocalizedCmd("warden.mute_cmd","do a warden mute",warden.WardenMuteCmd);

// reg lr commands
AddLocalizedCmd("lr.start_lr_cmd","start an lr",lr.LRCmd);
AddLocalizedCmd("lr.cancel_lr_cmd","admin : cancel lr",lr.CancelLRCmd);
Expand Down
7 changes: 5 additions & 2 deletions src/Lib/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ static public void KillTimer(ref CSTimer.Timer? timer)
}
}

static public void UnMuteAll()
static public void UnMuteAll(bool roundEnd = false)
{
foreach(CCSPlayerController player in Lib.GetPlayers())
{
player.UnMute();
if(player.IsLegalAlive() || roundEnd)
{
player.UnMute();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ static public bool IsConnected([NotNullWhen(true)] this CCSPlayerController? pla
return player.IsLegal() && player.Connected == PlayerConnectedState.PlayerConnected;
}

static public bool IsT(this CCSPlayerController? player)
static public bool IsT([NotNullWhen(true)] this CCSPlayerController? player)
{
return IsLegal(player) && player.TeamNum == TEAM_T;
}

static public bool IsCt(this CCSPlayerController? player)
static public bool IsCt([NotNullWhen(true)] this CCSPlayerController? player)
{
return IsLegal(player) && player.TeamNum == TEAM_CT;
}
Expand Down
49 changes: 28 additions & 21 deletions src/SpecialDay/Zombie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,33 @@ public void SetupZombie(CCSPlayerController player)
player.GiveArmour();
}

public void TeleportZombie(CCSPlayerController player)
{
//player.PrintToChat("TP!");

// respawn them on their death cordinates
if(deathCount[player.Slot] == 1)
{
player.Teleport(deathCord[player.Slot],Lib.ANGLE_ZERO,Lib.VEC_ZERO);
}

// teleport player to patient zero
else
{
var patientZero = Utilities.GetPlayerFromSlot(bossSlot);

if(patientZero.IsLegalAlive())
{
var pawn = patientZero.Pawn();

if(pawn != null && pawn.AbsOrigin != null)
{
player.Teleport(pawn.AbsOrigin,Lib.ANGLE_ZERO,Lib.VEC_ZERO);
}
}
}
}

public override void SetupPlayer(CCSPlayerController player)
{
if(player.IsCt())
Expand All @@ -217,27 +244,7 @@ public override void SetupPlayer(CCSPlayerController player)
player.SetHealth(250);
}

// respawn them on their death cordinates
if(deathCount[player.Slot] == 1)
{
player.Teleport(deathCord[player.Slot],Lib.ANGLE_ZERO,Lib.VEC_ZERO);
}

// teleport player to patient zero
else
{
var patientZero = Utilities.GetPlayerFromSlot(bossSlot);

if(patientZero.IsLegalAlive())
{
var pawn = patientZero.Pawn();

if(pawn != null && pawn.AbsOrigin != null)
{
player.Teleport(pawn.AbsOrigin,Lib.ANGLE_ZERO,Lib.VEC_ZERO);
}
}
}
TeleportZombie(player);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Warden/JailPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ public void PurgeRound()
public void Reset()
{
PurgeRound();

laserColour = Lib.CYAN;
markerColour = Lib.CYAN;
ctGun = "M4";
Expand Down Expand Up @@ -354,7 +353,7 @@ public void PlayerHurt(CCSPlayerController? player, CCSPlayerController? attacke
// log any ct damage
else if (attacker.IsCt())
{
//Lib.PrintConsoleAll($"CT {attacker.PlayerName} hit {player.PlayerName} for {damage}");
Chat.PrintConsoleAll($"CT {attacker.PlayerName} hit {player.PlayerName} for {damage}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Warden/Mute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void RoundEnd()
{
Lib.KillTimer(ref muteTimer);

Lib.UnMuteAll();
Lib.UnMuteAll(true);
}

public void Connect(CCSPlayerController? player)
Expand Down
3 changes: 3 additions & 0 deletions src/Warden/Warden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public void SetupPlayerGuns(CCSPlayerController? player)

Countdown<int> chatCountdown = new Countdown<int>();

CSTimer.Timer? tmpMuteTimer = null;
long tmpMuteTimestamp = 0;

const int INAVLID_SLOT = -3;

int wardenSlot = INAVLID_SLOT;
Expand Down
51 changes: 51 additions & 0 deletions src/Warden/WardenCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,57 @@ public bool IsAliveRebel(CCSPlayerController? player)
return false;
}

public void WardenMuteCmd(CCSPlayerController? invoke, CommandInfo cmd)
{
// make sure we are actually the warden
if(!IsWarden(invoke))
{
invoke.Announce(WARDEN_PREFIX,"you must be warden to use a warden mute");
return;
}

if(tmpMuteTimer != null)
{
invoke.Announce(WARDEN_PREFIX,"mute is already active");
return;
}

long remain = 60 - (Lib.CurTimestamp() - tmpMuteTimestamp);

// make sure we cant spam this
if(remain > 0)
{
invoke.Announce(WARDEN_PREFIX,$"Warden mute cannot be used for another {remain} seconds");
return;
}

// mute everyone that isnt the warden
foreach(CCSPlayerController player in Lib.GetAlivePlayers())
{
if(!IsWarden(player))
{
player.Mute();
}
}

Chat.Announce(WARDEN_PREFIX,"everyone apart from the warden is muted for 10 seconds!");

tmpMuteTimer = JailPlugin.globalCtx.AddTimer(10.0f,UnmuteTmp,CSTimer.TimerFlags.STOP_ON_MAPCHANGE);
}


public void UnmuteTmp()
{
Chat.Announce(WARDEN_PREFIX,"warden mute is now over!");

Lib.UnMuteAll();
tmpMuteTimer = null;

// re grab the timestmap for the cooldown
tmpMuteTimestamp = Lib.CurTimestamp();
}


public void GiveT(CCSPlayerController? invoke, String name, Action<CCSPlayerController, ChatMenuOption> callback,Func<CCSPlayerController?,bool> filter)
{
if(!IsWarden(invoke))
Expand Down

0 comments on commit b395096

Please sign in to comment.