public void OutputMyIds() { StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); foreach (KeyValuePair <int, MarketItem> item in list.items) { if (item.Value.SellerSteamId.Equals(Context.Player.SteamUserId)) { if (item.Value.Status == ItemStatus.Listed) { sb.AppendLine("Item ID: " + item.Key + " - Item Name " + item.Value.Name + " - Listed Price " + String.Format("{0:n0}", item.Value.Price)); } if (item.Value.Status == ItemStatus.Sold) { sb2.AppendLine(item.Value.Name + " - Sold for " + String.Format("{0:n0}", item.Value.Price) + " SC. Sold at " + item.Value.soldAt.ToString()); } } } sb.AppendLine(""); sb.AppendStringBuilder(sb2); DialogMessage m = new DialogMessage("The Market", "", sb.ToString()); ModCommunication.SendMessageTo(m, Context.Player.SteamUserId); }
public void FactionInfo() { StringBuilder sb = new StringBuilder(); foreach (var factionID in MySession.Static.Factions) { double memberCount; var faction = factionID.Value; memberCount = faction.Members.Count(); sb.AppendLine(); if (faction.IsEveryoneNpc()) { sb.AppendLine($"{faction.Tag} - {memberCount} NPC found in this faction"); continue; } sb.AppendLine($"{faction.Tag} - {memberCount} players in this faction"); foreach (var player in faction?.Members) { if (!MySession.Static.Players.HasIdentity(player.Key) && !MySession.Static.Players.IdentityIsNpc(player.Key) || string.IsNullOrEmpty(MySession.Static?.Players?.TryGetIdentity(player.Value.PlayerId).DisplayName)) { continue; //This is needed to filter out players with no id. } sb.AppendLine($"{MySession.Static?.Players?.TryGetIdentity(player.Value.PlayerId).DisplayName}"); } } if (Context.Player == null) { Context.Respond(sb.ToString()); } else if (Context?.Player?.SteamUserId > 0) { ModCommunication.SendMessageTo(new DialogMessage("Faction Info", null, sb.ToString()), Context.Player.SteamUserId); } }
public void VoteDebgug() { var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine($"Current Vote Status: {VoteStatus.ToString()}"); sb.AppendLine($"Current Vote Name: {voteInProgress}"); sb.AppendLine($"Current vote count: {_voteReg.Count}"); sb.AppendLine(); sb.AppendLine("Last vote info"); if (lastVoteName != null) { sb.AppendLine($"Last vote: {lastVoteName}"); } sb.AppendLine($"Last Vote Result: {voteResult.ToString()}"); sb.AppendLine($"Last vote percent: {voteResultPercentage}"); if (Context.Player == null) { Context.Respond(sb.ToString()); } else if (Context?.Player?.SteamUserId > 0) { ModCommunication.SendMessageTo(new DialogMessage("List of Online Players", null, sb.ToString()), Context.Player.SteamUserId); } }
public void DetectRotorguns() { List <string> args = Context.Args; bool gps = false; for (int i = 0; i < args.Count; i++) { if (args[i] == "-gps") { gps = true; } } StringBuilder sb = new StringBuilder(); foreach (var group in MyCubeGridGroups.Static.Physical.Groups) { int gridsWithRotorCount = CheckGroup(out MyCubeGrid biggestGrid, group); if (biggestGrid != null && gridsWithRotorCount >= Plugin.MinRotorGridCount) { var gridOwnerList = biggestGrid.BigOwners; var ownerCnt = gridOwnerList.Count; var gridOwner = 0L; if (ownerCnt > 0 && gridOwnerList[0] != 0) { gridOwner = gridOwnerList[0]; } else if (ownerCnt > 1) { gridOwner = gridOwnerList[1]; } var position = biggestGrid.PositionComp.GetPosition(); sb.AppendLine($"{biggestGrid.DisplayName}"); sb.AppendLine($" Owned by {PlayerUtils.GetPlayerNameById(gridOwner)}"); sb.AppendLine($" Location: X: {position.X.ToString("#,##0.00")}, Y: {position.Y.ToString("#,##0.00")}, Z: {position.Z.ToString("#,##0.00")}"); if (gps && Context.Player != null) { var gridGPS = MyAPIGateway.Session?.GPS.Create("--" + biggestGrid.DisplayName, ($"{biggestGrid.DisplayName} - {biggestGrid.GridSizeEnum} - {biggestGrid.BlocksCount} blocks"), position, true); MyAPIGateway.Session?.GPS.AddGps(Context.Player.IdentityId, gridGPS); } } } if (Context.Player == null) { Context.Respond($"Potential Rotorguns"); Context.Respond(sb.ToString()); } else { ModCommunication.SendMessageTo(new DialogMessage("Potential Rotorguns", $"At least " + Plugin.MinRotorGridCount + " rotors on different subgrids.", sb.ToString()), Context.Player.SteamUserId); } }
private static void MessageProcessing(Torch.API.Managers.TorchChatMessage msg, ref bool consumed) { var infoCommands = EssentialsPlugin.Instance.Config.InfoCommands; if (infoCommands == null) { return; } var c = infoCommands.FirstOrDefault(i => i.Command.Equals(msg.Message)); if (c == null) { return; } consumed = true; if (!string.IsNullOrEmpty(c.ChatResponse)) { EssentialsPlugin.Instance.Torch.CurrentSession?.Managers?.GetManager <IChatManagerServer>()?.SendMessageAsOther("Server", c.ChatResponse, MyFontEnum.Blue, msg.AuthorSteamId.Value); } if (!string.IsNullOrEmpty(c.DialogResponse)) { ModCommunication.SendMessageTo(new DialogMessage(c.Command, content: c.DialogResponse), msg.AuthorSteamId.Value); } }
public void List() { var id = Context.Player?.IdentityId ?? 0; StringBuilder sb = new StringBuilder(); foreach (var entity in MyEntities.GetEntities()) { if (!(entity is MyCubeGrid grid) || grid.Projector != null) { continue; } if (grid.BigOwners.Contains(id)) { sb.AppendLine($"{grid.DisplayName} - {grid.GridSizeEnum} - {grid.BlocksCount} blocks - Position {(EssentialsPlugin.Instance.Config.UtilityShowPosition ? grid.PositionComp.GetPosition().ToString() : "Unknown")}"); if (EssentialsPlugin.Instance.Config.MarkerShowPosition) { // Add temp GPS coordinates on request. var gridGPS = MyAPIGateway.Session?.GPS.Create(grid.DisplayName, ($"{grid.DisplayName} - {grid.GridSizeEnum} - {grid.BlocksCount} blocks"), grid.PositionComp.GetPosition(), true, true); MyAPIGateway.Session?.GPS.AddGps(Context.Player.IdentityId, gridGPS); } } } ModCommunication.SendMessageTo(new DialogMessage("Grids List", $"Ships/Stations owned by {Context.Player.DisplayName}", sb.ToString()), Context.Player.SteamUserId); }
public void HasCommandPermission(Command command, IMyPlayer player, bool hasPermission, ref bool?hasPermissionOverride) { if (!EssentialsPlugin.Instance.Config.EnableRanks) { return; } string playersRank = PlayerAccountModule.GetRank(player.SteamUserId); string cmd = ""; foreach (var part in command.Path) { cmd += part + " "; } cmd = cmd.TrimEnd(); bool hasPerm = RankHasPermission(playersRank, cmd, player.SteamUserId); if (!debug) { Log.Error($"HasPerm returned {hasPerm}"); } if (EssentialsPlugin.Instance.Config.OverrideVanillaPerms && hasPerm) { hasPermissionOverride = hasPerm; } if (hasPermission && !hasPerm) { hasPermissionOverride = hasPerm; Log.Info($"{player.DisplayName} tried to use the blocked command '{cmd}'"); ModCommunication.SendMessageTo(new NotificationMessage($"You do not have permission to use that command!", 10000, "Red"), player.SteamUserId); } }
private static void MessageProcessing(TorchChatMessage msg, ref bool consumed) { var infoCommands = EssentialsPlugin.Instance.Config.InfoCommands; if (infoCommands == null) { return; } var c = infoCommands.FirstOrDefault(i => i.Command?.Equals(msg.Message) == true); if (c == null) { return; } consumed = true; long playerId = MySession.Static.Players.TryGetIdentityId(msg.AuthorSteamId.Value); if (!string.IsNullOrEmpty(c.ChatResponse)) { EssentialsPlugin.Instance.Torch.CurrentSession?.Managers?.GetManager <IChatManagerServer>()?.SendMessageAsOther("Server", c.ChatResponse, MyFontEnum.Blue, msg.AuthorSteamId.Value); } if (!string.IsNullOrEmpty(c.DialogResponse)) { ModCommunication.SendMessageTo(new DialogMessage(c.Command, content: c.DialogResponse), msg.AuthorSteamId.Value); } if (!string.IsNullOrEmpty(c.URL)) { MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={c.URL}", playerId); } }
private void ListGridsInternal(bool biggest, bool furthest, bool abandoned, bool biggestBlocks) { StringBuilder sb = new StringBuilder(); long seconds = GetTimeMs(); if (biggest) { AddGridsToSb(BiggestGridDetectionPcuStrategy.INSTANCE, Plugin.MinPCU, Plugin.MaxDistancePlayersBiggest, Plugin.IgnoreOfflineBiggest, sb, seconds); } if (furthest) { AddGridsToSb(FurthestGridDetectionStrategy.INSTANCE, Plugin.MinDistance, Plugin.MaxDistancePlayersFurthest, Plugin.IgnoreOfflineFurthest, sb, seconds); } if (abandoned) { AddGridsToSb(AbandonedGridDetectionStrategy.INSTANCE, Plugin.MinDays, -1, false, sb, seconds); } if (biggestBlocks) { AddGridsToSb(BiggestGridDetectionBlocksStrategy.INSTANCE, Plugin.MinBlocks, Plugin.MaxDistancePlayersBiggestBlocks, Plugin.IgnoreOfflineBiggestBlocks, sb, seconds); } if (Context.Player == null) { Context.Respond(sb.ToString()); } else { ModCommunication.SendMessageTo(new DialogMessage("List of Grids", "Top " + Plugin.TopGrids + " grids", sb.ToString()), Context.Player.SteamUserId); } }
public void PBStatus() { var player = Context?.Player; if (player == null) { return; } var sb = new StringBuilder(); if (ProfilerConfig.perPlayer && PBPlayerTracker.players.ContainsKey(player.IdentityId)) { double playerMax = ProfilerConfig.maxTickTime; if (PBPlayerTracker.players[player.IdentityId].OverrideEnabled) { playerMax = PBPlayerTracker.players[player.IdentityId].PersonalMaxMs; } sb.AppendLine($"Player \"{player.DisplayName}\" Ms: {PBPlayerTracker.players[player.IdentityId].ms:F3}/{playerMax}\n"); } foreach (var pb in PBData.pbPair.Values.Where(v => v.PB.OwnerId == player.IdentityId).OrderByDescending(v => v.AverageMS)) { sb.AppendLine($"PB: \"{pb.PBID}\" Ms: {pb.AverageMS:F3}"); } ModCommunication.SendMessageTo(new DialogMessage($"PBLimiter Status", null, sb.ToString()), Context.Player.SteamUserId); }
public void EcoSet(string Player, long amount) { if (Player != "*") { var p = Utilities.GetPlayerByNameOrId(Player); if (p == null) { Context.Respond("Player not found"); return; } p.TryGetBalanceInfo(out long balance); long difference = (balance - amount); p.RequestChangeBalance(-difference); ModCommunication.SendMessageTo(new NotificationMessage($"Your balance has been set to {amount} credits!", 10000, "Blue"), p.SteamUserId); } else { foreach (var p in MySession.Static.Players.GetAllPlayers()) { long IdentityID = MySession.Static.Players.TryGetIdentityId(p.SteamId); long balance = MyBankingSystem.GetBalance(IdentityID); long difference = (balance - amount); MyBankingSystem.ChangeBalance(IdentityID, -difference); ModCommunication.SendMessageTo(new NotificationMessage($"Your balance has been set to {amount} credits!", 10000, "Blue"), p.SteamId); } } Context.Respond($"Balance(s) set to {amount}"); }
public void EcoTake(string Player, long amount) { if (Player != "*") { var p = Utilities.GetPlayerByNameOrId(Player); if (p == null) { Context.Respond("Player not found"); return; } long changefactor = 0 - amount; p.RequestChangeBalance(changefactor); ModCommunication.SendMessageTo(new NotificationMessage($"{amount} credits have been taken to your virtual account", 10000, "Blue"), p.SteamUserId); } else { foreach (var p in MySession.Static.Players.GetAllPlayers()) { long IdentityID = MySession.Static.Players.TryGetIdentityId(p.SteamId); long balance = MyBankingSystem.GetBalance(IdentityID); MyBankingSystem.ChangeBalance(IdentityID, -amount); ModCommunication.SendMessageTo(new NotificationMessage($"{amount} credits have been taken to your virtual account", 10000, "Blue"), p.SteamId); } } Context.Respond($"{amount} credits taken from account(s)"); }
public void EcoGive(string Player, long amount) { if (Player != "*") { var p = Utilities.GetPlayerByNameOrId(Player); if (p == null) { Context.Respond("Player not found"); return; } p.TryGetBalanceInfo(out long balance); Context.Respond($"new bal will be {balance + amount}"); p.RequestChangeBalance(amount); ModCommunication.SendMessageTo(new NotificationMessage($"{amount} credits have been added to your virtual account", 10000, "Blue"), p.SteamUserId); } else { foreach (var p in MySession.Static.Players.GetAllPlayers()) { long IdentityID = MySession.Static.Players.TryGetIdentityId(p.SteamId); MyBankingSystem.ChangeBalance(IdentityID, amount); ModCommunication.SendMessageTo(new NotificationMessage($"{amount} credits have been added to your virtual account", 10000, "Blue"), p.SteamId); } } Context.Respond($"{amount} credits given to account(s)"); }
public void EcoTop() { StringBuilder ecodata = new StringBuilder(); ecodata.AppendLine("Summary of balanaces accross the server"); Dictionary <ulong, long> balances = new Dictionary <ulong, long>(); foreach (var p in MySession.Static.Players.GetAllPlayers()) { long IdentityID = MySession.Static.Players.TryGetIdentityId(p.SteamId); long balance = MyBankingSystem.GetBalance(IdentityID); balances.Add(p.SteamId, balance); } var sorted = balances.OrderByDescending(x => x.Value).ThenBy(x => x.Key); foreach (var value in sorted) { var test = MySession.Static.Players.TryGetIdentityNameFromSteamId(value.Key); ecodata.AppendLine($"Player: {MySession.Static.Players.TryGetIdentityNameFromSteamId(value.Key).ToString()} - Balance: {value.Value.ToString()}"); } if (Context.Player == null) { Context.Respond(ecodata.ToString()); return; } ModCommunication.SendMessageTo(new DialogMessage("Public balance list", "List of players and their credit balances", ecodata.ToString()), Context.Player.SteamUserId); }
public void ListAutoRunning() { var commands = new List <AutoCommand>(EssentialsPlugin.Instance.Config.AutoCommands.Where(x => x.IsRunning())); if (commands.Count == 0) { Context.Respond("No active autocommand found"); return; } StringBuilder sb = new StringBuilder(); int count = 1; foreach (var command in commands) { sb.AppendLine((count++) + " " + command.Name); } if (Context.Player == null) { Context.Respond("Current AutoCommands:"); Context.Respond(sb.ToString()); } else { ModCommunication.SendMessageTo(new DialogMessage("Current AutoCommands", $"Found {commands.Count} Commands", sb.ToString()), Context.Player.SteamUserId); } }
public void MyLimit() { if (!BlockLimiterConfig.Instance.EnableLimits) { Context.Respond("Plugin disabled"); return; } if (Context.Player == null || Context.Player.IdentityId == 0) { Context.Respond("Command can only be run in-game by players"); return; } var playerId = Context.Player.IdentityId; var newList = BlockLimiterConfig.Instance.AllLimits; if (!newList.Any()) { Context.Respond("No limit item found"); return; } var sb = Utilities.GetLimit(playerId); if (sb.Length == 0) { Context.Respond("You have no block within set limit"); return; } ModCommunication.SendMessageTo(new DialogMessage(BlockLimiterConfig.Instance.ServerName, "PlayerLimit", sb.ToString()), Context.Player.SteamUserId); }
public void ListPlayers() { if (MySession.Static.Players.GetOnlinePlayerCount() == 0) { Context.Respond("No players online"); return; } StringBuilder sb = new StringBuilder(); var players = MySession.Static.Players.GetOnlinePlayers(); if (players.Count == 0) { Context.Respond("No Players Online"); return; } sb.AppendLine($"Found {players.Count} Players on server"); foreach (var player in players) { sb.AppendLine($"{player.DisplayName}"); sb.AppendLine($">PlayerId: {player.Identity.IdentityId}"); sb.AppendLine($">SteamId: {player.Id.SteamId}"); } if (Context.Player == null) { Context.Respond(sb.ToString()); } else if (Context?.Player?.SteamUserId > 0) { ModCommunication.SendMessageTo(new DialogMessage("List of Online Players", $"{players.Count} players Online", sb.ToString()), Context.Player.SteamUserId); } }
public void VoteList() { StringBuilder sb = new StringBuilder(); var voteCommands = new List <AutoCommand>(EssentialsPlugin.Instance.Config.AutoCommands.Where(x => x.CommandTrigger == Trigger.Vote)); if (Context.Player == null) { sb.AppendLine($"Found {voteCommands.Count}"); } var c = 1; foreach (var command in voteCommands) { if (string.IsNullOrEmpty(command.Name)) { continue; } sb.AppendLine($"{c}. {command.Name}"); c++; } if (Context.Player == null) { Context.Respond(sb.ToString()); return; } ModCommunication.SendMessageTo(new DialogMessage("Vote Commands", $"Found {voteCommands.Count} vote commands", sb.ToString()), Context.Player.SteamUserId); }
public void Config() { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("settings")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("open"), Module.Config.Open)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("max"), Module.Config.MaxNumber)); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("ticket")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("prix"), Module.Config.TicketPrix)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("multiple"), Module.Config.TicketMultiple)); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("gain")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("gainTotal"), Module.Config.GainTotal)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("gain"), Module.Config.Gain)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("maxi"), Module.Config.GainMax)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("cumulate"), Module.Config.GainCumulate)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("partage"), Module.Config.GainPartage)); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("draw")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("auto"), Module.Config.DrawAuto)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("days"), (Module.Config.DrawDays.Sunday ? ", " + TranslatesUtils.GetGeneralId("sunday") : ""), (Module.Config.DrawDays.Monday ? ", " + TranslatesUtils.GetGeneralId("monday") : ""), (Module.Config.DrawDays.Tuesday ? ", " + TranslatesUtils.GetGeneralId("tuesday") : ""), (Module.Config.DrawDays.Wednesday ? ", " + TranslatesUtils.GetGeneralId("wednesday") : ""), (Module.Config.DrawDays.Thursday ? ", " + TranslatesUtils.GetGeneralId("thursday") : ""), (Module.Config.DrawDays.Friday ? ", " + TranslatesUtils.GetGeneralId("friday") : ""), (Module.Config.DrawDays.Saturday ? ", " + TranslatesUtils.GetGeneralId("saturday") : ""))); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("hout"), Module.Config.DrawHours)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("next"), Module.Config.NextDraw)); DialogMessage dialogMessage = new DialogMessage(TranslatesUtils.GetConfigId("title"), TranslatesUtils.GetGeneralId("lotto"), stringBuilder.ToString()); ModCommunication.SendMessageTo(dialogMessage, base.Context.Player.SteamUserId); }
public void give(string playerName, string itemType, string item, int quantity) { string type = "MyObjectBuilder_" + itemType; VRage.Game.MyDefinitionId.TryParse(type, item, out VRage.Game.MyDefinitionId defID); if (defID.ToString().Contains("null")) { Context.Respond("Invalid item type"); return; } if (playerName != "*") { var p = Utilities.GetPlayerByNameOrId(playerName); if (p == null) { Context.Respond("Player not found"); return; } Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.IdentityId, defID, quantity); ModCommunication.SendMessageTo(new NotificationMessage($"You have been given {quantity} {item} {itemType}", 5000, "Blue"), p.SteamUserId); } else { foreach (var p in MySession.Static.Players.GetOnlinePlayers()) { var player = Utilities.GetPlayerByNameOrId(p.DisplayName); Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.Identity.IdentityId, defID, quantity); ModCommunication.SendMessageTo(new NotificationMessage($"You have been given {quantity} {item} {itemType}", 5000, "Blue"), player.SteamUserId); } } Context.Respond("Item(s) given!"); }
public void GetPlayerLimit(string name) { if (!BlockLimiterConfig.Instance.EnableLimits) { Context.Respond("Plugin disabled"); return; } var sb = new StringBuilder(); if (!Utilities.TryGetPlayerByNameOrId(name, out var id)) { Context.Respond($"Player {name} not found"); return; } sb = Utilities.GetLimit(id.IdentityId); if (Context.Player == null || Context.Player.IdentityId == 0) { Context.Respond(sb.ToString()); return; } ModCommunication.SendMessageTo(new DialogMessage(BlockLimiterConfig.Instance.ServerName, "PlayerLimit", sb.ToString()), Context.Player.SteamUserId); }
public void DeathCounter() { if (DamagePatch.DeathCounter.Count <= 0) { Context.Respond("No death since start"); return; } var sb = new StringBuilder(); sb.AppendLine(); foreach (var death in DamagePatch.DeathCounter) { var count = death.Value; var playerName = MySession.Static.Players.TryGetIdentityNameFromSteamId(death.Key); sb.AppendLine($"{playerName}: {count}"); } if (Context.Player == null) { Context.Respond(sb.ToString()); return; } ModCommunication.SendMessageTo(new DialogMessage("Death Counter", null, sb.ToString()), Context.Player.SteamUserId); }
public void GlobalValueList() { var responseBuilder = new StringBuilder(); responseBuilder.AppendLine(); var index = 1; var items = GetDataProvider <MarketSimulationProvider>() .GetUniversalItems() .ToArray(); foreach (var item in items) { if (string.IsNullOrEmpty(item.FriendlyName)) { continue; } responseBuilder.AppendLine($"{index.ToString().PadLeft(4)}. {item.FriendlyName.PadLeft(40)}: {Utilities.FriendlyFormatCurrency(item.Value)}"); index++; } responseBuilder.AppendLine($"{items.Length} Total Items"); ModCommunication.SendMessageTo( new DialogMessage("Global Value List", null, null, responseBuilder.ToString()), Context.Player.SteamUserId); }
public void ListFactionLimit(string factionTag) { if (!BlockLimiterConfig.Instance.EnableLimits) { Context.Respond("Plugin disabled"); return; } if (string.IsNullOrEmpty(factionTag)) { Context.Respond("Faction tag is needed for this command"); return; } var faction = MySession.Static.Factions.TryGetFactionByTag(factionTag); if (faction == null) { Context.Respond($"Faction with tag {factionTag} not found"); return; } var sb = new StringBuilder(); var limitItems = new List <LimitItem>(); limitItems.AddRange(BlockLimiterConfig.Instance.AllLimits); if (!limitItems.Any()) { Context.Respond("No limit found"); return; } sb.AppendLine($"Faction Limits for {faction.Tag}"); foreach (var item in limitItems.Where(x => x.LimitFaction)) { { if (!item.FoundEntities.TryGetValue(faction.FactionId, out var fCount)) { continue; } var itemName = string.IsNullOrEmpty(item.Name) ? item.BlockList.FirstOrDefault() : item.Name; sb.AppendLine($"-->{itemName} = {fCount}/{item.Limit}"); } } if (Context.Player == null || Context.Player.IdentityId == 0) { Context.Respond(sb.ToString()); return; } ModCommunication.SendMessageTo(new DialogMessage(BlockLimiterConfig.Instance.ServerName, "Faction Limits", sb.ToString()), Context.Player.SteamUserId); }
public void List(string playernameOrSteamId, string gridNameOrEntityId = null) { MyIdentity player = PlayerUtils.GetIdentityByNameOrId(playernameOrSteamId); if (player == null) { Context.Respond("Player not found!"); return; } StringBuilder sb = new StringBuilder(); int i = 1; string gridname = null; if (gridNameOrEntityId == null) { Utilities.AddListEntriesToSb(Plugin, sb, player.IdentityId, i, false, out _); } else { List <long> playerIdentityList = new List <long>(); playerIdentityList.Add(player.IdentityId); var relevantGrids = Utilities.FindRelevantGrids(Plugin, playerIdentityList); Utilities.AddListEntriesToSb(relevantGrids, sb, gridNameOrEntityId, out gridname); if (gridname == null) { Context.Respond("Grid not found!"); return; } } if (Context.Player == null) { Context.Respond($"Backed up Grids for Player {player.DisplayName} #{player.IdentityId}"); if (gridname != null) { Context.Respond($"Grid {gridname}"); } Context.Respond(sb.ToString()); } else { if (gridname != null) { ModCommunication.SendMessageTo(new DialogMessage("Backed up Grids", $"Grid {gridname}", sb.ToString()), Context.Player.SteamUserId); } else { ModCommunication.SendMessageTo(new DialogMessage("Backed up Grids", $"Player {player.DisplayName} #{player.IdentityId}", sb.ToString()), Context.Player.SteamUserId); } } }
public void GridLimit(string id) { if (!BlockLimiterConfig.Instance.EnableLimits) { Context.Respond("Plugin disabled"); return; } if (string.IsNullOrEmpty(id)) { Context.Respond("Grid name/Id is needed for this command"); return; } if (!Utilities.TryGetEntityByNameOrId(id, out var entity) || !(entity is MyCubeGrid grid)) { Context.Respond("Grid not found"); return; } var sb = new StringBuilder(); var limitItems = new List <LimitItem>(); limitItems.AddRange(BlockLimiterConfig.Instance.AllLimits); if (!limitItems.Any()) { Context.Respond("No limit found"); return; } sb.AppendLine($"Grid Limits for {grid.DisplayName}"); foreach (var item in limitItems.Where(x => x.LimitGrids)) { { if (!item.FoundEntities.TryGetValue(grid.EntityId, out var gCount)) { continue; } var itemName = string.IsNullOrEmpty(item.Name) ? item.BlockList.FirstOrDefault() : item.Name; sb.AppendLine($"-->{itemName} = {gCount }/{item.Limit}"); } } if (Context.Player == null || Context.Player.IdentityId == 0) { Context.Respond(sb.ToString()); return; } ModCommunication.SendMessageTo(new DialogMessage(BlockLimiterConfig.Instance.ServerName, "Faction Limits", sb.ToString()), Context.Player.SteamUserId); }
public void Info() { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(Module.Config.Open ? TranslatesUtils.GetInfoId("open") : TranslatesUtils.GetInfoId("close")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("next"), Module.Config.NextDraw)); stringBuilder.AppendLine(""); List <int> listPlayerNumbers = PlayersUtils.PlayerNumbers(base.Context.Player.IdentityId); if (listPlayerNumbers.Count != 0) { foreach (var item in listPlayerNumbers) { stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("play"), item)); } } else { stringBuilder.AppendLine(TranslatesUtils.GetInfoId("dont")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("play")); } stringBuilder.AppendLine(""); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("prix"), Module.Config.TicketPrix)); stringBuilder.AppendLine(Module.Config.TicketMultiple ? TranslatesUtils.GetInfoId("multiple") : TranslatesUtils.GetInfoId("dontMultiple")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("number"), Module.Config.MaxNumber)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("gain"), Module.Config.GainTotal)); stringBuilder.AppendLine(""); var win = PlayersUtils.PlayerWinLotto(base.Context.Player.IdentityId); if (win == null) { stringBuilder.AppendLine(TranslatesUtils.GetInfoId("dontRecove")); } else { long allGain = 0L; foreach (var item in win) { allGain += item.gain; } stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("recove"), win.Count, allGain)); } stringBuilder.AppendLine(""); stringBuilder.AppendLine(""); stringBuilder.AppendLine(""); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetGeneralId("stats"), Module.Config.NumberTotalDraw, Module.Config.NumberTotalPlayersWin)); DialogMessage dialogMessage = new DialogMessage(TranslatesUtils.GetInfoId("title"), TranslatesUtils.GetGeneralId("lotto"), stringBuilder.ToString()); ModCommunication.SendMessageTo(dialogMessage, base.Context.Player.SteamUserId); }
public static void AcceptSubmission(long challengerId, long subjectId, ConflictType type, ulong changeRequestId = 0) { if (changeRequestId == 0) { return; } if (!InConflict(challengerId, subjectId, type, out var foundPair) || foundPair.ChangeRequestId == changeRequestId) { return; } ConflictPairs.Remove(foundPair); SaveConflictData(); HashSet <ulong> steamIds = new HashSet <ulong>(); string challengerName = ""; if (type == ConflictType.Faction) { var faction = MySession.Static.Factions.TryGetFactionById(subjectId); if (faction != null) { foreach (var(memberId, member) in faction.Members) { steamIds.Add(MySession.Static.Players.TryGetSteamId(memberId)); } var challengerFaction = MySession.Static.Factions.TryGetFactionById(challengerId); if (challengerFaction != null) { challengerName = $"{MySession.Static.Factions.TryGetFactionById(challengerId).Tag} and {faction.Tag}"; foreach (var memberId in faction.Members.Keys) { steamIds.Add(MySession.Static.Players.TryGetSteamId(memberId)); } } } } else { steamIds.Add(MySession.Static.Players.TryGetSteamId(subjectId)); challengerName = MySession.Static.Players.TryGetIdentity(challengerId).DisplayName ?? ""; } if (Config.Instance.EnableConflict) { Core.Instance.RecheckReputations(); } if (steamIds.Count == 0 || string.IsNullOrEmpty(challengerName)) { return; } foreach (var steamId in steamIds) { ModCommunication.SendMessageTo(new NotificationMessage($"Resolution with {challengerName} Approved", 10000, MyFontEnum.White), steamId); } }
public void DetailedReport(int ID) { StringBuilder Response = new StringBuilder(); string Prefix = ""; if (ID == 0) { Prefix = $"HangarSlots: { SelectedPlayerFile.Grids.Count()}/{ MaxHangarSlots}"; Response.AppendLine("- - Global Limits - -"); Response.AppendLine($"TotalBlocks: {SelectedPlayerFile.TotalBlocks}/{ Config.TotalMaxBlocks}"); Response.AppendLine($"TotalPCU: {SelectedPlayerFile.TotalPCU}/{ Config.TotalMaxPCU}"); Response.AppendLine($"StaticGrids: {SelectedPlayerFile.StaticGrids}/{ Config.TotalMaxStaticGrids}"); Response.AppendLine($"LargeGrids: {SelectedPlayerFile.LargeGrids}/{ Config.TotalMaxLargeGrids}"); Response.AppendLine($"SmallGrids: {SelectedPlayerFile.SmallGrids}/{ Config.TotalMaxSmallGrids}"); Response.AppendLine(); Response.AppendLine("- - Individual Hangar Slots - -"); for (int i = 0; i < SelectedPlayerFile.Grids.Count; i++) { GridStamp Stamp = SelectedPlayerFile.Grids[i]; Response.AppendLine($" * * Slot {i + 1} : {Stamp.GridName} * *"); Response.AppendLine($"PCU: {Stamp.GridPCU}/{Config.SingleMaxPCU}"); Response.AppendLine($"Blocks: {Stamp.NumberofBlocks}/{Config.SingleMaxBlocks}"); Response.AppendLine($"StaticGrids: {Stamp.StaticGrids}/{Config.SingleMaxStaticGrids}"); Response.AppendLine($"LargeGrids: {Stamp.LargeGrids}/{Config.SingleMaxLargeGrids}"); Response.AppendLine($"SmallGrids: {Stamp.SmallGrids}/{Config.SingleMaxSmallGrids}"); Response.AppendLine($"TotalGridCount: {Stamp.NumberOfGrids}"); Response.AppendLine($"Mass: {Stamp.GridMass}kg"); Response.AppendLine($"Built%: {Stamp.GridBuiltPercent * 100}%"); Response.AppendLine($" * * * * * * * * * * * * * * * * "); Response.AppendLine(); } } else { if (!IsInputValid(ID - 1)) { return; } GridStamp Stamp = SelectedPlayerFile.Grids[ID - 1]; Prefix = $"Slot {ID} : {Stamp.GridName}"; Response.AppendLine($"PCU: {Stamp.GridPCU}/{Config.SingleMaxPCU}"); Response.AppendLine($"Blocks: {Stamp.NumberofBlocks}/{Config.SingleMaxBlocks}"); Response.AppendLine($"StaticGrids: {Stamp.StaticGrids}/{Config.SingleMaxStaticGrids}"); Response.AppendLine($"LargeGrids: {Stamp.LargeGrids}/{Config.SingleMaxLargeGrids}"); Response.AppendLine($"SmallGrids: {Stamp.SmallGrids}/{Config.SingleMaxSmallGrids}"); Response.AppendLine($"TotalGridCount: {Stamp.NumberOfGrids}"); Response.AppendLine($"Mass: {Stamp.GridMass}kg"); Response.AppendLine($"Built%: {Stamp.GridBuiltPercent * 100}%"); Response.AppendLine(); } ModCommunication.SendMessageTo(new DialogMessage("Hangar Info", Prefix, Response.ToString()), SteamID); //Chat.Respond(Response.ToString()); }
public void SendMotd(MyPlayer player, bool onSessionChanged) { long playerId = player.Identity.IdentityId; if (!string.IsNullOrEmpty(Config.MotdUrl) && !Config.NewUserMotdUrl) { var url = MakeUrl(Config.MotdUrl); MyVisualScriptLogicProvider.OpenSteamOverlay(url, playerId); return; } var id = player.Client.SteamUserId; if (id <= 0) { return; } string name = player.Identity?.DisplayName ?? "player"; bool isNewUser = !_knownIds.Contains(id); if (isNewUser) { _knownIds.Add(id); } if (!string.IsNullOrEmpty(Config.MotdUrl) && isNewUser && Config.NewUserMotdUrl) { var url = MakeUrl(Config.MotdUrl); MyVisualScriptLogicProvider.OpenSteamOverlay(url, playerId); return; } if (isNewUser && !string.IsNullOrEmpty(Config.NewUserMotd)) { var msg = new DialogMessage(MySession.Static.Name, "New User Message Of The Day", Config.NewUserMotd.Replace("%player%", name)); ModCommunication.SendMessageTo(msg, id); return; } if (!string.IsNullOrEmpty(Config.Motd)) { var msg = new DialogMessage(MySession.Static.Name, "Message Of The Day", Config.Motd.Replace("%player%", name)); ModCommunication.SendMessageTo(msg, id); return; } if (!onSessionChanged) // otherwise default motd shows up twice on connection { var txt = GetDefaultMotdText(); var msg = new DialogMessage(MySession.Static.Name, "Message Of The Day", txt); ModCommunication.SendMessageTo(msg, id); } }