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 { ["Info"] = "List of current Players/sleepers\n\n", ["NoPermission"] = "You do not have permission to use that command!", ["Online"] = "Online : {0}/{1}\n", ["Prefix"] = "[PlayerListing] ", ["Sleepers"] = "Sleepers : {0}\n", ["Spacing"] = "-------------\n", ["Allive"] = "Allive : {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 } }