Skip to content

Commit efb3966

Browse files
committed
Update 1.DZ.8.4
Changed Targeting
1 parent 940f5b7 commit efb3966

File tree

10 files changed

+66
-167
lines changed

10 files changed

+66
-167
lines changed

EntWatchSharp/Commands.cs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
using CounterStrikeSharp.API;
2-
using CounterStrikeSharp.API.Core;
1+
using CounterStrikeSharp.API.Core;
32
using CounterStrikeSharp.API.Core.Attributes.Registration;
43
using CounterStrikeSharp.API.Modules.Admin;
54
using CounterStrikeSharp.API.Modules.Commands;
5+
using CounterStrikeSharp.API.Modules.Commands.Targeting;
66
using EntWatchSharp.Helpers;
77
using EntWatchSharp.Items;
88
using EntWatchSharp.Modules;
99
using EntWatchSharp.Modules.Eban;
1010
using System.Globalization;
11-
using static EntWatchSharp.Helpers.FindTarget;
1211
using static EntWatchSharp.Modules.Eban.EbanDB;
1312

1413
namespace EntWatchSharp
@@ -396,7 +395,7 @@ public void OnEWBan(CCSPlayerController? admin, CommandInfo command)
396395
if (admin != null && !admin.IsValid) return;
397396
bool bConsole = command.CallingContext == CommandCallingContext.Console;
398397

399-
(List<CCSPlayerController> players, string _) = Find(admin, command, 1, true, true, MultipleFlags.NORMAL, false);
398+
(List<CCSPlayerController> players, string _, ProcessTargetResultFlag _) = EW.FindTargets(admin, command.GetArg(1), true, true, false);
400399

401400
OfflineBan target = null;
402401

@@ -490,9 +489,9 @@ public void OnEWUnBan(CCSPlayerController? admin, CommandInfo command)
490489
if (admin != null && !admin.IsValid) return;
491490
bool bConsole = command.CallingContext == CommandCallingContext.Console;
492491

493-
(List<CCSPlayerController> players, string _) = Find(admin, command, 1, true, true, MultipleFlags.NORMAL, false);
492+
(List<CCSPlayerController> players, string _, ProcessTargetResultFlag _) = EW.FindTargets(admin, command.GetArg(1), true, true, false);
494493

495-
EbanPlayer target = new();
494+
EbanPlayer target = new();
496495
string sTarget = command.GetArg(1);
497496

498497
bool bOnline = players.Count > 0;
@@ -605,9 +604,13 @@ public void OnEWStatus(CCSPlayerController? player, CommandInfo command)
605604
CCSPlayerController target = player;
606605
if (command.ArgCount > 1)
607606
{
608-
(List<CCSPlayerController> players, string _) = Find(player, command, 1, true, false, MultipleFlags.NORMAL);
607+
(List<CCSPlayerController> players, string _, ProcessTargetResultFlag _) = EW.FindTargets(player, command.GetArg(1), true, false, false);
609608

610-
if (players.Count == 0) return;
609+
if (players.Count == 0)
610+
{
611+
UI.EWReplyInfo(player, "Reply.No_matching_client", bConsole);
612+
return;
613+
}
611614

612615
target = players.Single();
613616
}
@@ -731,8 +734,12 @@ public void OnEWTransfer(CCSPlayerController? admin, CommandInfo command)
731734
}
732735
} else
733736
{
734-
(List<CCSPlayerController> players, string _) = Find(admin, command, 1, true, true, MultipleFlags.IGNORE_DEAD_PLAYERS);
735-
if (players.Count == 0) return;
737+
(List<CCSPlayerController> players, string _, ProcessTargetResultFlag _) = EW.FindTargets(admin, command.GetArg(1), true, true, true);
738+
if (players.Count == 0)
739+
{
740+
UI.EWReplyInfo(admin, "Reply.No_matching_client", bConsole);
741+
return;
742+
}
736743
target = players.Single();
737744
}
738745

@@ -742,8 +749,12 @@ public void OnEWTransfer(CCSPlayerController? admin, CommandInfo command)
742749
return;
743750
}
744751

745-
(List<CCSPlayerController> players1, string _) = Find(admin, command, 2, true, false, MultipleFlags.IGNORE_DEAD_PLAYERS);
746-
if (players1.Count == 0) return;
752+
(List<CCSPlayerController> players1, string _, ProcessTargetResultFlag _) = EW.FindTargets(admin, command.GetArg(2), true, true, true);
753+
if (players1.Count == 0)
754+
{
755+
UI.EWReplyInfo(admin, "Reply.No_matching_client", bConsole);
756+
return;
757+
}
747758
CCSPlayerController receiver = players1.Single();
748759

749760
if (!EW.CheckDictionary(receiver))
@@ -802,8 +813,12 @@ public void OnEWSpawn(CCSPlayerController? admin, CommandInfo command)
802813
return;
803814
}
804815

805-
(List<CCSPlayerController> players, string _) = Find(admin, command, 2, true, false, MultipleFlags.IGNORE_DEAD_PLAYERS);
806-
if (players.Count == 0) return;
816+
(List<CCSPlayerController> players, string _, ProcessTargetResultFlag _) = EW.FindTargets(admin, command.GetArg(1), true, true, true);
817+
if (players.Count == 0)
818+
{
819+
UI.EWReplyInfo(admin, "Reply.No_matching_client", bConsole);
820+
return;
821+
}
807822
CCSPlayerController receiver = players.Single();
808823

809824
if (!EW.CheckDictionary(receiver))

EntWatchSharp/EW.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CounterStrikeSharp.API;
22
using CounterStrikeSharp.API.Core;
33
using CounterStrikeSharp.API.Core.Capabilities;
4+
using CounterStrikeSharp.API.Modules.Commands.Targeting;
45
using CS2_GameHUDAPI;
56
using EntWatchSharp.Helpers;
67
using EntWatchSharp.Items;
@@ -284,7 +285,27 @@ public static bool IsGameUI(CEntityInstance entity)
284285
return false;
285286
}
286287

287-
public static string ConvertSteamID64ToSteamID(string steamId64)
288+
public static (List<CCSPlayerController> players, string targetname, ProcessTargetResultFlag result) FindTargets(CCSPlayerController? player, string targetString, bool nobots, bool immunity, bool aliveonly)
289+
{
290+
var filter = ProcessTargetFilterFlag.None;
291+
292+
if (nobots)
293+
filter |= ProcessTargetFilterFlag.FilterNoBots;
294+
295+
if (!immunity)
296+
filter |= ProcessTargetFilterFlag.FilterNoImmunity;
297+
298+
if (aliveonly)
299+
filter |= ProcessTargetFilterFlag.FilterAlive;
300+
301+
ProcessTargetResultFlag result;
302+
if ((result = Target.ProcessTargetString(player, targetString, filter, true, out var targetname, out var players)) == ProcessTargetResultFlag.TargetFound)
303+
return (players, targetname, result);
304+
305+
return ([], "", result);
306+
}
307+
308+
public static string ConvertSteamID64ToSteamID(string steamId64)
288309
{
289310
if (ulong.TryParse(steamId64, out var communityId) && communityId > 76561197960265728)
290311
{

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.8.3";
21+
public override string ModuleVersion => "1.DZ.8.4";
2222

2323
public override void OnAllPluginsLoaded(bool hotReload)
2424
{

EntWatchSharp/Events.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ private void OnMapEnd_Listener()
174174
EW.g_Timer.Kill();
175175
EW.g_Timer = null;
176176
}
177+
foreach(var offlineplayer in EW.g_OfflinePlayer.ToList())
178+
{
179+
offlineplayer.UserID = -1;
180+
}
177181
}
178182

179183
private void OnEntitySpawned_Listener(CEntityInstance entity)

EntWatchSharp/Helpers/FindTarget.cs

Lines changed: 0 additions & 113 deletions
This file was deleted.

EntWatchSharp/Modules/Eban/OfflineBan.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static OfflineBan CreateOrFind(CCSPlayerController UserID)
3737
offlineplayer = new OfflineBan();
3838
EW.g_OfflinePlayer.Add(offlineplayer);
3939
}
40-
offlineplayer.UserID = UserID.UserId ?? 0;
40+
offlineplayer.UserID = UserID.UserId ?? -1;
4141
offlineplayer.Name = UserID.PlayerName;
4242
offlineplayer.SteamID = EW.ConvertSteamID64ToSteamID(UserID.SteamID.ToString());
4343
offlineplayer.Immutity = AdminManager.GetPlayerImmunity(UserID);
@@ -97,6 +97,11 @@ public static OfflineBan FindTarget(CCSPlayerController admin, string sTarget, b
9797
UI.EWReplyInfo(admin, "Reply.Must_be_an_integer", bConsole);
9898
return null;
9999
}
100+
if (iUID < 0)
101+
{
102+
UI.EWReplyInfo(admin, "Reply.No_matching_client", bConsole);
103+
return null;
104+
}
100105
foreach (OfflineBan OfflineTest in EW.g_OfflinePlayer.ToList())
101106
{
102107
if (!OfflineTest.Online && OfflineTest.UserID == iUID)

EntWatchSharp/addons/counterstrikesharp/plugins/EntWatchSharp/lang/en.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
"Reply.No_matching_client": "There is no matching client.",
3333
"Reply.More_than_one_client_matched": "There are multiple clients that match.",
3434
"Reply.You_cannot_target": "Since this person's immunity level is higher than yours, you cannot target this person.",
35-
"Reply.You_can_target_only_dead_players": "You can target only dead players.",
36-
"Reply.You_can_target_only_alive_players": "You can target only alive players",
3735
"Reply.Must_be_an_integer": "The entered value must be a number",
3836
"Reply.Reload_configs": "Configs has been reloaded..",
3937
"Reply.NotValid": "The value you entered is not valid. Please use help",
@@ -88,14 +86,5 @@
8886
"Reply.Offline.OnServer": "{0}. {1}(#{2}/{3}). Last item: {4}. Status: Online",
8987
"Reply.Offline.Leave": "{0}. {1}(#{2}/{3}). Last item: {4}. Status: left {5} minutes ago",
9088
"All.Enabled": "Enabled",
91-
"All.Disabled": "Disabled",
92-
"all": "all players",
93-
"bots": "bots",
94-
"humans": "humans",
95-
"alive": "alive players",
96-
"dead": "dead players",
97-
"notme": "all players except self",
98-
"ct": "ct players",
99-
"t": "t players",
100-
"spec": "spec players"
89+
"All.Disabled": "Disabled"
10190
}

EntWatchSharp/addons/counterstrikesharp/plugins/EntWatchSharp/lang/ru.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
"Reply.No_matching_client": "Игрок не найден",
3333
"Reply.More_than_one_client_matched": "Найдено несколько игроков",
3434
"Reply.You_cannot_target": "Иммунитет этого игрока выше вашего",
35-
"Reply.You_can_target_only_dead_players": "Вы можете выбрать только мёртвых игроков",
36-
"Reply.You_can_target_only_alive_players": "Вы можете выбрать только живых игроков",
3735
"Reply.Must_be_an_integer": "Введенное значение должно быть числом",
3836
"Reply.Reload_configs": "Конфиги перезагружены...",
3937
"Reply.NotValid": "Введённое значение не валидно. Воспользуйтесь помощью",
@@ -88,14 +86,5 @@
8886
"Reply.Offline.OnServer": "{0}. {1}(#{2}/{3}). Последний итем: {4}. Статус: Онлайн",
8987
"Reply.Offline.Leave": "{0}. {1}(#{2}/{3}). Последний итем: {4}. Статус: вышел {5} минут назад",
9088
"All.Enabled": "Включена",
91-
"All.Disabled": "Отключена",
92-
"all": "все игроки",
93-
"bots": "боты",
94-
"humans": "игроки",
95-
"alive": "живые игроки",
96-
"dead": "мертвые игроки",
97-
"notme": "все игроки кроме себя",
98-
"ct": "контры",
99-
"t": "террористы",
100-
"spec": "спектаторы"
89+
"All.Disabled": "Отключена"
10190
}

EntWatchSharp/addons/counterstrikesharp/plugins/EntWatchSharp/lang/zh-Hans.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
"Reply.No_matching_client": "没有匹配的客户端。",
3333
"Reply.More_than_one_client_matched": "有多个匹配的客户端。",
3434
"Reply.You_cannot_target": "由于此人的权限级别高于你,你无法针对此人。",
35-
"Reply.You_can_target_only_dead_players": "你只能针对死亡的玩家。",
36-
"Reply.You_can_target_only_alive_players": "你只能针对存活的玩家",
3735
"Reply.Must_be_an_integer": "输入的值必须是一个数字",
3836
"Reply.Reload_configs": "配置已重新加载。",
3937
"Reply.NotValid": "您输入的值无效。请使用帮助",
@@ -88,14 +86,5 @@
8886
"Reply.Offline.OnServer": "{0}. {1}(#{2}/{3})。最后物品:{4}。状态:在线",
8987
"Reply.Offline.Leave": "{0}. {1}(#{2}/{3})。最后物品:{4}。状态:{5} 分钟前离开",
9088
"All.Enabled": "启用",
91-
"All.Disabled": "禁用",
92-
"all": "所有玩家",
93-
"bots": "机器人",
94-
"humans": "人类玩家",
95-
"alive": "存活玩家",
96-
"dead": "死亡玩家",
97-
"notme": "除自己外的所有玩家",
98-
"ct": "CT玩家",
99-
"t": "T玩家",
100-
"spec": "观察者"
89+
"All.Disabled": "禁用"
10190
}

VERSION

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

0 commit comments

Comments
 (0)