// BasePlayer.UpdateRadiation() public static void On_PlayerTakeRadiation(BasePlayer player, float radAmount) { var ptr = new PlayerTakeRadsEvent(Server.GetPlayer(player), player.metabolism.radiation_level.value, radAmount); OnNext("On_PlayerTakeRadiation", ptr); player.metabolism.radiation_level.value = ptr.Next; }
// BasePlayer.Die() public static void PlayerDied(BasePlayer player, HitInfo info) { if (info == null) { info = new HitInfo(); info.damageTypes.Add(player.lastDamage, Single.MaxValue); info.Initiator = player as BaseEntity; } Player victim = Server.GetPlayer(player); if (info.Initiator != null) { PlayerStats statsV = victim.Stats; if (info.Initiator is BasePlayer) { Server.GetPlayer(info.Initiator as BasePlayer).Stats.AddKill(true, false); victim.Stats.AddDeath(true, false); } else if (info.Initiator is BaseNPC) { victim.Stats.AddDeath(false, true); } } Events.PlayerDeathEvent pde = new Events.PlayerDeathEvent(victim, info); OnPlayerDied.OnNext(pde); if (!pde.dropLoot) { player.inventory.Strip(); } }
// Door.RPC_CloseDoor()/RPC_OpenDoor() public static void DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open) { BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock; if (baseLock != null) { bool TryCloseOpen = open ? !baseLock.OnTryToOpen(rpc.player) : !baseLock.OnTryToClose(rpc.player); if (TryCloseOpen) { return; } } DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open); OnDoorUse.OnNext(due); door.SetFlag(BaseEntity.Flags.Open, due.Open); door.Invoke("UpdateLayer", 0f); door.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); if (due.DenyReason != "") { rpc.player.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), due.DenyReason)); } }
public Player ToPlayer() { BasePlayer p = baseEntity.ToPlayer(); if (p == null) { return(null); } return(Server.GetPlayer(p)); }
// BaseAnimal.Die() public static void On_NPCKilled(BaseNPC bnpc, HitInfo info) { if (info.Initiator != null && info.Initiator.ToPlayer() != null) { Server.GetPlayer(info.Initiator as BasePlayer).Stats.AddKill(false, true); } var npc = new NPC(bnpc); OnNext("On_NPCKilled", new Events.NPCDeathEvent(npc, info)); }
public static Player Find(string nameOrSteamidOrIP) { BasePlayer player = BasePlayer.Find(nameOrSteamidOrIP); if (player != null) { return(Server.GetPlayer(player)); } Logger.LogDebug("[Player] Couldn't find player!"); return(null); }
public static Player FindByGameID(ulong steamID) { BasePlayer player = BasePlayer.FindByID(steamID); if (player != null) { return(Server.GetPlayer(player)); } Logger.LogDebug("[Player] Couldn't find player!"); return(null); }
// BasePlayer.Die() public static void On_PlayerDied(BasePlayer player, HitInfo info) { using (TimeWarning.New("Player.Die", 0.1f)) { if (!player.IsDead()) { if (info == null) { info = new HitInfo(); info.damageTypes.Add(player.lastDamage, Single.MaxValue); info.Initiator = player as BaseEntity; } Player victim = Server.GetPlayer(player); if (!((bool)player.CallMethod("WoundInsteadOfDying", info))) { var pde = new PlayerDeathEvent(victim, info); OnNext("On_PlayerDied", pde); if (pde.Die) { if (info.Initiator != null) { PlayerStats statsV = victim.Stats; if (info.Initiator is BasePlayer) { Server.GetPlayer(info.Initiator as BasePlayer).Stats.AddKill(true, false); victim.Stats.AddDeath(true, false); } else if (info.Initiator is BaseNPC) { victim.Stats.AddDeath(false, true); } } if (!pde.dropLoot) { if (player.belt != null) { var vector = new Vector3(UnityEngine.Random.Range(-2f, 2f), 0.2f, UnityEngine.Random.Range(-2f, 2f)); player.belt.DropActive(vector.normalized * 3f); } player.inventory.Strip(); } player.CallMethodOnBase(typeof(BaseCombatEntity), "Die", info); } } } } }
// PlayerLoot.StartLootingItem() public static void On_LootingItem(PlayerLoot playerLoot) { BasePlayer looter = playerLoot.GetComponent <BasePlayer>(); var ile = new Events.ItemLootEvent(playerLoot, Server.GetPlayer(looter), playerLoot.itemSource); OnNext("On_LootingItem", ile); if (ile.Cancel) { playerLoot.Clear(); looter.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), ile.cancelReason)); } }
// PlayerLoot.StartLootingPlayer() public static void StartLootingPlayer(PlayerLoot playerLoot) { BasePlayer looter = playerLoot.GetComponent <BasePlayer>(); var ple = new Events.PlayerLootEvent(playerLoot, Server.GetPlayer(looter), Server.GetPlayer(playerLoot.entitySource as BasePlayer)); OnLootingPlayer.OnNext(ple); if (ple.Cancel) { playerLoot.Clear(); looter.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), ple.cancelReason)); } }
public Player GetLookPlayer(float maxDist = 500f) { RaycastHit hit = GetLookHit(maxDist, LayerMask.GetMask("Player (Server)")); if (hit.collider != null) { BasePlayer basePlayer = hit.collider.GetComponentInParent <BasePlayer>(); if (basePlayer != null) { return(Server.GetPlayer(basePlayer)); } } return(null); }
/* * // In future create an Event, allow people to adjust certain resources to give certain amounts! * public static void ResourceGatherMultiplier(int amount, BaseEntity receiver, ItemAmount itemAmt) * { * int newAmt = amount; * if (receiver.ToPlayer() != null) * newAmt = (int)((double)amount * World.GetInstance().ResourceGatherMultiplier); * * Item item = ItemManager.CreateByItemID(itemAmt.itemid, newAmt); * receiver.GiveItem(item); * }*/ public static void Respawn(BasePlayer player, bool newPos) { Player p = Server.GetPlayer(player); RespawnEvent re = new RespawnEvent(p); OnRespawn.OnNext(re); ++ServerPerformance.spawns; if (newPos) { BasePlayer.SpawnPoint spawnPoint = ServerMgr.FindSpawnPoint(); player.transform.position = spawnPoint.pos; player.transform.rotation = spawnPoint.rot; } if (re.ChangePos && re.SpawnPos != Vector3.zero) { player.transform.position = re.SpawnPos; } player.SetPlayerFlag(BasePlayer.PlayerFlags.Wounded, false); player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, true); player.SetFieldValue("lastTickTime", 0f); player.CancelInvoke("DieFromWounds"); player.StopSpectating(); player.UpdateNetworkGroup(); player.UpdatePlayerCollider(true, false); player.StartSleeping(); player.Invoke("LifeStoryStart", 0f); player.metabolism.Reset(); if (re.StartHealth < Single.Epsilon) { player.InitializeHealth(player.StartHealth(), player.StartMaxHealth()); } else { player.InitializeHealth(re.StartHealth, player.StartMaxHealth()); } if (re.GiveDefault) { player.inventory.GiveDefaultItems(); } if (re.WakeUp) { player.EndSleeping(); } }
// chat.say().Hooks.Chat() public static void On_Command(ConsoleSystem.Arg arg) { Player player = Server.GetPlayer(arg.Player()); string[] args = arg.ArgsStr.Substring(2, arg.ArgsStr.Length - 3).Replace("\\", "").Split(new string[] { " " }, StringSplitOptions.None); CommandEvent cmd = new CommandEvent(player, args); // TODO: do this part in a different function to be documented if (cmd.Cmd == "") { return; } foreach (KeyValuePair <string, BasePlugin> pl in PluginLoader.GetInstance().Plugins) { ChatCommand[] commands = pl.Value.chatCommands.getChatCommands(cmd.Cmd); foreach (ChatCommand chatCmd in commands) { if (chatCmd.callback == null) { continue; } CommandPermissionEvent permission = new CommandPermissionEvent(player, args, chatCmd); OnNext("On_CommandPermission", permission); if (permission.Blocked) { player.Message(permission.Reply); continue; } try { chatCmd.callback(cmd.Args, player); } catch (Exception ex) { Logger.LogError(chatCmd.plugin.FormatException(ex)); } } } OnNext("On_Command", cmd); if (cmd.Reply != "") { arg.ReplyWith(cmd.Reply); } }
public static void On_Respawn(BasePlayer player, Vector3 pos, Quaternion quat) { Player p = Server.GetPlayer(player); RespawnEvent re = new RespawnEvent(p, pos, quat); OnNext("On_Respawn", re); ++ServerPerformance.spawns; player.SetFieldValue("lastPositionValue", pos); player.transform.position = re.SpawnPos; player.transform.rotation = re.SpawnRot; player.SetPlayerFlag(BasePlayer.PlayerFlags.Wounded, false); player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, true); player.SetFieldValue("lastTickTime", 0f); player.CancelInvoke("WoundingEnd"); player.StopSpectating(); player.UpdateNetworkGroup(); player.UpdatePlayerCollider(true, false); player.StartSleeping(); player.Invoke("LifeStoryStart", 0f); player.metabolism.Reset(); if (re.StartHealth < Single.Epsilon) { player.InitializeHealth(player.StartHealth(), player.StartMaxHealth()); } else { player.InitializeHealth(re.StartHealth, player.StartMaxHealth()); } if (re.GiveDefault) { player.inventory.GiveDefaultItems(); } if (re.WakeUp) { player.EndSleeping(); } player.SendNetworkUpdateImmediate(false); player.ClientRPCPlayer(null, player, "StartLoading"); player.SendFullSnapshot(); player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, false); player.ClientRPCPlayer(null, player, "FinishLoading"); }
// Door.RPC_CloseDoor()/RPC_OpenDoor() public static void On_DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open) { if ((open && door.IsOpen()) || (!open && !door.IsOpen())) { return; } DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open); OnNext("On_DoorUse", due); if (!due.Allow) { if (due.DenyReason != "") { rpc.player.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), due.DenyReason)); } return; } bool doaction = true; BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock; if (!due.IgnoreLock && baseLock != null) { doaction = open ? baseLock.OnTryToOpen(rpc.player) : baseLock.OnTryToClose(rpc.player); if (doaction && open && (baseLock.IsLocked() && Time.realtimeSinceStartup - (float)door.GetFieldValue("decayResetTimeLast") > 60)) { Decay.RadialDecayTouch(door.transform.position, 40, 270532608); door.SetFieldValue("decayResetTimeLast", Time.realtimeSinceStartup); } } if (doaction) { door.SetFlag(BaseEntity.Flags.Open, open); door.SendNetworkUpdateImmediate(false); door.CallMethod("UpdateDoorAnimationParameters", false); } }
// BasePlayer.OnDisconnected() public static void On_PlayerDisconnected(BasePlayer player) { var p = Server.GetPlayer(player); if (Server.GetInstance().serverData.ContainsKey("OfflinePlayers", p.SteamID)) { OfflinePlayer op = (Server.GetInstance().serverData.Get("OfflinePlayers", p.SteamID) as OfflinePlayer); op.Update(p); Server.GetInstance().OfflinePlayers[player.userID] = op; } else { OfflinePlayer op = new OfflinePlayer(p); Server.GetInstance().OfflinePlayers.Add(player.userID, op); } if (Server.GetInstance().Players.ContainsKey(player.userID)) { Server.GetInstance().Players.Remove(player.userID); } OnNext("On_PlayerDisconnected", p); }
public static void On_PlayerAssisted(BasePlayer bp) { OnNext("On_PlayerAssisted", Server.GetPlayer(bp)); }
public Inv(PlayerInventory inv) { _inv = inv; owner = Server.GetPlayer(inv.GetComponent <BasePlayer>()); }
public static void On_Chat(ConsoleSystem.Arg arg) { if (arg.ArgsStr.StartsWith("\"/") && !arg.ArgsStr.StartsWith("\"/ ")) { On_Command(arg); return; } if (!ConVar.Chat.enabled) { arg.ReplyWith("Chat is disabled."); } else { if (arg.ArgsStr == "\"\"") { return; } BasePlayer basePlayer = arg.Player(); if (!basePlayer) { return; } ChatEvent pChat = new ChatEvent(Server.GetPlayer(basePlayer), arg); string str = arg.GetString(0, "text"); if (str.Length > 128) { str = str.Substring(0, 128); } if (str.Length <= 0) { return; } if (ConVar.Chat.serverlog) { ServerConsole.PrintColoured(new object[] { ConsoleColor.DarkYellow, basePlayer.displayName + ": ", ConsoleColor.DarkGreen, str }); ConVar.Server.Log("Log.Chat.txt", string.Format("{0}/{1}: {2}\r\n", basePlayer.userID, basePlayer.displayName, str)); Debug.Log(string.Format("[CHAT] {0}: {1}", basePlayer.displayName, str)); } string arg2 = "#5af"; if (basePlayer.IsAdmin()) { arg2 = "#af5"; } if (DeveloperList.IsDeveloper(basePlayer)) { arg2 = "#fa5"; } OnNext("On_Chat", pChat); string text2 = string.Format("<color={2}>{0}</color>: {1}", basePlayer.displayName.Replace('<', '[').Replace('>', ']'), pChat.FinalText, arg2); if (pChat.FinalText != "") { Logger.ChatLog(pChat.BroadcastName, pChat.OriginalText); arg.ReplyWith(pChat.Reply); if (ConVar.Server.globalchat) { ConsoleSystem.Broadcast("chat.add", basePlayer.userID, text2, 1); } else { float num = 2500; foreach (Connection current in Net.sv.connections) { if (current.player != null) { float sqrMagnitude = (current.player.transform.position - basePlayer.transform.position).sqrMagnitude; if (sqrMagnitude <= num) { ConsoleSystem.SendClientCommand(current, "chat.add", basePlayer.userID, text2, Mathf.Clamp01(num - sqrMagnitude + 0.2f)); } } } } } } }
public static void On_PlayerWakeUp(BasePlayer bp) { OnNext("On_PlayerWakeUp", Server.GetPlayer(bp)); }
public static void CombatEntityHurt(BaseCombatEntity combatEnt, HitInfo info) { try { Assert.Test(combatEnt.isServer, "This should be called serverside only"); if (combatEnt.IsDead()) { return; } BaseNPC npc = combatEnt.GetComponent <BaseNPC>(); BaseCorpse corpse = combatEnt.GetComponent <BaseCorpse>(); BasePlayer player = combatEnt.GetComponent <BasePlayer>(); if (!SkinnedMeshCollider.ScaleDamage(info)) { if (combatEnt.baseProtection != null) { combatEnt.baseProtection.Scale(info.damageTypes); if (ConsoleGlobal.developer > 1) { Debug.Log("BaseProtection Scaling for entity :" + combatEnt.name); } } } else { if (ConsoleGlobal.developer > 1) { Debug.Log("SMC scaling damage for entity :" + combatEnt.name); } } HurtEvent he; if (player != null) { Player p = Server.GetPlayer(player); if (p.Teleporting) { for (int i = 0; i < info.damageTypes.types.Length; i++) { info.damageTypes.types[i] = 0f; } } he = new PlayerHurtEvent(p, info); OnPlayerHurt.OnNext(he as PlayerHurtEvent); } else if (npc != null) { he = new NPCHurtEvent(new NPC(npc), info); OnNPCHurt.OnNext(he as NPCHurtEvent); } else if (corpse != null) { he = new CorpseHurtEvent(corpse, info); OnCorpseHurt.OnNext(he as CorpseHurtEvent); } else { he = new CombatEntityHurtEvent(combatEnt, info); OnCombatEntityHurt.OnNext(he as CombatEntityHurtEvent); } // the DebugHurt() method if (vis.attack) { if (info.PointStart != info.PointEnd) { ConsoleSystem.Broadcast("ddraw.arrow", new object[] { 60, Color.cyan, info.PointStart, info.PointEnd, 0.1 }); ConsoleSystem.Broadcast("ddraw.sphere", new object[] { 60, Color.cyan, info.HitPositionWorld, 0.05 }); } string text = String.Empty; for (int i = 0; i < info.damageTypes.types.Length; i++) { float num = info.damageTypes.types [i]; if (num != 0) { string text2 = text; text = String.Concat(new string[] { text2, " ", ((Rust.DamageType)i).ToString().PadRight(10), num.ToString("0.00"), "\r\n" }); } } string text3 = String.Concat(new object[] { "<color=lightblue>Damage:</color>".PadRight(10), info.damageTypes.Total().ToString("0.00"), "\r\n<color=lightblue>Health:</color>".PadRight(10), combatEnt.health.ToString("0.00"), " / ", (combatEnt.health - info.damageTypes.Total() > 0) ? "<color=green>" : "<color=red>", (combatEnt.health - info.damageTypes.Total()).ToString("0.00"), "</color>", "\r\n<color=lightblue>Hit Ent:</color>".PadRight(10), combatEnt, "\r\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator, "\r\n<color=lightblue>Weapon:</color>".PadRight(10), info.Weapon, "\r\n<color=lightblue>Damages:</color>\r\n", text }); ConsoleSystem.Broadcast("ddraw.text", new object[] { 60, Color.white, info.HitPositionWorld, text3 }); } combatEnt.health -= info.damageTypes.Total(); if (ConsoleGlobal.developer > 1) { Debug.Log("[Combat]".PadRight(10) + combatEnt.gameObject.name + " hurt " + info.damageTypes.GetMajorityDamageType() + "/" + info.damageTypes.Total() + " - " + combatEnt.health.ToString("0") + " health left" ); } combatEnt.lastDamage = info.damageTypes.GetMajorityDamageType(); if (combatEnt.health <= 0) { combatEnt.Die(info); } } catch (Exception ex) { Logger.LogError("[Hooks] Error in CombatEntityHurt hook."); Logger.LogException(ex); } }
public static void On_CombatEntityHurt(BaseCombatEntity combatEnt, HitInfo info, bool useProtection = true) { try { Assert.Test(combatEnt.isServer, "This should be called serverside only"); if (combatEnt.IsDead()) { return; } using (TimeWarning.New("Hurt", 50)) { BaseNPC npc = combatEnt.GetComponent <BaseNPC>(); BaseCorpse corpse = combatEnt.GetComponent <BaseCorpse>(); BasePlayer player = combatEnt.GetComponent <BasePlayer>(); combatEnt.ScaleDamage(info, useProtection); HurtEvent he; if (player != null) { Player p = Server.GetPlayer(player); if (p.Teleporting) { for (int i = 0; i < info.damageTypes.types.Length; i++) { info.damageTypes.types[i] = 0f; } } he = new PlayerHurtEvent(p, info); OnNext("On_PlayerHurt", he); } else if (npc != null) { he = new NPCHurtEvent(new NPC(npc), info); OnNext("On_NPCHurt", he); } else if (corpse != null) { he = new CorpseHurtEvent(corpse, info); OnNext("On_CorpseHurt", he); } else { he = new CombatEntityHurtEvent(combatEnt, info); OnNext("On_CombatEntityHurt", he); } if (info.PointStart != Vector3.zero) { DirectionProperties[] directionProperties = (DirectionProperties[])combatEnt.GetFieldValue("propDirection"); for (int i = 0; i < directionProperties.Length; i++) { if (!(directionProperties[i].extraProtection == null)) { if (directionProperties[i].IsPointWithinRadius(combatEnt.transform, info.PointStart)) { directionProperties[i].extraProtection.Scale(info.damageTypes); } } } } // the DebugHurt() method if (ConVar.Vis.attack) { if (info.PointStart != info.PointEnd) { ConsoleSystem.Broadcast("ddraw.arrow", new object[] { 60, Color.cyan, info.PointStart, info.PointEnd, 0.1 }); ConsoleSystem.Broadcast("ddraw.sphere", new object[] { 60, Color.cyan, info.HitPositionWorld, 0.05 }); } string text = String.Empty; for (int i = 0; i < info.damageTypes.types.Length; i++) { float num = info.damageTypes.types[i]; if (num != 0) { string text2 = text; text = String.Concat(new string[] { text2, " ", ((Rust.DamageType)i).ToString().PadRight(10), num.ToString("0.00"), "\r\n" }); } } string text3 = String.Concat(new object[] { "<color=lightblue>Damage:</color>".PadRight(10), info.damageTypes.Total().ToString("0.00"), "\r\n<color=lightblue>Health:</color>".PadRight(10), combatEnt.health.ToString("0.00"), " / ", (combatEnt.health - info.damageTypes.Total() > 0) ? "<color=green>" : "<color=red>", (combatEnt.health - info.damageTypes.Total()).ToString("0.00"), "</color>", "\r\n<color=lightblue>Hit Ent:</color>".PadRight(10), combatEnt, "\r\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator, "\r\n<color=lightblue>Weapon:</color>".PadRight(10), info.Weapon, "\r\n<color=lightblue>Damages:</color>\r\n", text }); ConsoleSystem.Broadcast("ddraw.text", new object[] { 60, Color.white, info.HitPositionWorld, text3 }); } combatEnt.health -= info.damageTypes.Total(); combatEnt.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); if (ConVar.Global.developer > 1) { Debug.Log(string.Concat(new object[] { "[Combat]".PadRight(10), combatEnt.gameObject.name, " hurt ", info.damageTypes.GetMajorityDamageType(), "/", info.damageTypes.Total(), " - ", combatEnt.health.ToString("0"), " health left" })); } combatEnt.lastDamage = info.damageTypes.GetMajorityDamageType(); combatEnt.lastAttacker = info.Initiator; combatEnt.SetFieldValue("_lastAttackedTime", Time.time); if (combatEnt.health <= 0f) { combatEnt.Die(info); BuildingBlock bb = combatEnt.GetComponent <BuildingBlock>(); if (bb != null) { OnNext("On_BuildingPartDestroyed", new BuildingPartDestroyedEvent(bb, info)); } } } } catch (Exception ex) { Logger.LogError("[Hooks] Error in CombatEntityHurt hook."); Logger.LogException(ex); } }
// chat.say().Hooks.Chat() public static void Command(ConsoleSystem.Arg arg) { Player player = Server.GetPlayer(arg.Player()); string[] args = arg.ArgsStr.Substring(2, arg.ArgsStr.Length - 3).Replace("\\", "").Split(new string[] { " " }, StringSplitOptions.None); CommandEvent cmd = new CommandEvent(player, args); if (cmd.cmd == "") { return; } foreach (KeyValuePair <string, BasePlugin> pl in PluginLoader.GetInstance().Plugins) { ChatCommand[] commands = pl.Value.chatCommands.getChatCommands(cmd.cmd); foreach (ChatCommand chatCmd in commands) { if (chatCmd.callback == null) { continue; } CommandPermissionEvent permission = new CommandPermissionEvent(player, args, chatCmd); OnCommandPermission.OnNext(permission); if (permission.blocked) { player.Message(permission.Reply); continue; } try { chatCmd.callback(cmd.args, player); } catch (Exception ex) { Logger.LogError(chatCmd.plugin.FormatException(ex)); } } } if (Config.GetInstance().GetBoolValue("Commands", "enabled", true)) { // TODO: make a plugin from these, no need to be in the core if (cmd.cmd == Config.GetInstance().GetValue("Commands", "ShowMyStats", "mystats")) { PlayerStats stats = player.Stats; player.Message(String.Format("You have {0} kills and {1} deaths!", stats.Kills, stats.Deaths)); player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats.TotalDamageTaken, stats.TotalDamageDone)); return; } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "ShowStatsOther", "statsof")) { Player pOther = Player.Find(String.Join(" ", cmd.args)); if (pOther != null) { PlayerStats stats2 = pOther.Stats; player.Message(String.Format(pOther.Name + " has {0} kills and {1} deaths!", stats2.Kills, stats2.Deaths)); player.Message(String.Format(pOther.Name + " has taken {0} dmg, and caused {1} in total!", stats2.TotalDamageTaken, stats2.TotalDamageDone)); return; } player.Message("Can't find player: " + String.Join(" ", cmd.args)); return; } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "ShowLocation", "whereami")) { player.Message(player.Location.ToString()); return; } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "ShowOnlinePlayers", "players")) { string msg = Server.GetInstance().Players.Count == 1 ? "You are alone!" : String.Format("There are: {0} players online!", Server.GetInstance().Players.Count); player.Message(msg); return; } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "Help", "help")) { foreach (string key in Config.GetInstance().PlutonConfig.EnumSection("HelpMessage")) { player.Message(Config.GetInstance().GetValue("HelpMessage", key)); } } List <ChatCommands> cc = new List <ChatCommands>(); foreach (KeyValuePair <string, BasePlugin> pl in PluginLoader.GetInstance().Plugins) { cc.Add(pl.Value.chatCommands); } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "Commands", "commands")) { List <string> list = new List <string>(); foreach (ChatCommands cm in cc) { list.AddRange(cm.getCommands()); } player.Message(String.Join(", ", list.ToArray())); } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "Description", "whatis")) { if (cmd.args.Length < 1) { player.Message("You must provide a command name"); } else { List <string> list = new List <string>(); foreach (ChatCommands cm in cc) { list.AddRange(cm.getDescriptions(cmd.args[0])); } if (list.Count > 0) { player.Message(String.Join("\r\n", list.ToArray())); } } } if (cmd.cmd == Config.GetInstance().GetValue("Commands", "Usage", "howto")) { if (cmd.args.Length < 1) { player.Message("You must provide a command name"); } else { List <string> list = new List <string>(); foreach (ChatCommands cm in cc) { list.AddRange(cm.getUsages(cmd.args[0])); } foreach (var item in list) { player.Message(String.Format("/{0} {1}", cmd.args[0], item)); } } } } OnCommand.OnNext(cmd); if (cmd.Reply != "") { arg.ReplyWith(cmd.Reply); } }