Skip to content

Commit

Permalink
Merge pull request #27 from destoer/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
destoer authored Mar 3, 2024
2 parents 2bc1973 + b788852 commit afdec76
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 7 deletions.
7 changes: 7 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
"warden.give_pardon": "{0} has been pardoned",
"warden.give_freeday": "{0} has been given a freeday",

"warden.countdown_cmd": "countdown",
"warden.countdown_abort_cmd": "countdown_abort",
"warden.countdown_usage": "!countdown: <time> <msg>",
"warden.countdown_restrict": "You must be the warden to call a countdown",
"warden.countdown_abort": "Warden aborted the countdown",


"logs.ct": "CT",
"logs.t": "T",
"logs.logs_cmd": "logs",
Expand Down
5 changes: 4 additions & 1 deletion src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ void RegisterCommands()
AddLocalizedCmd("warden.fire_guard_cmd","admin : Remove all guards apart from warden",warden.FireGuardCmd);

AddLocalizedCmd("warden.give_freeday_cmd","give t a freeday",warden.GiveFreedayCmd);
AddLocalizedCmd("warden.give_pardon_cmd","give t a freeday",warden.GivePardonCmd);
AddLocalizedCmd("warden.give_pardon_cmd","give t a pardon",warden.GivePardonCmd);

AddLocalizedCmd("warden.countdown_cmd","start a countdown",warden.CountdownCmd);
AddLocalizedCmd("warden.countdown_abort_cmd","abort a countdown",warden.CountdownAbortCmd);

// reg lr commands
AddLocalizedCmd("lr.start_lr_cmd","start an lr",lr.LRCmd);
Expand Down
2 changes: 1 addition & 1 deletion src/LastRequest/LRBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void CountdownStart()
}
}

countdown.Start(lrName,5,this,PrintCountdown,manager.ActivateLR);
countdown.Start($"{lrName} starts in",5,this,PrintCountdown,manager.ActivateLR);
}

public void FailSafeActivate()
Expand Down
4 changes: 2 additions & 2 deletions src/LastRequest/ShotForShot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public override void InitPlayer(CCSPlayerController player)

}

// override to 1 if mag for mag
if(magForMag)
// override to 1 if shot for shot
if(!magForMag)
{
clipSize = 1;
}
Expand Down
9 changes: 7 additions & 2 deletions src/Lib/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class Countdown<T>
{
public void Start(String countdownName, int countdownDelay,
T countdownData,Action<T,int>? countdownPrintFunc, Action <T> countdownCallback)
T countdownData,Action<T,int>? countdownPrintFunc, Action <T>? countdownCallback)
{
this.delay = countdownDelay;
this.callback = countdownCallback;
Expand Down Expand Up @@ -59,6 +59,11 @@ void Tick()
{
callback(data);
}

else
{
Chat.PrintCentreAll("Countdown over");
}
}

// countdown still active
Expand All @@ -73,7 +78,7 @@ void Tick()
// default print
else
{
Chat.PrintCentreAll($"{name} is starting in {delay} seconds");
Chat.PrintCentreAll($"{name}: {delay}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SpecialDay/SpecialDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void SetupSD(CCSPlayerController? invoke, ChatMenuOption option)
activeSD.SetupCommon();

// start the countdown for enable
countdown.Start($"{name} specialday",delay,0,null,StartSD);
countdown.Start($"{name} starts in",delay,0,null,StartSD);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Warden/Warden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ public void SetupPlayerGuns(CCSPlayerController? player)
return jailPlayers[player.Slot];
}

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

const int INAVLID_SLOT = -3;

int wardenSlot = INAVLID_SLOT;
Expand Down
66 changes: 66 additions & 0 deletions src/Warden/WardenCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,70 @@ public void WardayCmd(CCSPlayerController? player, CommandInfo command)
}


public void CountdownCmd(CCSPlayerController? player, CommandInfo command)
{
if(!player.IsLegal())
{
return;
}

// must be warden
if(!IsWarden(player))
{
player.LocalizePrefix(WARDEN_PREFIX,"warden.countdown_restrict");
return;
}

// must specify location
if(command.ArgCount < 2)
{
player.LocalizePrefix(WARDEN_PREFIX,"warden.countdown_usage");
return;
}

// attempt the start the warday
String str = command.ArgByIndex(2);

// attempt to parse optional delay
int delay = 20;

if(command.ArgCount >= 3)
{
if(Int32.TryParse(command.ArgByIndex(1),out int delayOpt))
{
delay = delayOpt;
}

else
{
player.LocalizePrefix(WARDEN_PREFIX,"warden.countdown_usage");
return;
}
}

chatCountdown.Start(str,delay,0,null,null);
}


public void CountdownAbortCmd(CCSPlayerController? player, CommandInfo command)
{
if(!player.IsLegal())
{
return;
}

// must be warden
if(!IsWarden(player))
{
player.LocalizePrefix(WARDEN_PREFIX,"warden.countdown_restrict");
return;
}

Chat.LocalizeAnnounce(WARDEN_PREFIX,"warden.countdown_abort");

chatCountdown.Kill();
}

(JailPlayer?, CCSPlayerController?) GiveTInternal(CCSPlayerController? invoke, String name, String playerName)
{
if(!IsWarden(invoke))
Expand Down Expand Up @@ -409,4 +473,6 @@ public void CmdCtGuns(CCSPlayerController? player, CommandInfo command)
player.GunMenuInternal(true,CtGuns);
}



}

0 comments on commit afdec76

Please sign in to comment.