Skip to content

Commit

Permalink
Merge pull request #16 from destoer/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
destoer authored Feb 8, 2024
2 parents f916793 + 57db5be commit 98a20f9
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Cs2Jailbreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.141" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.163" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.1" />
<PackageReference Include="MySqlConnector" Version="2.3.1" />
</ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ Download the latest release from the releases tab and copy it into the counterst

NOTE: this plugin only operates correctly on linux

windows has a couple of places where a !is_windows() check wraps buggy code
windows has a couple of places where a !IsWindows() check wraps buggy code
namely OnTakeDamage

# Warden TODO
Warden Laser and T laser
T laser

Auto unstuck

Handicap

Warden Ring

Refactor stat API

# LR TODO
Port crash, sumo

Expand All @@ -40,7 +39,7 @@ Add beacons


# SD TODO
Waiting on player colour and respawn issues fixed for these
Waiting on no block issues being fixed, and trace for laser wars

Zombie, Gun game, Laser wars

Expand Down
8 changes: 1 addition & 7 deletions gamedata/Cs2Jailbreak.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"CBasePlayerController_SetPawn": {
"signatures": {
"library": "server",
"windows": "\\x44\\x88\\x4C\\x24\\x2A\\x55\\x57",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x89\\xF3\\x48\\x81\\xEC\\xC8\\x00\\x00\\x00"
}
}

}
10 changes: 9 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"warden.give_freeday_cmd": "give_freeday",
"warden.give_pardon_cmd": "give_pardon",
"warden.colour_cmd": "colour",
"warden.warden_prefix": "{green}[Warden]: {white}",
"warden.door_prefix": "{green}[Door]: {white}",
"warden.team_prefix": "{green}[Team]: {white}",

"warden.give_pardon": "{0} has been pardoned",
"warden.give_freeday": "{0} has been given a freeday",
Expand All @@ -78,11 +81,14 @@
"mute.thirty": "All t's are muted for the first 30 seconds",
"mute.speak_quietly": "T's may now speak quietly",
"mute.end_round": "You are muted until the end of the round",
"mute.mute_prefix": "{green}[Mute]: {white}",

"warday.live": "Weapons live!",
"warday.location": "warday at {0}",
"warday.warday_prefix": "{green}[Warday]: {white}",

"rebel.kill": "{0} killed the rebel {1}",
"rebel.rebel_prefix": "{green}[Rebel]: {white}",

"block.enable": "Block enabled",
"block.disable": "Block disabled",
Expand Down Expand Up @@ -118,6 +124,7 @@
"sd.start_cmd": "sd",
"sd.start_ff_cmd": "sd_ff",
"sd.cancel_cmd": "sd_cancel",
"sd.sd_prefix": "{green}[Special Day]: {white}",


"lr.rebel_last": "You must be the last player alive to rebel",
Expand All @@ -137,5 +144,6 @@

"lr.cancel_lr_cmd": "cancel_lr",
"lr.start_lr_cmd": "lr",
"lr.stats_cmd": "lr_stats"
"lr.stats_cmd": "lr_stats",
"lr.lr_prefix": "{green}[LR]: {white}"
}
55 changes: 22 additions & 33 deletions src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class JailConfig : BasePluginConfig

// main plugin file, controls central hooking
// defers to warden, lr and sd
[MinimumApiVersion(141)]
[MinimumApiVersion(163)]
public class JailPlugin : BasePlugin, IPluginConfig<JailConfig>
{
// Global event settings, used to filter plugin activits
Expand Down Expand Up @@ -184,7 +184,7 @@ public static void PurgePlayerStats(CCSPlayerController? player)

public override string ModuleName => "CS2 Jailbreak - destoer";

public override string ModuleVersion => "v0.3.5";
public override string ModuleVersion => "v0.3.6";

public override void Load(bool hotReload)
{
Expand All @@ -197,6 +197,8 @@ public override void Load(bool hotReload)

RegisterListeners();

LocalizePrefix();

JailPlayer.SetupDB();

Console.WriteLine("Sucessfully started JB");
Expand All @@ -205,6 +207,21 @@ public override void Load(bool hotReload)

}

void LocalizePrefix()
{
LastRequest.LR_PREFIX = Chat.Localize("lr.lr_prefix");
Entity.DOOR_PREFIX = Chat.Localize("warden.door_prefix");

SpecialDay.SPECIALDAY_PREFIX = Chat.Localize("sd.sd_prefix");
JailPlayer.REBEL_PREFIX = Chat.Localize("rebel.rebel_prefix");

Mute.MUTE_PREFIX = Chat.Localize("mute.mute_prefix");
Warden.TEAM_PREFIX = Chat.Localize("warden.team_prefix");

Warday.WARDAY_PREFIX = Chat.Localize("warday.warday_prefix");
Warden.WARDEN_PREFIX = Chat.Localize("warden.warden_prefix");
}

void StatDBReload()
{
Task.Run(async () =>
Expand Down Expand Up @@ -524,48 +541,20 @@ HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
CCSPlayerController? killer = @event.Attacker;

// NOTE: have to check IsConnected incase this is tripped by a dc

// hide t killing ct
if(Config.hideKills && victim.IsConnected() && killer.IsConnected() && killer.IsT() && victim.IsCt())
{
//@event.Attacker = player;
// fire event as is to T
foreach(CCSPlayerController? player in Utilities.GetPlayers())
{
if(player.IsLegal())
{
if(player.IsT())
{
// T gets full event
@event.Userid = victim;
@event.Attacker = killer;

@event.FireEventToClient(player);
}

else
{
// ct gets a suicide
@event.Userid = victim;
@event.Attacker = victim;
@event.Assister = victim;

@event.FireEventToClient(player);
}
}
}

killer.Announce(Warden.WARDEN_PREFIX,$"You killed: {victim.PlayerName}");
info.DontBroadcast = true;
}



if(victim.IsLegal() && victim.IsConnected())
{
warden.Death(victim,killer);
lr.Death(victim);
sd.Death(victim,killer);
}

return HookResult.Continue;
}

Expand Down
18 changes: 17 additions & 1 deletion src/LastRequest/Dodgeball.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public override void InitPlayer(CCSPlayerController player)
}
}

public override void PairActivate()
{
DelayFailSafe(35.0f);
}

public override void PlayerHurt(int damage, int health, int hitgroup)
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
Expand All @@ -59,7 +64,18 @@ public override void PlayerHurt(int damage, int health, int hitgroup)
public override void GrenadeThrown()
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
GiveLRNadeDelay(1.4f,"weapon_flashbang");

if(!failSafe)
{
GiveLRNadeDelay(1.4f,"weapon_flashbang");
}

// failsafe timer is up give a he grenade
else
{
weaponRestrict = "hegrenade";
GiveLRNadeDelay(1.4f,"weapon_hegrenade");
}
}

public override void EntCreated(CEntityInstance entity)
Expand Down
18 changes: 18 additions & 0 deletions src/LastRequest/Grenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,25 @@ public override void InitPlayer(CCSPlayerController player)
}
}
}

public override void PairActivate()
{
DelayFailSafe(35.0f);
}


public override void PlayerHurt(int damage, int health, int hitgroup)
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);

// instantly drop the player if the failsafe is active
if(player.IsLegalAlive() && failSafe)
{
player.Announce(LastRequest.LR_PREFIX,"Boom!");
player.Slay();
}
}

public override void GrenadeThrown()
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
Expand Down
22 changes: 22 additions & 0 deletions src/LastRequest/LRBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public void Cleanup()
// clean up laser
Lib.KillTimer(ref laserTimer);

// killthe fail safe timer
Lib.KillTimer(ref failsafeTimer);

laser.Destroy();

countdown.Kill();
Expand Down Expand Up @@ -278,6 +281,21 @@ public void CountdownStart()
countdown.Start(lrName,5,this,PrintCountdown,manager.ActivateLR);
}

public void FailSafeActivate()
{
// clean up timer
failsafeTimer = null;

failSafe = true;
Chat.Announce(LastRequest.LR_PREFIX,$"{lrName} fail-safe active");
}

public void DelayFailSafe(float delay)
{
Chat.Announce(LastRequest.LR_PREFIX,$"fail-safe active in {delay} seconds");
JailPlugin.globalCtx.AddTimer(delay,FailSafeActivate,CSTimer.TimerFlags.STOP_ON_MAPCHANGE);
}

public void LaserTick()
{
// get both players and check they are valid
Expand Down Expand Up @@ -350,6 +368,10 @@ public virtual void WeaponZoom() {}

Line laser = new Line();

CSTimer.Timer? failsafeTimer = null;
public bool failSafe = false;


CSTimer.Timer? laserTimer = null;

// managed timer
Expand Down
9 changes: 4 additions & 5 deletions src/LastRequest/LastRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,14 @@ public void LRCmdInternal(CCSPlayerController? player,bool bypass, CommandInfo c
{
lrMenu.AddMenuOption("Knife rebel",StartKnifeRebel);
lrMenu.AddMenuOption("Rebel",StartRebel);
/*

if(Config.riotEnable)
{
lrMenu.AddMenuOption("Riot",start_riot);
lrMenu.AddMenuOption("Riot",StartRiot);
}
*/
}

ChatMenus.OpenMenu(player, lrMenu);
MenuManager.OpenChatMenu(player, lrMenu);
}

public void LRCmd(CCSPlayerController? player, CommandInfo command)
Expand Down Expand Up @@ -526,5 +525,5 @@ internal class LRChoice

long startTimestamp = 0;

public static readonly String LR_PREFIX = $" {ChatColors.Green}[LR]: {ChatColors.White}";
public static String LR_PREFIX = $" {ChatColors.Green}[LR]: {ChatColors.White}";
}
10 changes: 5 additions & 5 deletions src/LastRequest/LastRequestMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option)
lrMenu.AddMenuOption("High speed", PickedOption);
lrMenu.AddMenuOption("One hit", PickedOption);

ChatMenus.OpenMenu(player, lrMenu);
MenuManager.OpenChatMenu(player, lrMenu);
break;
}

Expand All @@ -112,7 +112,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option)
lrMenu.AddMenuOption("Vanilla", PickedOption);
lrMenu.AddMenuOption("Low gravity", PickedOption);

ChatMenus.OpenMenu(player, lrMenu);
MenuManager.OpenChatMenu(player, lrMenu);
break;
}

Expand All @@ -123,7 +123,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option)
lrMenu.AddMenuOption("Awp", PickedOption);
lrMenu.AddMenuOption("Scout", PickedOption);

ChatMenus.OpenMenu(player, lrMenu);
MenuManager.OpenChatMenu(player, lrMenu);
break;
}

Expand All @@ -134,7 +134,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option)
lrMenu.AddMenuOption("Vanilla", PickedOption);
lrMenu.AddMenuOption("Low gravity", PickedOption);

ChatMenus.OpenMenu(player, lrMenu);
MenuManager.OpenChatMenu(player, lrMenu);
break;
}

Expand All @@ -149,7 +149,7 @@ public void PickOption(CCSPlayerController? player, ChatMenuOption option)
lrMenu.AddMenuOption("Five seven",PickedOption);
lrMenu.AddMenuOption("Dual Elite",PickedOption);

ChatMenus.OpenMenu(player, lrMenu);
MenuManager.OpenChatMenu(player, lrMenu);
break;
}

Expand Down
1 change: 0 additions & 1 deletion src/LastRequest/Rebel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public void RiotRespawn()
{
if(player.IsLegal() && !player.IsLegalAlive())
{
Server.PrintToChatAll($"Respawn {player.PlayerName}");
player.Respawn();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static public int DrawLaser(Vector start, Vector end, float width, Color colour)
return (int)laser.Index;
}

static String DOOR_PREFIX = $" {ChatColors.Green}[Door control]: {ChatColors.White}";
public static String DOOR_PREFIX = $" {ChatColors.Green}[Door control]: {ChatColors.White}";

public static void ForceClose()
{
Expand Down
Loading

0 comments on commit 98a20f9

Please sign in to comment.