Skip to content

Commit 0f4a2cc

Browse files
authored
1.1.2
1 parent 2ee8f0a commit 0f4a2cc

File tree

5 files changed

+45
-31
lines changed

5 files changed

+45
-31
lines changed

Config/Configs.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ public string Link
222222
}
223223

224224
[BreakLine("{space}----------------------------[ ↓ Main Config ↓ ]----------------------------{space}")]
225+
226+
[Comment("Compatibility With CS2Fixes?\ntrue = Yes")]
227+
public bool CompatibilityWithCS2Fixes { get; set; }
228+
225229
[Comment("Enable Early Connection Of The Players?\ntrue = Yes\nfalse = No (Wait When Player Fully Connected)")]
226230
public bool EarlyConnection { get; set; }
227231

@@ -366,6 +370,7 @@ public ConfigData()
366370
Version = MainPlugin.Instance.ModuleVersion;
367371
Link = "https://github.com/oqyh/cs2-Connect-Disconnect-Sound-GoldKingZ";
368372

373+
CompatibilityWithCS2Fixes = true;
369374
EarlyConnection = true;
370375
DisableLoopConnections = true;
371376
DisableServerHibernate = true;

Config/EventPlayerChat.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ public class PlayerChat
3434
{
3535
public HookResult OnPlayerChat(CCSPlayerController? player, CommandInfo info, bool TeamChat)
3636
{
37-
if (!player.IsValid())return HookResult.Continue;
37+
if (!player.IsValid() || !MainPlugin.Instance.g_Main.Player_Data.ContainsKey(player))return HookResult.Continue;
38+
39+
if (Configs.GetConfigData().CompatibilityWithCS2Fixes)
40+
{
41+
if((DateTime.Now - MainPlugin.Instance.g_Main.Player_Data[player].Time).TotalSeconds < 2)
42+
{
43+
return HookResult.Continue;
44+
}
45+
MainPlugin.Instance.g_Main.Player_Data[player].Time = DateTime.Now;
46+
}
47+
3848
var playerid = player.SteamID;
3949
var eventmessage = info.ArgString;
4050
eventmessage = eventmessage.TrimStart('"');
@@ -52,17 +62,13 @@ public HookResult OnPlayerChat(CCSPlayerController? player, CommandInfo info, bo
5262
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Messages.Not.Allowed"]);
5363
}else
5464
{
55-
if(MainPlugin.Instance.g_Main.Player_Data.ContainsKey(player))
65+
MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages = MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages.ToggleOnOff();
66+
if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages == -1)
5667
{
57-
MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages = MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages.ToggleOnOff();
58-
59-
if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages == -1)
60-
{
61-
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Messages.Enabled"]);
62-
}else if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages == -2)
63-
{
64-
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Messages.Disabled"]);
65-
}
68+
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Messages.Enabled"]);
69+
}else if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Messages == -2)
70+
{
71+
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Messages.Disabled"]);
6672
}
6773
}
6874
}
@@ -75,21 +81,16 @@ public HookResult OnPlayerChat(CCSPlayerController? player, CommandInfo info, bo
7581
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Sounds.Not.Allowed"]);
7682
}else
7783
{
78-
if(MainPlugin.Instance.g_Main.Player_Data.ContainsKey(player))
84+
MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds = MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds.ToggleOnOff();
85+
if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds == -1)
7986
{
80-
MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds = MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds.ToggleOnOff();
81-
82-
if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds == -1)
83-
{
84-
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Sounds.Enabled"]);
85-
}else if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds == -2)
86-
{
87-
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Sounds.Disabled"]);
88-
}
87+
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Sounds.Enabled"]);
88+
}else if(MainPlugin.Instance.g_Main.Player_Data[player].Toggle_Sounds == -2)
89+
{
90+
Helper.AdvancedPlayerPrintToChat(player, MainPlugin.Instance.Localizer["PrintChatToPlayer.Toggle.Sounds.Disabled"]);
8991
}
9092
}
9193
}
92-
9394
return HookResult.Continue;
9495
}
9596
}

Config/Globals.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ public class PlayerDataClass
2525
public bool Remove_Icon { get; set; }
2626
public int Toggle_Messages { get; set; }
2727
public int Toggle_Sounds { get; set; }
28-
public PlayerDataClass(CCSPlayerController player, ulong steamId, bool remove_Icon, int toggle_Messages, int toggle_Sounds)
28+
public DateTime Time { get; set; }
29+
public PlayerDataClass(CCSPlayerController player, ulong steamId, bool remove_Icon, int toggle_Messages, int toggle_Sounds, DateTime time)
2930
{
3031
Player = player;
3132
SteamId = steamId;
3233
Remove_Icon = remove_Icon;
3334
Toggle_Messages = toggle_Messages;
3435
Toggle_Sounds = toggle_Sounds;
36+
Time = time;
3537
}
3638
}
3739
public Dictionary<CCSPlayerController, PlayerDataClass> Player_Data = new Dictionary<CCSPlayerController, PlayerDataClass>();

Config/Helper.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ namespace CnD_Sound;
2929

3030
public class Helper
3131
{
32-
3332
public static void AdvancedPlayerPrintToChat(CCSPlayerController player, string message, params object[] args)
3433
{
35-
if (string.IsNullOrEmpty(message))return;
34+
if (string.IsNullOrEmpty(message)) return;
3635

3736
for (int i = 0; i < args.Length; i++)
3837
{
@@ -43,11 +42,17 @@ public static void AdvancedPlayerPrintToChat(CCSPlayerController player, string
4342
string[] parts = Regex.Split(message, "{nextline}", RegexOptions.IgnoreCase);
4443
foreach (string part in parts)
4544
{
46-
string messages = part.Trim();
47-
player.PrintToChat(" " + messages);
45+
string trimmedPart = part.Trim();
46+
trimmedPart = trimmedPart.ReplaceColorTags();
47+
if (!string.IsNullOrEmpty(trimmedPart))
48+
{
49+
player.PrintToChat(" " + trimmedPart);
50+
}
4851
}
49-
}else
52+
}
53+
else
5054
{
55+
message = message.ReplaceColorTags();
5156
player.PrintToChat(message);
5257
}
5358
}
@@ -230,7 +235,8 @@ await Server.NextFrameAsync(() =>
230235
steamId,
231236
false,
232237
Configs.GetConfigData().Default_Messages ? 1 : 2,
233-
Configs.GetConfigData().Default_Sounds ? 1 : 2
238+
Configs.GetConfigData().Default_Sounds ? 1 : 2,
239+
DateTime.Now
234240
);
235241
g_Main.Player_Data.TryAdd(player, initialData);
236242
});
@@ -620,7 +626,7 @@ public static string GetDisconnectReason(int reasonCode)
620626

621627
if (g_Main.JsonData_Disconnect == null)
622628
{
623-
Helper.DebugMessage("config/disconnect_reasons.json not loaded");
629+
DebugMessage("config/disconnect_reasons.json not loaded");
624630
return "config/disconnect_reasons.json not loaded";
625631
}
626632

Connect-Disconnect-Sound-GoldKingZ.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace CnD_Sound;
1616
public class MainPlugin : BasePlugin
1717
{
1818
public override string ModuleName => "Connect Disconnect Sound (Continent , Country , City , Message , Sounds , Logs , Discord)";
19-
public override string ModuleVersion => "1.1.1";
19+
public override string ModuleVersion => "1.1.2";
2020
public override string ModuleAuthor => "Gold KingZ";
2121
public override string ModuleDescription => "https://github.com/oqyh";
2222
public static MainPlugin Instance { get; set; } = new();

0 commit comments

Comments
 (0)