C#:
using System.Collections.Generic;
#region Changelogs and ToDo
/**********************************************************************
*
* 1.0.1 : Language file updated remove the old
* : Message formats can now be changed in the language file
*
**********************************************************************/
#endregion
namespace Oxide.Plugins
{
[Info("Player Listing", "Krungh Crow", "1.0.1", ResourceId = 157)]
[Description("Prints sleepers and online playercount to chat")]
class PlayerListing : RustPlugin
{
#region Variables
const ulong chaticon = 0;
const string Players_Perm = "playerlisting.players";
string prefix = "";
#endregion
#region Hooks
void Init()
{
permission.RegisterPermission(Players_Perm, this);
prefix = msg("Prefix");
}
#endregion
#region LanguageAPI
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["Info"] = "<color=green>List of current Players/sleepers</color>\n\n",
["NoPermission"] = "<color=red>You do not have permission to use that command!</color>",
["Online"] = "<color=orange>Online</color> : {0}/{1}\n",
["Prefix"] = "[<color=yellow>PlayerListing</color>] ",
["Sleepers"] = "<color=orange>Sleepers</color> : {0}\n",
["Spacing"] = "-------------\n",
["Allive"] = "<color=orange>Allive</color> : {0}",
}, this);
}
#endregion
#region Commands
[ChatCommand("players")]
private void cmdplayers(BasePlayer player, string command, string[] args)
{
if (!permission.UserHasPermission(player.UserIDString, Players_Perm))
{
Player.Message(player, prefix + string.Format(msg("NoPermission", player.UserIDString)), chaticon);
return;
}
if (permission.UserHasPermission(player.UserIDString, Players_Perm))
{
var _online = BasePlayer.activePlayerList.Count;
var _sleeping = BasePlayer.sleepingPlayerList.Count;
var _total = (_online + _sleeping);
var _max = ConVar.Server.maxplayers;
Player.Message(player,
prefix + "\n"+ msg("Info")
+ string.Format(msg("Online", player.UserIDString), _online, _max)
+ string.Format(msg("Sleepers", player.UserIDString), _sleeping)
+ msg("Spacing")
+ string.Format(msg("Allive", player.UserIDString), _total)
, chaticon);
}
}
#endregion
#region Methods
private string msg(string key, string id = null) => lang.GetMessage(key, this, id);
#endregion
}
}