Skip to content

Commit

Permalink
1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
oqyh committed Jul 6, 2024
1 parent 1a79251 commit 3e7dbf5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Config/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Knife_Round_GoldKingZ;

public class Globals
{
public static CounterStrikeSharp.API.Modules.Timers.Timer? WarmUpTimer;
public static List<ulong> VoteCountCT = new();
public static List<ulong> VoteCountT = new();

Expand All @@ -19,6 +20,7 @@ public class Globals
public static float mp_roundtime;
public static float mp_roundtime_defuse;
public static float mp_team_intro_time;
public static float mp_warmuptime;
public static bool sv_alltalk;
public static bool sv_deadtalk;
public static bool sv_full_alltalk;
Expand Down
3 changes: 3 additions & 0 deletions Config/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public static int GetPlayersNeeded()
}
public static void ClearVariables()
{
Globals.WarmUpTimer?.Kill();
Globals.WarmUpTimer = null;

Globals.DisableKnife = false;
Globals.VoteCountCT.Clear();
Globals.VoteCountT.Clear();
Expand Down
48 changes: 27 additions & 21 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.2";
public override string ModuleVersion => "1.1.3";
public override string ModuleAuthor => "Gold KingZ";
public override string ModuleDescription => "https://github.com/oqyh";
internal static IStringLocalizer? Stringlocalizer;
Expand Down Expand Up @@ -258,26 +258,6 @@ public HookResult OnEventRoundPrestart(EventRoundPrestart @event, GameEventInfo

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;
Expand Down Expand Up @@ -314,13 +294,19 @@ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
Globals.mp_roundtime = ConVar.Find("mp_roundtime")!.GetPrimitiveValue<float>();
Globals.mp_roundtime_defuse = ConVar.Find("mp_roundtime_defuse")!.GetPrimitiveValue<float>();
Globals.mp_team_intro_time = ConVar.Find("mp_team_intro_time")!.GetPrimitiveValue<float>();
Globals.mp_warmuptime = ConVar.Find("mp_warmuptime")!.GetPrimitiveValue<float>();
Globals.sv_alltalk = ConVar.Find("sv_alltalk")!.GetPrimitiveValue<bool>();
Globals.sv_full_alltalk = ConVar.Find("sv_full_alltalk")!.GetPrimitiveValue<bool>();
Globals.sv_talk_enemy_dead = ConVar.Find("sv_talk_enemy_dead")!.GetPrimitiveValue<bool>();
Globals.sv_talk_enemy_living = ConVar.Find("sv_talk_enemy_living")!.GetPrimitiveValue<bool>();
Globals.sv_deadtalk = ConVar.Find("sv_deadtalk")!.GetPrimitiveValue<bool>();
Globals.PrepareKnifeRound = true;
Globals.OnWarmUp = true;

float time = Globals.mp_warmuptime - 1.0f;
Globals.WarmUpTimer?.Kill();
Globals.WarmUpTimer = null;
Globals.WarmUpTimer = AddTimer(time, WarmUpTimer_Callback, TimerFlags.STOP_ON_MAPCHANGE);
}

if(Globals.PrepareKnifeRound)
Expand All @@ -341,6 +327,26 @@ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)

return HookResult.Continue;
}
private void WarmUpTimer_Callback()
{
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}");
}
if (!string.IsNullOrEmpty(Localizer["chat.message.knife.ignored"]))
{
Helper.AdvancedPrintToServer(Localizer["chat.message.knife.ignored"], Helper.GetPlayersNeeded(), Configs.GetConfigData().MinimumPlayersToEnableKnifePlugin);
}

Globals.DisableKnife = true;
}
}

private HookResult OnCommandJoinTeam(CCSPlayerController? player, CommandInfo commandInfo)
{
Expand Down

0 comments on commit 3e7dbf5

Please sign in to comment.