Skip to content

Commit f76a3f5

Browse files
committed
tiny update
1 parent 8c8910f commit f76a3f5

2 files changed

Lines changed: 64 additions & 32 deletions

File tree

BasicAdmin/BasicAdmin.cs

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class BasicAdmin : BasePlugin, IPluginConfig<BasicAdminConfig>
2323
{
2424
public override string ModuleName => "BasicAdmin";
2525
public override string ModuleAuthor => "livevilog";
26-
public override string ModuleVersion => "0.1.0";
26+
public override string ModuleVersion => "1.0.0";
2727

2828
public BasicAdminConfig Config {get; set;} = new ();
2929

@@ -51,15 +51,16 @@ public void OnMapCommand(CCSPlayerController? caller, CommandInfo info)
5151
return;
5252
}
5353

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

56-
AddTimer(5f, () =>
56+
AddTimer(3f, () =>
5757
{
5858
Server.ExecuteCommand($"changelevel {map}");
59+
// caller.Discon
5960
});
6061
}
6162

62-
[ConsoleCommand("css_kick", "Kicks a player from the server.")]
63+
[ConsoleCommand("css_kick", "Kick a player from the server.")]
6364
[CommandHelper(1, "<#userid or name> [reason]")]
6465
[RequiresPermissions("@css/kick")]
6566
public void OnKickCommand(CCSPlayerController? caller, CommandInfo info)
@@ -73,6 +74,9 @@ public void OnKickCommand(CCSPlayerController? caller, CommandInfo info)
7374
var reason = info.GetArg(2);
7475

7576
ServerUtils.KickPlayer(player!.PlayerName, reason);
77+
78+
if (!Config.HideActivity)
79+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} slayed {player!.PlayerName}."));
7680
}
7781

7882
[ConsoleCommand("css_slay", "Slay a player.")]
@@ -87,13 +91,14 @@ public void OnSlayCommand(CCSPlayerController? caller, CommandInfo info)
8791
}
8892

8993
player!.Pawn.Value.CommitSuicide(false, true);
94+
9095
if (!Config.HideActivity)
91-
Server.PrintToChatAll($"{caller!.PlayerName} slayed {player!.PlayerName}.");
96+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} slayed {player!.PlayerName}."));
9297
}
9398

9499
[ConsoleCommand("css_give", "Give a player an item.")]
95100
[CommandHelper(2, "<#userid or name> <item name>")]
96-
[RequiresPermissions("@css/kick")]
101+
[RequiresPermissions("@css/cvar")]
97102
public void OnGiveCommand(CCSPlayerController? caller, CommandInfo info)
98103
{
99104
if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
@@ -105,7 +110,7 @@ public void OnGiveCommand(CCSPlayerController? caller, CommandInfo info)
105110
player!.GiveNamedItem(info.GetArg(2));
106111

107112
if (!Config.HideActivity)
108-
Server.PrintToChatAll($"{caller!.PlayerName} gave {player!.PlayerName} {info.GetArg(2)}.");
113+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} gave {player!.PlayerName} {info.GetArg(2)}."));
109114
}
110115

111116
[ConsoleCommand("css_swap", "Swap a player.")]
@@ -130,7 +135,7 @@ public void OnSwapCommand(CCSPlayerController? caller, CommandInfo info)
130135
player!.ChangeTeam(isCs ? CsTeam.Terrorist : CsTeam.CounterTerrorist);
131136

132137
if (!Config.HideActivity)
133-
Server.PrintToChatAll($"{caller!.PlayerName} swapped {player!.PlayerName}.");
138+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} swapped {player!.PlayerName}."));
134139
}
135140

136141
[ConsoleCommand("css_spec", "Change a player to spec.")]
@@ -147,34 +152,37 @@ public void OnSpecCommand(CCSPlayerController? caller, CommandInfo info)
147152
player!.ChangeTeam(CsTeam.Spectator);
148153

149154
if (!Config.HideActivity)
150-
Server.PrintToChatAll($"{caller!.PlayerName} swapped {player!.PlayerName} to spec.");
155+
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} swapped {player!.PlayerName} to spec."));
151156
}
152157

153-
// [ConsoleCommand("css_respawn", "Respawn a dead player.")]
154-
// [CommandHelper(1, "<#userid or name>")]
155-
// [RequiresPermissions("@css/kick")]
156-
// public void OnRespawnCommand(CCSPlayerController? caller, CommandInfo info)
157-
// {
158-
// if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
159-
// {
160-
// info.ReplyToCommand(FormatMessage($"Target {info.GetArg(1)} not found."));
161-
// return;
162-
// }
163-
//
164-
// info.ReplyToCommand(FormatMessage("Not implemented yet."));
165-
// }
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+
}
166174

167175
[ConsoleCommand("css_say", "Say to all players.")]
168176
[CommandHelper(1, "<message>")]
169-
[RequiresPermissions("@css/vote")]
177+
[RequiresPermissions("@css/chat")]
170178
public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo info)
171179
{
172180
Server.PrintToChatAll(FormatAdminMessage(info.GetCommandString[info.GetCommandString.IndexOf(' ')..]));
173181
}
174182

175-
[ConsoleCommand("css_psay", "Say to all players.")]
183+
[ConsoleCommand("css_psay", "Private message a player.")]
176184
[CommandHelper(2, "<#userid or name> <message>")]
177-
[RequiresPermissions("@css/vote")]
185+
[RequiresPermissions("@css/chat")]
178186
public void OnAdminPrivateSayCommand(CCSPlayerController? caller, CommandInfo info)
179187
{
180188
if (!ServerUtils.GetTarget(info.GetArg(1), out var player))
@@ -192,15 +200,15 @@ public void OnAdminPrivateSayCommand(CCSPlayerController? caller, CommandInfo in
192200

193201
[ConsoleCommand("css_csay", "Say to all players (in center).")]
194202
[CommandHelper(1, "<message>")]
195-
[RequiresPermissions("@css/vote")]
203+
[RequiresPermissions("@css/chat")]
196204
public void OnAdminCenterSayCommand(CCSPlayerController? caller, CommandInfo info)
197205
{
198206
ServerUtils.PrintToCenterAll(FormatAdminMessage(info.GetCommandString[info.GetCommandString.IndexOf(' ')..]));
199207
}
200208

201209
[ConsoleCommand("css_hsay", "Say to all players (in hud).")]
202210
[CommandHelper(1, "<message>")]
203-
[RequiresPermissions("@css/vote")]
211+
[RequiresPermissions("@css/chat")]
204212
public void OnAdminHudSayCommand(CCSPlayerController? caller, CommandInfo info)
205213
{
206214
VirtualFunctions.ClientPrintAll(
@@ -240,7 +248,7 @@ public void OnRestartGameCommand(CCSPlayerController? caller, CommandInfo info)
240248

241249
[ConsoleCommand("css_bury", "Bury a player.")]
242250
[CommandHelper(1, "<#userid or name>")]
243-
[RequiresPermissions("@css/changemap")]
251+
[RequiresPermissions("@css/ban")]
244252
public void OnBuryCommand(CCSPlayerController? caller, CommandInfo info)
245253
{
246254
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || player!.Pawn.Value.LifeState != (int) LifeState_t.LIFE_ALIVE)
@@ -266,9 +274,9 @@ public void OnBuryCommand(CCSPlayerController? caller, CommandInfo info)
266274
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} buried {player!.PlayerName}."));
267275
}
268276

269-
[ConsoleCommand("css_unbury", "Bury a player.")]
277+
[ConsoleCommand("css_unbury", "Unbury a player.")]
270278
[CommandHelper(1, "<#userid or name>")]
271-
[RequiresPermissions("@css/changemap")]
279+
[RequiresPermissions("@css/ban")]
272280
public void OnUnburyCommand(CCSPlayerController? caller, CommandInfo info)
273281
{
274282
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || !OriginalPositions.ContainsKey(player!))
@@ -287,7 +295,7 @@ public void OnUnburyCommand(CCSPlayerController? caller, CommandInfo info)
287295

288296
[ConsoleCommand("css_disarm", "Disarm a player.")]
289297
[CommandHelper(1, "<#userid or name>")]
290-
[RequiresPermissions("@css/changemap")]
298+
[RequiresPermissions("@css/ban")]
291299
public void OnDisarmCommand(CCSPlayerController? caller, CommandInfo info)
292300
{
293301
if (!ServerUtils.GetTarget(info.GetArg(1), out var player) || !OriginalPositions.ContainsKey(player!))
@@ -322,6 +330,30 @@ public void OnHealthCommand(CCSPlayerController? caller, CommandInfo info)
322330
Server.PrintToChatAll(FormatAdminMessage($"{caller!.PlayerName} changed {player!.PlayerName}'s health to {health}."));
323331
}
324332

333+
[ConsoleCommand("css_cvar", "Change a cvar.")]
334+
[CommandHelper(2, "<cvar> <value>")]
335+
[RequiresPermissions("@css/cvar")]
336+
public void OnCvarCommand(CCSPlayerController? caller, CommandInfo info)
337+
{
338+
var cvar = ConVar.Find(info.GetArg(1));
339+
340+
if (cvar == null)
341+
{
342+
info.ReplyToCommand(FormatMessage($"Cvar \"{info.GetArg(1)}\" not found."));
343+
return;
344+
}
345+
346+
if (cvar.Name.Equals("sv_cheats") && !AdminManager.PlayerHasPermissions(caller, "@css/cvar"))
347+
{
348+
info.ReplyToCommand(FormatMessage($"You don't have permissions to change \"{info.GetArg(1)}\"."));
349+
return;
350+
}
351+
352+
var value = info.GetArg(2);
353+
354+
Server.ExecuteCommand($"{cvar.Name} {value}");
355+
}
356+
325357
// [ConsoleCommand("css_vote", "Respawn a dead player.")]
326358
// [CommandHelper(1, "<#userid or name>")]
327359
// // [RequiresPermissions("@css/vote")]

BasicAdmin/BasicAdmin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.56" />
10+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.61" />
1111
</ItemGroup>
1212
</Project>

0 commit comments

Comments
 (0)