public static bool transferFP(ulong userID, string factiontag, int amount) { if (amount < 0) { ChatUtil.SendPrivateChat(userID, "Please enter a positive value"); return(false); } if (Faction.getFactionIDfromTag(factiontag) != 0) { if (FactionPoints.RemoveFP((ulong)Faction.getFactionID(userID), amount) == true) { FactionPoints.AddFP(Faction.getFactionIDfromTag(factiontag), amount); return(true); } else { return(false); } } else { ChatUtil.SendPrivateChat(userID, "Factionx tag does not exist"); return(false); } }
public override void Handle() { // * Faction Points System: Every 60 minutes, Give each faction (owned asteroids) number of credits. Save faction balances to file. // ---------------------- try { MyObjectBuilder_FactionCollection factionlist = MyAPIGateway.Session.GetWorld().Checkpoint.Factions; int num_factions = factionlist.Factions.Count; //get number of factions ulong[,] fcleaderboard = new ulong[num_factions, 2]; foreach (MyObjectBuilder_Faction faction in factionlist.Factions) { int 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; } } } // Add faction_score to factions current credits. FactionPoints.AddFP(faction.FactionId, faction_score); } } catch (InvalidOperationException) { // Log Invalid Operation Log.Info("Caught Invalid Operation in FactionPoints Process."); } // ---------------------- base.Handle(); }