Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Nov 1, 2024
1 parent 9f38509 commit 8e9b2c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mod/Jailbreak.LastGuard/LastGuard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public HookResult OnPlayerDeathEvent(EventPlayerDeath @event,
var player = @event.Userid;
if (player == null) return HookResult.Continue;

Server.NextFrame(() => checkLastGuard(@event.Userid));
checkLastGuard(@event.Userid);

if (!IsLastGuardActive) return HookResult.Continue;

Expand Down
12 changes: 2 additions & 10 deletions mod/Jailbreak.Warden/Global/WardenBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public bool TryRemoveWarden(bool isPass = false) {

logs.Append(logs.Player(Warden), "is no longer the warden.");

if (!isPass && false) {
if (!isPass) {
var stats = API.Gangs?.Services.GetService<IPlayerStatManager>();
if (stats != null) {
var wrapper = new PlayerWrapper(Warden);
Expand Down Expand Up @@ -296,29 +296,21 @@ private async Task updateWardenDeathStats(PlayerWrapper player) {

[GameEventHandler]
public HookResult OnDeath(EventPlayerDeath ev, GameEventInfo info) {
return HookResult.Continue;
var player = ev.Userid;
if (player == null || !player.IsValid) return HookResult.Continue;
var isWarden = ((IWardenService)this).IsWarden(player);
if (API.Gangs != null && false) {
Server.PrintToConsole("WardenBehavior: OnDeath");
if (API.Gangs != null) {
if (ev.Attacker != null && ev.Attacker.IsValid && ev.Attacker != player
&& isWarden) {
Server.PrintToConsole("WardenBehavior: OnDeath: Attacker is valid");
var wrapper = new PlayerWrapper(ev.Attacker);
Task.Run(async () => await incrementWardenKills(wrapper));
}

Server.PrintToConsole(
"WardenBehavior: OnDeath: Updating guard death stats");
foreach (var guard in PlayerUtil.FromTeam(CsTeam.CounterTerrorist)) {
Server.PrintToConsole($"WardenBehavior: OnDeath: Guard: {guard}");
var wrapper = new PlayerWrapper(guard);
// If the guard is the warden, update all guards' stats
// If the guard is not the warden, only update the warden's stats
if (guard.SteamID == player.SteamID != isWarden) continue;
Server.PrintToConsole(
$"WardenBehavior: OnDeath: Guard: {guard} is the warden");
Task.Run(async () => await updateGuardDeathStats(wrapper, isWarden));
}
}
Expand Down

0 comments on commit 8e9b2c3

Please sign in to comment.