Skip to content

Commit 7022105

Browse files
committed
Imagine a proper commit message here.
1 parent f76a3f5 commit 7022105

2 files changed

Lines changed: 32 additions & 39 deletions

File tree

BasicAdmin/BasicAdmin.cs

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void OnMapCommand(CCSPlayerController? caller, CommandInfo info)
5151
return;
5252
}
5353

54-
Server.PrintToChatAll(FormatAdminMessage($"Changing map to {map}."));
54+
Server.PrintToChatAll(FormatAdminMessage($"Changing map to {map}..."));
5555

5656
AddTimer(3f, () =>
5757
{
@@ -73,10 +73,10 @@ public void OnKickCommand(CCSPlayerController? caller, CommandInfo info)
7373

7474
var reason = info.GetArg(2);
7575

76-
ServerUtils.KickPlayer(player!.PlayerName, reason);
76+
ServerUtils.KickPlayer(player!.UserId, reason);
7777

7878
if (!Config.HideActivity)
79-
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} slayed {player!.PlayerName}."));
79+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} kicked {player!.PlayerName}."));
8080
}
8181

8282
[ConsoleCommand("css_slay", "Slay a player.")]
@@ -110,7 +110,7 @@ public void OnGiveCommand(CCSPlayerController? caller, CommandInfo info)
110110
player!.GiveNamedItem(info.GetArg(2));
111111

112112
if (!Config.HideActivity)
113-
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} gave {player!.PlayerName} {info.GetArg(2)}."));
113+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} gave {player!.PlayerName} {ChatColors.Lime}{info.GetArg(2)}{ChatColors.Default}."));
114114
}
115115

116116
[ConsoleCommand("css_swap", "Swap a player.")]
@@ -152,25 +152,25 @@ public void OnSpecCommand(CCSPlayerController? caller, CommandInfo info)
152152
player!.ChangeTeam(CsTeam.Spectator);
153153

154154
if (!Config.HideActivity)
155-
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} swapped {player!.PlayerName} to spec."));
155+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} moved {player!.PlayerName} to spec."));
156156
}
157157

158-
[ConsoleCommand("css_respawn", "Respawn a dead player.")]
159-
[CommandHelper(1, "<#userid or name>")]
160-
[RequiresPermissions("@css/kick")]
161-
public void OnRespawnCommand(CCSPlayerController? caller, CommandInfo info)
162-
{
163-
if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
164-
{
165-
info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found."));
166-
return;
167-
}
168-
169-
player!.DispatchSpawn();
170-
171-
if (Config.HideActivity)
172-
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} respawned {player!.PlayerName}."));
173-
}
158+
// [ConsoleCommand("css_respawn", "Respawn a dead player.")]
159+
// [CommandHelper(1, "<#userid or name>")]
160+
// [RequiresPermissions("@css/kick")]
161+
// public void OnRespawnCommand(CCSPlayerController? caller, CommandInfo info)
162+
// {
163+
// if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
164+
// {
165+
// info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found."));
166+
// return;
167+
// }
168+
//
169+
// player!.DispatchSpawn();
170+
//
171+
// if (Config.HideActivity)
172+
// Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} respawned {player!.PlayerName}."));
173+
// }
174174

175175
[ConsoleCommand("css_say", "Say to all players.")]
176176
[CommandHelper(1, "<message>")]
@@ -257,14 +257,6 @@ public void OnBuryCommand(CCSPlayerController? caller, CommandInfo info)
257257
return;
258258
}
259259

260-
if (!OriginalPositions.ContainsKey(player!))
261-
OriginalPositions[player!] = new OriginalVec()
262-
{
263-
Position = player!.AbsOrigin!,
264-
Rotation = player!.AbsRotation!,
265-
Velocity = player!.AbsVelocity
266-
};
267-
268260
var newPos = new Vector(player!.Pawn.Value.AbsOrigin!.X, player!.Pawn.Value.AbsOrigin!.Y,
269261
player!.Pawn.Value.AbsOrigin!.Z - 10f);
270262

@@ -279,32 +271,33 @@ public void OnBuryCommand(CCSPlayerController? caller, CommandInfo info)
279271
[RequiresPermissions("@css/ban")]
280272
public void OnUnburyCommand(CCSPlayerController? caller, CommandInfo info)
281273
{
282-
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || !OriginalPositions.ContainsKey(player!))
274+
if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
283275
{
284276
info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found or is not buried."));
285277
return;
286278
}
287279

288-
player!.Pawn.Value.Teleport(OriginalPositions[player!].Position, OriginalPositions[player!].Rotation, OriginalPositions[player!].Velocity);
280+
var newPos = new Vector(player!.Pawn.Value.AbsOrigin!.X, player!.Pawn.Value.AbsOrigin!.Y,
281+
player!.Pawn.Value.AbsOrigin!.Z + 15f);
282+
283+
player!.Pawn.Value.Teleport(newPos, player!.AbsRotation!, player!.AbsVelocity);
289284

290285
if (!Config.HideActivity)
291286
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} unburied {player!.PlayerName}."));
292-
293-
OriginalPositions.Remove(player!);
294287
}
295288

296289
[ConsoleCommand("css_disarm", "Disarm a player.")]
297290
[CommandHelper(1, "<#userid or name>")]
298291
[RequiresPermissions("@css/ban")]
299292
public void OnDisarmCommand(CCSPlayerController? caller, CommandInfo info)
300293
{
301-
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || !OriginalPositions.ContainsKey(player!))
294+
if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
302295
{
303-
info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found or is not buried."));
296+
info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found."));
304297
return;
305298
}
306299

307-
foreach (var weapon in player!.Pawn.Value.WeaponServices.MyWeapons)
300+
foreach (var weapon in player!.Pawn.Value.WeaponServices!.MyWeapons)
308301
{
309302
weapon.Value.Remove();
310303
}
@@ -318,7 +311,7 @@ public void OnDisarmCommand(CCSPlayerController? caller, CommandInfo info)
318311
[RequiresPermissions("@css/slay")]
319312
public void OnHealthCommand(CCSPlayerController? caller, CommandInfo info)
320313
{
321-
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || int.TryParse(info.GetArg(2), out var health))
314+
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || !int.TryParse(info.GetArg(2), out var health))
322315
{
323316
info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found or is not buried."));
324317
return;

BasicAdmin/ServerUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public static bool GetTarget(string target, out CCSPlayerController? player)
2727
return player?.IsValid == true;
2828
}
2929

30-
public static void KickPlayer(string playerName, string? reason = null)
30+
public static void KickPlayer(int? userId, string? reason = null)
3131
{
32-
Server.ExecuteCommand($"kick {playerName} {reason}");
32+
Server.ExecuteCommand($"kickid {userId} {reason}");
3333
}
3434

3535
public static void PrintToCenterAll(string message)

0 commit comments

Comments
 (0)