Trying to make a population plugin to display server population when someone types !players or !pop, but nothing happens when it is typed.
I would like it if it worked in team chat as well. Any suggestions?
What am I doing wrong? Is it because I am using better chat? Do I need to use some sort of other hook?
I would like it if it worked in team chat as well. Any suggestions?
using Rust;
namespace Oxide.Plugins
{
[Info("Population", "Zeeth", "1.0")]
public class Population : RustPlugin
{
void OnPlayerChat(ConsoleSystem.Arg arg)
{
var message = arg.GetString(0);
if (message.Contains("!players"))
{
var playerCount = BasePlayer.activePlayerList.Count;
if (playerCount > 1)
rust.BroadcastChat($"There are currently {playerCount} players online.");
else
rust.BroadcastChat("There is currently 1 player online.");
}
else if (message.Contains("!wipe"))
{
rust.BroadcastChat($"The last wipe was {SaveRestore.SaveCreatedTime}, the next wipe will be the first Thursday of the month.");
}
else if (message.Contains("!pop"))
{
var playerCount = BasePlayer.activePlayerList.Count;
if (playerCount > 1)
rust.BroadcastChat($"There are currently {playerCount} players online.");
else
rust.BroadcastChat("There is currently 1 player online.");
}
}
}
}What am I doing wrong? Is it because I am using better chat? Do I need to use some sort of other hook?