Skip to content

Commit 8107400

Browse files
N1Ranrexxar-tc
authored andcommitted
URL to info command (#72)
* URL for InfoCommands
1 parent 14a4750 commit 8107400

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎Essentials/Commands/AdminModule.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public void PlayerCount(int count = -1)
4141
{
4242
if (count == -1)
4343
{
44-
Context.Respond($"Nax player count: {MyMultiplayer.Static.MemberLimit}. Current online players: {MyMultiplayer.Static.MemberCount - 1}");
44+
Context.Respond($"Max player count: {MyMultiplayer.Static.MemberLimit}. Current online players: {MyMultiplayer.Static.MemberCount - 1}");
4545
return;
4646
}
4747

4848
MyMultiplayer.Static.MemberLimit = count;
49-
Context.Respond($"Nax player count: {MyMultiplayer.Static.MemberLimit}. Current online players: {MyMultiplayer.Static.MemberCount - 1}");
49+
Context.Respond($"Max player count: {MyMultiplayer.Static.MemberLimit}. Current online players: {MyMultiplayer.Static.MemberCount - 1}");
5050
}
5151

5252
[Command("runauto", "Runs the auto command with the given name immediately")]

‎Essentials/Commands/InfoModule.cs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Linq;
2+
using Sandbox.Game;
3+
using Sandbox.Game.World;
24
using Torch.Commands;
3-
using Torch.Managers.ChatManager;
45
using Torch.API.Managers;
56
using Torch.Mod;
67
using Torch.Mod.Messages;
@@ -23,21 +24,26 @@ public void List()
2324
Context.Respond(string.Join(", ", EssentialsPlugin.Instance.Config.InfoCommands.Select(i => i.Command).Where(c => !string.IsNullOrEmpty(c))));
2425
}
2526

26-
private static void MessageProcessing(Torch.API.Managers.TorchChatMessage msg, ref bool consumed)
27+
private static void MessageProcessing(TorchChatMessage msg, ref bool consumed)
2728
{
2829
var infoCommands = EssentialsPlugin.Instance.Config.InfoCommands;
2930
if (infoCommands == null)
3031
return;
31-
32+
3233
var c = infoCommands.FirstOrDefault(i => i.Command?.Equals(msg.Message) == true);
3334
if (c == null)
3435
return;
35-
36+
3637
consumed = true;
38+
long playerId = MySession.Static.Players.TryGetIdentityId(msg.AuthorSteamId.Value);
39+
3740
if (!string.IsNullOrEmpty(c.ChatResponse))
3841
EssentialsPlugin.Instance.Torch.CurrentSession?.Managers?.GetManager<IChatManagerServer>()?.SendMessageAsOther("Server", c.ChatResponse, MyFontEnum.Blue, msg.AuthorSteamId.Value);
3942
if (!string.IsNullOrEmpty(c.DialogResponse))
4043
ModCommunication.SendMessageTo(new DialogMessage(c.Command, content: c.DialogResponse), msg.AuthorSteamId.Value);
44+
if (!string.IsNullOrEmpty(c.URL))
45+
MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={c.URL}", playerId);
46+
4147
}
4248
}
4349
}

‎Essentials/InfoCommand.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class InfoCommand : ViewModel
88
private string _command;
99
private string _chatResponse;
1010
private string _dialogResponse;
11+
private string _urlResponse;
1112

1213
public string Command
1314
{
@@ -26,6 +27,12 @@ public string DialogResponse
2627
get => _dialogResponse;
2728
set => SetValue(ref _dialogResponse, value);
2829
}
30+
31+
public string URL
32+
{
33+
get => _urlResponse;
34+
set => SetValue(ref _urlResponse, value);
35+
}
2936

3037
public override string ToString()
3138
{

0 commit comments

Comments
 (0)