Skip to content

Commit

Permalink
1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
oqyh committed Jul 5, 2024
1 parent db4dffb commit cad6678
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Config/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ private static void SaveConfigData(ConfigData configData)

public class ConfigData
{
public int MinimumPlayersToEnableKnifePlugin { get; set; }
public bool CountBotsAsPlayers { get; set; }
public bool EnableVoteTeamSideAfterWinning { get; set; }
public bool FreezePlayersOnVoteStarted { get; set; }
public bool BlockTeamChangeOnVotingAndKnifeRound { get; set; }
Expand Down Expand Up @@ -116,6 +118,8 @@ public int GiveArmorOnKnifeRound

public ConfigData()
{
MinimumPlayersToEnableKnifePlugin = 6;
CountBotsAsPlayers = false;
EnableVoteTeamSideAfterWinning = true;
FreezePlayersOnVoteStarted = true;
BlockTeamChangeOnVotingAndKnifeRound = true;
Expand Down
2 changes: 1 addition & 1 deletion Config/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Globals
public static List<ulong> VoteCountT = new();

public static Stopwatch Stopwatch = new Stopwatch();

public static bool DisableKnife = false;
public static bool CTWINNER = false;
public static bool TWINNER = false;
public static float Timer = 0;
Expand Down
16 changes: 14 additions & 2 deletions Config/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Utils;
using Knife_Round_GoldKingZ.Config;

namespace Knife_Round_GoldKingZ;

Expand Down Expand Up @@ -107,9 +108,20 @@ public static int GetTerroristCount()
{
return Utilities.GetPlayers().Count(p => p != null && p.IsValid && !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected && p.TeamNum == (byte)CsTeam.Terrorist);
}
public static int GetAllCount()
public static int GetPlayersCount(bool IncludeBots = false)
{
return Utilities.GetPlayers().Count(p => p != null && p.IsValid && !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected);
return Utilities.GetPlayers().Count(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && (IncludeBots || (!p.IsBot && !p.IsHLTV)));
}
public static int GetPlayersNeeded()
{
if (Configs.GetConfigData().CountBotsAsPlayers)
{
return GetPlayersCount(true);
}
else
{
return GetPlayersCount(false);
}
}
public static void ClearVariables()
{
Expand Down
Binary file modified CounterStrikeSharp.API.dll
Binary file not shown.
38 changes: 30 additions & 8 deletions Knife-Round-GoldKingZ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Knife_Round_GoldKingZ;
public class KnifeRoundGoldKingZ : BasePlugin
{
public override string ModuleName => "Knife Round (Creates An Additional Round With Knifes After Warmup)";
public override string ModuleVersion => "1.1.0";
public override string ModuleVersion => "1.1.1";
public override string ModuleAuthor => "Gold KingZ";
public override string ModuleDescription => "https://github.com/oqyh";
internal static IStringLocalizer? Stringlocalizer;
Expand All @@ -42,7 +42,7 @@ public override void Load(bool hotReload)

public void OnTick()
{
if(!Globals.PrepareKnifeRound)
if(!Globals.DisableKnife && !Globals.PrepareKnifeRound)
{
if(Globals.KnifeRoundStarted && Globals.KnifeModeStartMessage && !string.IsNullOrEmpty(Localizer["hud.message.kniferoundstarted"]))
{
Expand Down Expand Up @@ -141,7 +141,7 @@ public void OnTick()

public HookResult OnEventRoundEnd(EventRoundEnd @event, GameEventInfo info)
{
if(@event == null)return HookResult.Continue;
if(Globals.DisableKnife || @event == null)return HookResult.Continue;

if(Globals.KnifeRoundStarted)
{
Expand Down Expand Up @@ -200,7 +200,7 @@ public HookResult OnEventRoundEnd(EventRoundEnd @event, GameEventInfo info)

public HookResult OnEventPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
{
if(@event == null)return HookResult.Continue;
if(Globals.DisableKnife || @event == null)return HookResult.Continue;

var player = @event.Userid;
if (player == null || !player.IsValid)return HookResult.Continue;
Expand Down Expand Up @@ -254,17 +254,39 @@ public HookResult OnEventPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info
}
public HookResult OnEventRoundPrestart(EventRoundPrestart @event, GameEventInfo info)
{
if(@event == null)return HookResult.Continue;
if(Globals.DisableKnife ||@event == null)return HookResult.Continue;

if(Globals.PrepareKnifeRound)
{
if(Configs.GetConfigData().CountBotsAsPlayers && Helper.GetPlayersCount(true) < Configs.GetConfigData().MinimumPlayersToEnableKnifePlugin || !Configs.GetConfigData().CountBotsAsPlayers && Helper.GetPlayersCount(false) < Configs.GetConfigData().MinimumPlayersToEnableKnifePlugin)
{
string roundtime = Globals.mp_roundtime.ToString().Replace(',', '.');
string roundtimeDefuse = Globals.mp_roundtime_defuse.ToString().Replace(',', '.');
string teamIntroTime = Globals.mp_team_intro_time.ToString().Replace(',', '.');
Server.ExecuteCommand($"mp_team_intro_time {teamIntroTime}; sv_buy_status_override -1; mp_roundtime {roundtime}; mp_roundtime_defuse {roundtimeDefuse}; mp_give_player_c4 1");
if (Configs.GetConfigData().AllowAllTalkOnKnifeRound)
{
Server.ExecuteCommand($"sv_alltalk {Globals.sv_alltalk}; sv_deadtalk {Globals.sv_deadtalk}; sv_full_alltalk {Globals.sv_full_alltalk}; sv_talk_enemy_dead {Globals.sv_talk_enemy_dead}; sv_talk_enemy_living {Globals.sv_talk_enemy_living}");
}

Server.ExecuteCommand($"mp_restartgame 3");
if (!string.IsNullOrEmpty(Localizer["chat.message.knife.ignored"]))
{
Helper.AdvancedPrintToServer(Localizer["chat.message.knife.ignored"], Helper.GetPlayersNeeded(), Configs.GetConfigData().MinimumPlayersToEnableKnifePlugin);
}

Globals.DisableKnife = true;
return HookResult.Continue;
}
Globals.RemoveWeapons = true;
}
return HookResult.Continue;
}


public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
{
if(@event == null)return HookResult.Continue;
if(Globals.DisableKnife || @event == null)return HookResult.Continue;

if(Globals.PrepareKnifeRound)
{
Expand Down Expand Up @@ -331,7 +353,7 @@ private HookResult OnCommandJoinTeam(CCSPlayerController? player, CommandInfo co

public HookResult OnEventPlayerChat(EventPlayerChat @event, GameEventInfo info)
{
if(!Configs.GetConfigData().EnableVoteTeamSideAfterWinning || @event == null)return HookResult.Continue;
if(Globals.DisableKnife || !Configs.GetConfigData().EnableVoteTeamSideAfterWinning || @event == null)return HookResult.Continue;

var eventplayer = @event.Userid;
var eventmessage = @event.Text;
Expand Down Expand Up @@ -452,7 +474,7 @@ public void ResetValuesAndExecuteCommands()
Server.ExecuteCommand($"mp_team_intro_time {teamIntroTime}; sv_buy_status_override -1; mp_roundtime {roundtime}; mp_roundtime_defuse {roundtimeDefuse}; mp_give_player_c4 1");
if (Configs.GetConfigData().AllowAllTalkOnKnifeRound)
{
Server.ExecuteCommand($"sv_alltalk {Globals.sv_alltalk}; sv_deadtalk {Globals.sv_deadtalk}; sv_full_alltalk {Globals.sv_full_alltalk}; sv_talk_enemy_dead {Globals.sv_talk_enemy_dead}; sv_talk_enemy_living {Globals.sv_talk_enemy_living};");
Server.ExecuteCommand($"sv_alltalk {Globals.sv_alltalk}; sv_deadtalk {Globals.sv_deadtalk}; sv_full_alltalk {Globals.sv_full_alltalk}; sv_talk_enemy_dead {Globals.sv_talk_enemy_dead}; sv_talk_enemy_living {Globals.sv_talk_enemy_living}");
}
int x = Configs.GetConfigData().AfterWinningRestartXTimes;
Expand Down
9 changes: 5 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"chat.message.knife.start": "{green}Gold KingZ | Knife Round! {nextline} {green}Gold KingZ | Knife Round! {nextline} {green}Gold KingZ | Knife Round!",
"chat.message.knife.ignored": "{green}Gold KingZ | {grey}Knife Round Ignored Less Players ( {yellow}{0} Current {grey}/ {yellow}{1} Needed {grey})",
"chat.message.knife.start": "{green}Gold KingZ | Knife Round! {nextline} {green}Gold KingZ | Knife Round! {nextline} {green}Gold KingZ | Knife Round!",
"chat.message.match.start": "{green}Gold KingZ | LIVE! {nextline} {green}Gold KingZ | LIVE! {nextline} {green}Gold KingZ | LIVE!",


"hud.message.kniferoundstarted": "<img src='https://github.com/raw/oqyh/cs2-Knife-Round-GoldKingZ/main/Resources/knifeleft.png' class=''> <font color='orange'>Knife Round <img src='https://github.com/raw/oqyh/cs2-Knife-Round-GoldKingZ/main/Resources/kniferight.png' class=''> <br> <br> <font color='blueviolet'>Winner Will Choose Team Side </font>",
"hud.message.winnerteam": "<font color='green'>Vote Which Side To Pick <br> <font color='darkred'> = Time Left To Vote: {0} Secs = <br> <font color='yellow'>!ct <font color='grey'>To Go CT Side Team <br> <font color='yellow'>!t <font color='grey'>To Go T Side Team <br> <font color='grey'>Votes On <img src='https://github.com/raw/oqyh/cs2-Knife-Round-GoldKingZ/main/Resources/ctimg.png' class=''> <font color='green'>[{1} <font color='grey'>/ <font color='green'>{3}] <br> <font color='grey'>Votes On <img src='https://github.com/raw/oqyh/cs2-Knife-Round-GoldKingZ/main/Resources/timg.png' class=''> <font color='green'>[{2} <font color='grey'>/ <font color='green'>{3}] </font>",
"hud.message.winnerteam": "<font color='green'>Vote Which Side To Pick <br> <font color='darkred'> = Time Left To Vote: {0} Secs = <br> <font color='yellow'>!ct <font color='grey'>To Go CT Side Team <br> <font color='yellow'>!t <font color='grey'>To Go T Side Team <br> <font color='grey'>Votes On <img src='https://github.com/raw/oqyh/cs2-Knife-Round-GoldKingZ/main/Resources/ctimg.png' class=''> <font color='green'>[{1} <font color='grey'>/ <font color='green'>{3}] <br> <font color='grey'>Votes On <img src='https://github.com/raw/oqyh/cs2-Knife-Round-GoldKingZ/main/Resources/timg.png' class=''> <font color='green'>[{2} <font color='grey'>/ <font color='green'>{3}] </font>",
"hud.message.loseteam.ct": "<font color='yellow'>Waitng For <font color='red'>T's <font color='yellow'>To Vote </font>",
"hud.message.loseteam.t": "<font color='yellow'>Waitng For <font color='RoyalBlue'>CT's <font color='yellow'>To Vote </font>"
}

0 comments on commit cad6678

Please sign in to comment.