Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Commit

Permalink
Fixed NRE when RA commands are used through console
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlOfDuty committed Jul 25, 2022
1 parent acf5f5f commit 083a24c
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions SCPDiscordPlugin/EventListeners/AdminEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,45 @@ public void OnAdminQuery(AdminQueryEvent ev)
{
return;
}
Dictionary<string, string> variables = new Dictionary<string, string>

if (ev.Admin == null)
{
{ "ipaddress", ev.Admin.IPAddress },
{ "name", ev.Admin.Name },
{ "playerid", ev.Admin.PlayerID.ToString() },
{ "steamid", ev.Admin.GetParsedUserID() },
{ "class", ev.Admin.PlayerRole.RoleID.ToString() },
{ "team", ev.Admin.PlayerRole.Team.ToString() },
{ "handled", ev.Handled.ToString() },
{ "output", ev.Output },
{ "query", ev.Query },
{ "successful", ev.Successful.ToString() }
};
Dictionary<string, string> variables = new Dictionary<string, string>
{
{ "ipaddress", "" },
{ "name", "Server" },
{ "playerid", "" },
{ "steamid", "" },
{ "class", "" },
{ "team", "" },
{ "handled", ev.Handled.ToString() },
{ "output", ev.Output },
{ "query", ev.Query },
{ "successful", ev.Successful.ToString() }
};

this.plugin.SendMessage(Config.GetArray("channels.onadminquery"), "admin.onadminquery", variables);
}
else
{
Dictionary<string, string> variables = new Dictionary<string, string>
{
{ "ipaddress", ev.Admin.IPAddress },
{ "name", ev.Admin.Name },
{ "playerid", ev.Admin.PlayerID.ToString() },
{ "steamid", ev.Admin.GetParsedUserID() },
{ "class", ev.Admin.PlayerRole.RoleID.ToString() },
{ "team", ev.Admin.PlayerRole.Team.ToString() },
{ "handled", ev.Handled.ToString() },
{ "output", ev.Output },
{ "query", ev.Query },
{ "successful", ev.Successful.ToString() }
};

this.plugin.SendMessage(Config.GetArray("channels.onadminquery"), "admin.onadminquery", variables);
}


this.plugin.SendMessage(Config.GetArray("channels.onadminquery"), "admin.onadminquery", variables);
}

public void OnBan(BanEvent ev)
Expand Down

0 comments on commit 083a24c

Please sign in to comment.