Skip to content

Commit cf44c55

Browse files
committed
Update 1.DZ.7.3
Fixed the issue where an item would fall into the ground upon death Refusal to use parallelization[darkerz7/CS2-GameHUD#2]
1 parent 62eec0f commit cf44c55

File tree

5 files changed

+34
-104
lines changed

5 files changed

+34
-104
lines changed

EntWatchSharp/EW.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,17 @@ public static void DropSpecialWeapon(CCSPlayerController player)
140140
{
141141
if (player.IsValid && player.PlayerPawn.Value != null && player.PlayerPawn.Value.IsValid)
142142
{
143-
System.Numerics.Vector3 vecPos = (System.Numerics.Vector3)player.PlayerPawn.Value.AbsOrigin with { Z = player.PlayerPawn.Value.AbsOrigin.Z + 30 };
143+
System.Numerics.Vector3 vecPos = (System.Numerics.Vector3)player.PlayerPawn.Value.AbsOrigin with { Z = player.PlayerPawn.Value.AbsOrigin.Z + 70 };
144144
foreach (var weapon in player.PlayerPawn.Value.WeaponServices.MyWeapons)
145145
{
146146
if (!weapon.IsValid || string.IsNullOrEmpty(weapon.Value.UniqueHammerID)) continue;
147147

148+
CBasePlayerWeapon wpn = new(weapon.Value.Handle);
149+
148150
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Raw = weapon.Raw;
149151
player.DropActiveWeapon();
150152

151153
//Fix for item dropping underground
152-
CBasePlayerWeapon wpn = new(weapon.Value.Handle);
153154
Server.NextFrame(() =>
154155
{
155156
if (wpn != null && wpn.IsValid) wpn.Teleport(vecPos);

EntWatchSharp/EntWatchSharp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class EntWatchSharp : BasePlugin
1818
public override string ModuleName => "EntWatchSharp";
1919
public override string ModuleDescription => "Notify players about entity interactions";
2020
public override string ModuleAuthor => "DarkerZ [RUS]";
21-
public override string ModuleVersion => "1.DZ.7.2";
21+
public override string ModuleVersion => "1.DZ.7.3";
2222

2323
public override void OnAllPluginsLoaded(bool hotReload)
2424
{

EntWatchSharp/EntWatchSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.339" />
23+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.340" />
2424
</ItemGroup>
2525

2626
<ItemGroup>

EntWatchSharp/Helpers/UI.cs

Lines changed: 28 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,20 @@ public static void EWChatActivity(string sMessage, string sColor, Item ItemTest,
2424

2525
if (!(AbilityTest == null || ItemTest.Chat || AbilityTest.Chat_Uses)) return;
2626

27-
Task.Run(() =>
28-
{
29-
Parallel.ForEach(EW.g_EWPlayer, (pair) =>
30-
{
31-
Server.NextFrame(() =>
32-
{
33-
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false }) || !EW.g_EWPlayer.ContainsKey(pair.Key)) return;
34-
35-
if (Cvar.TeamOnly && pair.Key.TeamNum > 1 && ItemTest.Team != pair.Key.TeamNum && (!AdminManager.PlayerHasPermissions(pair.Key, "@css/ew_chat") || Cvar.AdminChat == 2 || (Cvar.AdminChat == 1 && AbilityTest != null))) return;
36-
37-
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
38-
{
39-
pair.Key.PrintToChat(EWChatMessage($"{PlayerInfo(pair.Key, sPlayerInfoFormat)} {sColor}{EntWatchSharp.Strlocalizer[sMessage]} {ItemTest.Color}{ItemTest.Name}{((AbilityTest != null && !string.IsNullOrEmpty(AbilityTest.Name)) ? $" ({AbilityTest.Name})" : "")}"));
40-
}
41-
});
42-
});
43-
});
44-
45-
/*Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(pl =>
27+
foreach (var pair in EW.g_EWPlayer)
4628
{
4729
Server.NextFrame(() =>
4830
{
49-
if (!pl.IsValid || !EW.g_EWPlayer.ContainsKey(pl)) return;
31+
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false }) || !EW.g_EWPlayer.ContainsKey(pair.Key)) return;
5032

51-
if (Cvar.TeamOnly && pl.TeamNum > 1 && ItemTest.Team != pl.TeamNum && (!AdminManager.PlayerHasPermissions(pl, "@css/ew_chat") || Cvar.AdminChat == 2 || (Cvar.AdminChat == 1 && AbilityTest != null))) return;
33+
if (Cvar.TeamOnly && pair.Key.TeamNum > 1 && ItemTest.Team != pair.Key.TeamNum && (!AdminManager.PlayerHasPermissions(pair.Key, "@css/ew_chat") || Cvar.AdminChat == 2 || (Cvar.AdminChat == 1 && AbilityTest != null))) return;
5234

53-
using (new WithTemporaryCulture(pl.GetLanguage()))
35+
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
5436
{
55-
pl.PrintToChat(EWChatMessage($"{PlayerInfo(pl, sPlayerInfoFormat)} {sColor}{EntWatchSharp.Strlocalizer[sMessage]} {ItemTest.Color}{ItemTest.Name}{((AbilityTest != null && !string.IsNullOrEmpty(AbilityTest.Name)) ? $" ({AbilityTest.Name})" : "")}"));
37+
pair.Key.PrintToChat(EWChatMessage($"{PlayerInfo(pair.Key, sPlayerInfoFormat)} {sColor}{EntWatchSharp.Strlocalizer[sMessage]} {ItemTest.Color}{ItemTest.Name}{((AbilityTest != null && !string.IsNullOrEmpty(AbilityTest.Name)) ? $" ({AbilityTest.Name})" : "")}"));
5638
}
5739
});
58-
});*/
40+
}
5941
}
6042
public static void EWChatAdminBan(string[] sPIF_admin, string[] sPIF_player, string sReason, bool bAction)
6143
{
@@ -73,32 +55,18 @@ public static void EWChatAdminBan(string[] sPIF_admin, string[] sPIF_player, str
7355
LogManager.AdminAction("Chat.Admin.Reason", EW.g_Scheme.color_warning, sReason);
7456
});
7557

76-
Task.Run(() =>
77-
{
78-
Parallel.ForEach(EW.g_EWPlayer, (pair) =>
79-
{
80-
Server.NextFrame(() =>
81-
{
82-
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
83-
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
84-
{
85-
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer[bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted", EW.g_Scheme.color_warning, PlayerInfo(pair.Key, sPIF_admin), bAction ? EW.g_Scheme.color_disabled : EW.g_Scheme.color_enabled, PlayerInfo(pair.Key, sPIF_player)]));
86-
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Chat.Admin.Reason", EW.g_Scheme.color_warning, sReason]));
87-
}
88-
});
89-
});
90-
});
91-
/*Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(pl =>
58+
foreach (var pair in EW.g_EWPlayer)
9259
{
9360
Server.NextFrame(() =>
9461
{
95-
using (new WithTemporaryCulture(pl.GetLanguage()))
62+
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
63+
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
9664
{
97-
pl.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer[bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted", EW.g_Scheme.color_warning, PlayerInfo(pl, sPIF_admin), bAction ? EW.g_Scheme.color_disabled : EW.g_Scheme.color_enabled, PlayerInfo(pl, sPIF_player)]));
98-
pl.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Chat.Admin.Reason", EW.g_Scheme.color_warning, sReason]));
65+
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer[bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted", EW.g_Scheme.color_warning, PlayerInfo(pair.Key, sPIF_admin), bAction ? EW.g_Scheme.color_disabled : EW.g_Scheme.color_enabled, PlayerInfo(pair.Key, sPIF_player)]));
66+
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Chat.Admin.Reason", EW.g_Scheme.color_warning, sReason]));
9967
}
10068
});
101-
});*/
69+
}
10270
});
10371
}
10472
public static void EWChatAdminSpawn(string[] sPIF_admin, string[] sPIF_receiver, string sItem)
@@ -115,30 +83,17 @@ public static void EWChatAdminSpawn(string[] sPIF_admin, string[] sPIF_receiver,
11583
LogManager.AdminAction("Reply.Spawn.Notify", sPIF_admin[3], sItem, sPIF_receiver[3]);
11684
});
11785

118-
Task.Run(() =>
119-
{
120-
Parallel.ForEach(EW.g_EWPlayer, (pair) =>
121-
{
122-
Server.NextFrame(() =>
123-
{
124-
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
125-
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
126-
{
127-
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Reply.Spawn.Notify", PlayerInfo(pair.Key, sPIF_admin), sItem, PlayerInfo(pair.Key, sPIF_receiver)]));
128-
}
129-
});
130-
});
131-
});
132-
/*Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(pl =>
86+
foreach (var pair in EW.g_EWPlayer)
13387
{
13488
Server.NextFrame(() =>
13589
{
136-
using (new WithTemporaryCulture(pl.GetLanguage()))
90+
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
91+
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
13792
{
138-
pl.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Reply.Spawn.Notify", PlayerInfo(pl, sPIF_admin), sItem, PlayerInfo(pl, sPIF_receiver)]));
93+
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Reply.Spawn.Notify", PlayerInfo(pair.Key, sPIF_admin), sItem, PlayerInfo(pair.Key, sPIF_receiver)]));
13994
}
14095
});
141-
});*/
96+
}
14297
});
14398
}
14499
public static void EWChatAdminTransfer(string[] sPIF_admin, string[] sPIF_receiver, string sItem, string[] sPIF_target)
@@ -154,31 +109,18 @@ public static void EWChatAdminTransfer(string[] sPIF_admin, string[] sPIF_receiv
154109
{
155110
LogManager.AdminAction("Reply.Transfer.Notify", sPIF_admin[3], sItem, sPIF_target[3], sPIF_receiver[3]);
156111
});
157-
158-
Task.Run(() =>
159-
{
160-
Parallel.ForEach(EW.g_EWPlayer, (pair) =>
161-
{
162-
Server.NextFrame(() =>
163-
{
164-
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
165-
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
166-
{
167-
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Reply.Transfer.Notify", PlayerInfo(pair.Key, sPIF_admin), sItem, PlayerInfo(pair.Key, sPIF_target), PlayerInfo(pair.Key, sPIF_receiver)]));
168-
}
169-
});
170-
});
171-
});
172-
/*Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(pl =>
112+
113+
foreach (var pair in EW.g_EWPlayer)
173114
{
174115
Server.NextFrame(() =>
175116
{
176-
using (new WithTemporaryCulture(pl.GetLanguage()))
117+
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
118+
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
177119
{
178-
pl.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Reply.Transfer.Notify", PlayerInfo(pl, sPIF_admin), sItem, PlayerInfo(pl, sPIF_target), PlayerInfo(pl, sPIF_receiver)]));
120+
pair.Key.PrintToChat(EWChatMessage(EntWatchSharp.Strlocalizer["Reply.Transfer.Notify", PlayerInfo(pair.Key, sPIF_admin), sItem, PlayerInfo(pair.Key, sPIF_target), PlayerInfo(pair.Key, sPIF_receiver)]));
179121
}
180122
});
181-
});*/
123+
}
182124
});
183125
}
184126

@@ -216,30 +158,17 @@ public static void CvarChangeNotify(string sCvarName, string sCvarValue, bool bC
216158

217159
if (bClientNotify)
218160
{
219-
Task.Run(() =>
220-
{
221-
Parallel.ForEach(EW.g_EWPlayer, (pair) =>
222-
{
223-
Server.NextFrame(() =>
224-
{
225-
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
226-
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
227-
{
228-
pair.Key.PrintToChat(EWChatMessage($"{EW.g_Scheme.color_warning}{EntWatchSharp.Strlocalizer["Cvar.Notify", sCvarName, sCvarValue]}"));
229-
}
230-
});
231-
});
232-
});
233-
/*Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(pl =>
161+
foreach (var pair in EW.g_EWPlayer)
234162
{
235163
Server.NextFrame(() =>
236164
{
237-
using (new WithTemporaryCulture(pl.GetLanguage()))
165+
if (!(pair.Key is { IsValid: true, IsBot: false, IsHLTV: false })) return;
166+
using (new WithTemporaryCulture(pair.Key.GetLanguage()))
238167
{
239-
pl.PrintToChat(EWChatMessage($"{EW.g_Scheme.color_warning}{EntWatchSharp.Strlocalizer["Cvar.Notify", sCvarName, sCvarValue]}"));
168+
pair.Key.PrintToChat(EWChatMessage($"{EW.g_Scheme.color_warning}{EntWatchSharp.Strlocalizer["Cvar.Notify", sCvarName, sCvarValue]}"));
240169
}
241170
});
242-
});*/
171+
}
243172
}
244173
}
245174

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.DZ.7.2
1+
1.DZ.7.3

0 commit comments

Comments
 (0)