public override bool HandleCommand(ulong userId, string[] words) { try { MyObjectBuilder_Faction currentfaction; currentfaction = Utility.Faction.getFaction(Utility.Faction.getFactionID(userId)); foreach (MyObjectBuilder_FactionMember currentmember in currentfaction.Members) { if (currentmember.IsLeader == true && currentmember.PlayerId == PlayerMap.Instance.GetPlayerIdsFromSteamId(userId).First())//currentmember.isleader(currentfaction) { string output = ""; output = Utility.Shop.Shop.getShopList(userId); ChatUtil.DisplayDialog(userId, "Faction Store", "Spend FP Here!", output); break; } else if (currentmember.PlayerId == PlayerMap.Instance.GetPlayerIdsFromSteamId(userId).First()) { ChatUtil.SendPrivateChat(userId, "You do not have Permission to use this command."); } } } catch (NullReferenceException) { log.Info(string.Format("Error getting shop list nullreferenceexception")); } return(true); }
public void HandleChatMessage(ulong steamId, string message) { // Parse chat message ulong remoteUserId = steamId; List <string> commandParts = CommandParser.GetCommandParts(message); // User wants some help if (commandParts[0].ToLower() == "/conquesthelp") { String content2 = "Commands:\r\n/conquest player: Player Leaderboard\r\n/conquest faction: Faction Leaderboard\r\n/shop list: Show Shop\r\n/shop buy [item] [amount]:Buys Items"; content2 += "\r\n/bal: Current FP Balance\r\n/givefp [factiontag] [amount]: Gives a faction some of your FP\r\n\r\nTo Capture:\r\nBuild a Station with a powered beacon within 500m of an asteroid and broadcast at least 5km."; ChatUtil.DisplayDialog(steamId, "Conquest Gamemode", "Command Help", content2, "THANKS!"); return; } // See if we have any valid handlers bool handled = false; foreach (ChatHandlerBase chatHandler in _chatHandlers) { int commandCount = 0; if (remoteUserId == 0 && !chatHandler.AllowedInConsole()) { continue; } if (chatHandler.CanHandle(remoteUserId, commandParts.ToArray(), ref commandCount)) { try { chatHandler.HandleCommand(remoteUserId, commandParts.Skip(commandCount).ToArray()); } catch (Exception ex) { Log.Info(string.Format("ChatHandler Error: {0}", ex)); } handled = true; } } if (!handled) { DisplayAvailableCommands(remoteUserId, message); } }
public override bool HandleCommand(ulong userId, string[] words) { var board = GMConquest.Instance.Leaderboard; string leaderResult = ""; foreach (var p in board) { // leaderResult += string.Format("Here: {0} - {1}", p.Key, p.Value); } // leaderResult += "\r\n"; var leaders = GMConquest.Instance.Leaderboard.GroupBy(x => x.Value).Select(group => new { group.Key, Total = group.Count() }).OrderByDescending(x => x.Total); int position = 1; foreach (var p in leaders) { if (leaderResult != "") { leaderResult += "\r\n"; } MyObjectBuilder_Checkpoint.PlayerItem item = PlayerMap.Instance.GetPlayerItemFromPlayerId(p.Key); leaderResult += string.Format("#{0}: {1} with {2} asteroids", position, item.Name, p.Total); position++; } leaderResult += "\r\n\r\n"; long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId(userId); int playerCount = 0; var playerItem = leaders.FirstOrDefault(x => x.Key == playerId); if (playerItem != null) { playerCount = playerItem.Total; } leaderResult += string.Format("You currently have {0} owned asteroids.", playerCount); // ChatUtil.SendPrivateChat(userId, leaderResult); ChatUtil.DisplayDialog(userId, "Conquest Leaderboard", "Current Leaders", leaderResult); return(true); }
public override bool HandleCommand(ulong userId, string[] words) { // Display Faction Leaderboard string flstring = ""; MyObjectBuilder_FactionCollection factionlist = MyAPIGateway.Session.GetWorld().Checkpoint.Factions; List <FactionScores> factionleaderboard = new List <FactionScores>(); int position = 1; foreach (MyObjectBuilder_Faction faction in factionlist.Factions) { long faction_score = 0; List <MyObjectBuilder_FactionMember> currentfaction = faction.Members; foreach (MyObjectBuilder_FactionMember currentmember in currentfaction) { var leaders = GMConquest.Instance.Leaderboard.GroupBy(x => x.Value).Select(group => new { group.Key, Total = group.Count() }).OrderByDescending(x => x.Total); foreach (var p in leaders) { if (p.Key == currentmember.PlayerId) { faction_score += p.Total; } } } if (faction_score > 0) { factionleaderboard.Add(new FactionScores(faction.Name, faction_score)); } } factionleaderboard = factionleaderboard.OrderByDescending(x => x.FactionScore).ToList(); foreach (FactionScores score in factionleaderboard) { flstring += string.Format("#{0}: {1} with {2} asteroids.\r\n", position, score.FactionName, score.FactionScore); position++; } ChatUtil.DisplayDialog(userId, "Faction Leaderbored", "Current Leader", flstring); return(true); }