forked from samyycX/CS2-PlayerModelChanger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.cs
86 lines (74 loc) · 2.35 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
namespace PlayerModelChanger;
public class Utils {
public static void ExecuteSide(string side, Action? whenAll, Action whenT, Action whenCT, Action? invalid = null) {
switch (side.ToLower()) {
case "all":
if (whenAll == null) {
whenT();
whenCT();
} else {
whenAll();
}
break;
case "t":
whenT();
break;
case "ct":
whenCT();
break;
default:
if (invalid != null) {
invalid();
}
break;
};
}
public static bool PlayerHasPermission(CCSPlayerController player, string[] permissions, string[] permissionsOr) {
foreach (string perm in permissions) {
if (perm.StartsWith("@")) {
if (!AdminManager.PlayerHasPermissions(player, new string[]{perm})) {
return false;
}
}
else if (perm.StartsWith("#")) {
if (!AdminManager.PlayerInGroup(player, new string[]{perm})) {
return false;
}
}
else {
ulong steamId;
if (!ulong.TryParse(perm, out steamId)) {
throw new FormatException($"Unknown SteamID64 format: {perm}");
} else {
if (player.SteamID != steamId) {
return false;
}
}
}
}
foreach (string perm in permissionsOr) {
if (perm.StartsWith("@")) {
if (AdminManager.PlayerHasPermissions(player, perm)) {
return true;
}
}
else if (perm.StartsWith("#")) {
if (AdminManager.PlayerInGroup(player, perm)) {
return true;
}
} else {
ulong steamId;
if (!ulong.TryParse(perm, out steamId)) {
throw new FormatException($"Unknown SteamID64 format: {perm}");
} else {
if (player.SteamID == steamId) {
return true;
}
}
}
}
return true;
}
}