|
3 | 3 | using LabApi.Features.Permissions; |
4 | 4 | using LabApi.Features.Wrappers; |
5 | 5 | using RemoteAdmin; |
| 6 | +using SER.Code.Helpers; |
6 | 7 | using SER.Code.Helpers.Exceptions; |
7 | 8 | using SER.Code.Helpers.Extensions; |
8 | 9 | using SER.Code.Helpers.ResultSystem; |
|
13 | 14 | using SER.Code.ValueSystem; |
14 | 15 | using SER.Code.VariableSystem.Bases; |
15 | 16 | using SER.Code.VariableSystem.Variables; |
| 17 | +using UnityEngine; |
16 | 18 | using Console = GameCore.Console; |
17 | 19 |
|
18 | 20 | namespace SER.Code.FlagSystem.Flags; |
@@ -252,22 +254,25 @@ public static Result RunAttachedScript(CustomCommand cmd, ScriptExecutor sender, |
252 | 254 |
|
253 | 255 | private static string? HandlePlayer(CustomCommand cmd, Player plr) |
254 | 256 | { |
255 | | - var hasRank = plr.UserGroup is not { } group || cmd.NeededRanks.All(rank => group.Name != rank); |
256 | | - if (cmd.NeededRanks.Any() && hasRank) |
| 257 | + Log.Debug($"handling player in command {cmd.Command}"); |
| 258 | + if (cmd.NeededRanks.Any()) |
257 | 259 | { |
258 | | - return "This command is reserved for players with a rank: " + |
259 | | - $"{cmd.NeededRanks.JoinStrings(", ")}"; |
| 260 | + if (plr.UserGroup is not { } group || cmd.NeededRanks.All(rank => group.Name != rank)) |
| 261 | + { |
| 262 | + return "This command is reserved for players with a rank: " + |
| 263 | + $"{cmd.NeededRanks.Select(r => $"'{r}'").JoinStrings(" or ")}"; |
| 264 | + } |
260 | 265 | } |
261 | 266 |
|
262 | 267 | if (cmd.PlayerCooldown <= TimeSpan.Zero) |
263 | 268 | { |
264 | 269 | return null; |
265 | 270 | } |
266 | | - |
267 | | - if (cmd.NextEligableDateForPlayer.TryGetValue(plr, out var nextEligableDate) && nextEligableDate < DateTime.UtcNow) |
| 271 | + |
| 272 | + if (cmd.NextEligableDateForPlayer.TryGetValue(plr, out var nextEligableDate) && nextEligableDate > DateTime.UtcNow) |
268 | 273 | { |
269 | 274 | return $"You are on cooldown! You can use this command in " + |
270 | | - $"{(nextEligableDate - DateTime.UtcNow).Seconds} seconds."; |
| 275 | + $"{Math.Round((nextEligableDate - DateTime.UtcNow).TotalSeconds, MidpointRounding.AwayFromZero)} seconds."; |
271 | 276 | } |
272 | 277 |
|
273 | 278 | cmd.NextEligableDateForPlayer[plr] = DateTime.UtcNow + cmd.PlayerCooldown; |
|
0 commit comments