diff --git a/lang/en.json b/lang/en.json index f19d112..19ffc57 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,4 +1,6 @@ { + "jail.kill_cmd": "{0} slayed themself", + "warden.remove": "Warden Removed", "warden.warden_command_desc": "!w - take warden", "warden.warday_command_desc": "!wd - start a warday", diff --git a/src/Jail.cs b/src/Jail.cs index 61557a8..6c593f5 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -184,7 +184,7 @@ public static void PurgePlayerStats(CCSPlayerController? player) public override string ModuleName => "CS2 Jailbreak - destoer"; - public override string ModuleVersion => "v0.3.8"; + public override string ModuleVersion => "v0.3.9"; public override void Load(bool hotReload) { @@ -265,8 +265,19 @@ void AddLocalizedCmd(String base_name,String desc,CommandInfo.CommandCallback ca AddCommand("css_" + Localizer[base_name],desc,callback); } + public static void KillCmd(CCSPlayerController? invoke, CommandInfo command) + { + if(invoke.IsLegalAlive()) + { + Chat.LocalizeAnnounce("","jail.kill_cmd",invoke.PlayerName); + invoke.Slay(); + } + } + void RegisterCommands() { + AddCommand("kill","kill self",KillCmd); + // reg warden comamnds AddLocalizedCmd("warden.take_warden_cmd", "take warden", warden.TakeWardenCmd); AddLocalizedCmd("warden.leave_warden_cmd", "leave warden", warden.LeaveWardenCmd); @@ -383,9 +394,23 @@ void RegisterHooks() AddCommandListener("jointeam",JoinTeam); AddCommandListener("player_ping",PlayerPingCmd); + AddCommandListener("say", OnPlayerChat); + // TODO: need to hook weapon drop } + + public HookResult OnPlayerChat(CCSPlayerController? invoke, CommandInfo command) + { + // dont print chat, warden is handling it + if(!warden.PlayerChat(invoke,command)) + { + return HookResult.Handled; + } + + return HookResult.Continue; + } + public HookResult PlayerPingCmd(CCSPlayerController? invoke, CommandInfo command) { // if player is not warden ignore the ping diff --git a/src/LastRequest/GunToss.cs b/src/LastRequest/GunToss.cs index ad78373..14f1ad6 100644 --- a/src/LastRequest/GunToss.cs +++ b/src/LastRequest/GunToss.cs @@ -29,6 +29,9 @@ public override void InitPlayer(CCSPlayerController player) if(deagle != null) { + // colour gun to player team! + deagle.SetColour(player.IsT()? Lib.RED : Lib.CYAN); + deagle.SetAmmo(0,0); } } diff --git a/src/LastRequest/NoScope.cs b/src/LastRequest/NoScope.cs index 917be60..0461877 100644 --- a/src/LastRequest/NoScope.cs +++ b/src/LastRequest/NoScope.cs @@ -46,6 +46,14 @@ void GiveWeapon(CCSPlayerController? player) } } + public override void WeaponFire(String name) + { + CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot); + + var weapon = player.FindWeapon(name); + weapon.SetAmmo(5,-1); + } + public override void InitPlayer(CCSPlayerController player) { GiveWeapon(player); diff --git a/src/LastRequest/War.cs b/src/LastRequest/War.cs index 03b718f..5c4bd51 100644 --- a/src/LastRequest/War.cs +++ b/src/LastRequest/War.cs @@ -26,13 +26,13 @@ public override void InitPlayer(CCSPlayerController player) player.GiveWeapon(weaponRestrict); player.SetHealth(1000); + } + public override void WeaponFire(String name) + { + CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot); - var shotgun = player.FindWeapon(weaponRestrict); - - if(shotgun != null) - { - shotgun.SetAmmo(999,999); - } + var weapon = player.FindWeapon(name); + weapon.SetAmmo(999,999); } } \ No newline at end of file diff --git a/src/Lib/Weapon.cs b/src/Lib/Weapon.cs index 3a9894b..dd0b217 100644 --- a/src/Lib/Weapon.cs +++ b/src/Lib/Weapon.cs @@ -5,14 +5,27 @@ using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Menu; using CSTimer = CounterStrikeSharp.API.Modules.Timers; +using System.Drawing; +using System.Diagnostics.CodeAnalysis; public static class Weapon { - static public bool IsLegal(this CBasePlayerWeapon? weapon) + static public bool IsLegal([NotNullWhen(true)] this CBasePlayerWeapon? weapon) { return weapon != null && weapon.IsValid; } + + static public void SetColour(this CBasePlayerWeapon? weapon, Color colour) + { + if(weapon.IsLegal()) + { + weapon.RenderMode = RenderMode_t.kRenderTransColor; + weapon.Render = colour; + Utilities.SetStateChanged(weapon,"CBaseModelEntity","m_clrRender"); + } + } + static public CBasePlayerWeapon? FindWeapon(this CCSPlayerController? player, String name) { // only care if player is alive @@ -57,7 +70,7 @@ static public bool IsLegal(this CBasePlayerWeapon? weapon) static public void SetAmmo(this CBasePlayerWeapon? weapon, int clip, int reserve) { - if(weapon == null || !weapon.IsLegal()) + if(!weapon.IsLegal()) { return; } @@ -66,15 +79,19 @@ static public void SetAmmo(this CBasePlayerWeapon? weapon, int clip, int reserve // setting "infinite ammo" // thanks 1Mack CCSWeaponBaseVData? weaponData = weapon.As().VData; - + + if(weaponData != null) { + // TODO: this overide it for every gun the player has... + // when not a map gun, this is not a big deal + // for the reserve ammo it is for the clip though + /* if(clip > weaponData.MaxClip1) { weaponData.MaxClip1 = clip; - weaponData.DefaultClip1 = clip; } - + */ if(reserve > weaponData.PrimaryReserveAmmoMax) { weaponData.PrimaryReserveAmmoMax = reserve; diff --git a/src/Warden/Team.cs b/src/Warden/Team.cs index f51273b..8b19f08 100644 --- a/src/Warden/Team.cs +++ b/src/Warden/Team.cs @@ -84,8 +84,14 @@ public bool JoinTeam(CCSPlayerController? invoke, CommandInfo command) default: { - invoke.Announce(TEAM_PREFIX,$"Invalid team swap team"); + if(!invoke.IsLegalAlive()) + { + invoke.SwitchTeam(CsTeam.Terrorist); + } + + invoke.Announce(TEAM_PREFIX,$"Invalid team swap {team}"); invoke.PlaySound("sounds/ui/counter_beep.vsnd"); + return false; } } diff --git a/src/Warden/Warden.cs b/src/Warden/Warden.cs index 7d26dca..8edb1c7 100644 --- a/src/Warden/Warden.cs +++ b/src/Warden/Warden.cs @@ -95,6 +95,24 @@ public void RemoveIfWarden(CCSPlayerController? player) } + public bool PlayerChat(CCSPlayerController? player, CommandInfo info) + { + String text = info.GetArg(1); + + if(text.StartsWith("/") || text.StartsWith("!") || String.IsNullOrWhiteSpace(text)) + { + return true; + } + + if(player.IsLegalAlive() && IsWarden(player)) + { + Server.PrintToChatAll($"{WARDEN_PREFIX} {player.PlayerName}: {text}"); + return false; + } + + return true; + } + // reset variables for a new round void PurgeRound() {