I made a plugin for my Rust server and am having issues. I haven't been coding C# for too long, maybe a year or two but I only make small private plugins for myself.
If my plugin is loaded, and a user is muted with BetterChat Mute, something allows them to still type. If my plugin is unloaded, they are blocked from typing because of mute. If the plugin isn't reloaded after the first time installing it, user chat prints twice. Any help appreciated.
If my plugin is loaded, and a user is muted with BetterChat Mute, something allows them to still type. If my plugin is unloaded, they are blocked from typing because of mute. If the plugin isn't reloaded after the first time installing it, user chat prints twice. Any help appreciated.
using ConVar;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("CustomCommands", "Ryz0r", "1.2")]
[Description("Custom Commands Plugin made by Ryz0r")]
class CustomCommands : RustPlugin
{
object OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel)
{
var steamID = "76561198907351815";
var serverName = "RustOps";
var count = 0;
foreach (BasePlayer playerz in BasePlayer.activePlayerList)
{
if (playerz.IsAdmin)
{
count ++;
}
}
var cPlayers = ConVar.Admin.ServerInfo().Players;
var mPlayers = ConVar.Admin.ServerInfo().MaxPlayers;
var jPlayers = ConVar.Admin.ServerInfo().Joining;
var qPlayers = ConVar.Admin.ServerInfo().Queued;
if (player == null || string.IsNullOrEmpty(message) || channel != Chat.ChatChannel.Global) {
return null;
} else if (message.Contains("!pop") || message.Contains("!POP") || message.Contains("!players") || message.Contains("online")) {
rust.SendChatMessage(player, $"[{serverName}]", $"<color=#ff0000>There is {count} admin(s) online.</color> <color=#505050>There are currently <color=orange>{cPlayers}/{mPlayers} ({jPlayers} joining) </color> players online with a queue of <color=orange>{qPlayers}</color> players!</color>", steamID);
} else if (message.Contains("!discord")) {
rust.SendChatMessage(player, $"[{serverName}]", $"<color=#505050>Hey, <color=orange>{player.displayName}</color>! You can join the {serverName} Discord to get support from a staff member or view more info on the server. Join:<color=orange> discord link removed </color></color>", steamID);
} else if (message.Contains("!admin")) {
rust.SendChatMessage(player, $"[{serverName}]", $"<color=#505050>Hey, <color=orange>{player.displayName}</color>! If an admin doesn't respond, please join the Discord and view #support! Join:<color=orange> discord link removed </color></color>", steamID);
}
return "Operation completed succesfully.";
}
}
}