public void RemoveMember(long memberId)
        {
            try
            {
                if (!m_members.ContainsKey(memberId))
                {
                    return;
                }

                m_memberToModify = memberId;

                MyObjectBuilder_FactionMember memberToRemove = new MyObjectBuilder_FactionMember( );
                foreach (MyObjectBuilder_FactionMember member in m_faction.Members)
                {
                    if (member.PlayerId == m_memberToModify)
                    {
                        memberToRemove = member;
                        break;
                    }
                }
                m_faction.Members.Remove(memberToRemove);

                Action action = InternalRemoveMember;
                SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
示例#2
0
        public void RemoveMember(long memberId)
        {
            try
            {
                if (!m_members.ContainsKey(memberId))
                {
                    return;
                }

                m_memberToModify = memberId;

                MyObjectBuilder_FactionMember memberToRemove = new MyObjectBuilder_FactionMember( );
                foreach (MyObjectBuilder_FactionMember member in m_faction.Members)
                {
                    if (member.PlayerId == m_memberToModify)
                    {
                        memberToRemove = member;
                        break;
                    }
                }
                m_faction.Members.Remove(memberToRemove);

                MySandboxGame.Static.Invoke(InternalRemoveMember);
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
        }
        //public static string FactionMemberClass = "32F8947D11EDAF4D079FD54C2397A951";

        #endregion "Attributes"

        #region "Constructors and Initializers"

        public FactionMember(Faction parent, MyObjectBuilder_FactionMember definition)
        {
            m_parent = parent;
            m_member = definition;
        }
 public FactionMember( Faction parent, MyObjectBuilder_FactionMember definition )
 {
     m_parent = parent;
     m_member = definition;
 }
        public void RemoveMember( long memberId )
        {
            try
            {
                if ( !m_members.ContainsKey( memberId ) )
                    return;

                m_memberToModify = memberId;

                MyObjectBuilder_FactionMember memberToRemove = new MyObjectBuilder_FactionMember( );
                foreach ( MyObjectBuilder_FactionMember member in m_faction.Members )
                {
                    if ( member.PlayerId == m_memberToModify )
                    {
                        memberToRemove = member;
                        break;
                    }
                }
                m_faction.Members.Remove( memberToRemove );

                MySandboxGame.Static.Invoke( InternalRemoveMember );
            }
            catch ( Exception ex )
            {
                ApplicationLog.BaseLog.Error( ex );
            }
        }
示例#6
0
        private bool SellOnMarket(string IDPath, GridStamp Grid, PlayerInfo Data, MyIdentity Player, long NumPrice, string Description)
        {
            string path = Path.Combine(IDPath, Grid.GridName + ".sbc");

            if (!File.Exists(path))
            {
                //Context.Respond("Grid doesnt exist! Contact an admin!");
                return(false);
            }



            Parallel.Invoke(() =>
            {
                MyObjectBuilderSerializer.DeserializeXML(path, out MyObjectBuilder_Definitions myObjectBuilder_Definitions);

                var shipBlueprint             = myObjectBuilder_Definitions.ShipBlueprints;
                MyObjectBuilder_CubeGrid grid = shipBlueprint[0].CubeGrids[0];



                byte[] Definition       = MyAPIGateway.Utilities.SerializeToBinary(grid);
                GridsForSale GridSell   = new GridsForSale();
                GridSell.name           = Grid.GridName;
                GridSell.GridDefinition = Definition;


                //Seller faction
                var fc = MyAPIGateway.Session.Factions.GetObjectBuilder();

                MyObjectBuilder_Faction factionBuilder;
                try
                {
                    factionBuilder = fc.Factions.First(f => f.Members.Any(m => m.PlayerId == Player.IdentityId));
                    if (factionBuilder != null || factionBuilder.Tag != "")
                    {
                        Grid.SellerFaction = factionBuilder.Tag;
                    }
                }
                catch
                {
                    try
                    {
                        Hangar.Debug("Player " + Player.DisplayName + " has a bugged faction model! Attempting to fix!");
                        factionBuilder = fc.Factions.First(f => f.Members.Any(m => m.PlayerId == Player.IdentityId));
                        MyObjectBuilder_FactionMember member = factionBuilder.Members.First(x => x.PlayerId == Player.IdentityId);

                        bool IsFounder;
                        bool IsLeader;

                        IsFounder = member.IsFounder;
                        IsLeader  = member.IsLeader;

                        factionBuilder.Members.Remove(member);
                        factionBuilder.Members.Add(member);
                    }
                    catch (Exception a)
                    {
                        Hangar.Debug("Welp tbh fix failed! Please why no fix. :(", a, Hangar.ErrorType.Trace);
                    }

                    //Bugged player!
                }



                MarketList List       = new MarketList();
                List.Name             = Grid.GridName;
                List.Description      = Description;
                List.Seller           = "Auction House";
                List.Price            = NumPrice;
                List.Steamid          = Convert.ToUInt64(IDPath);
                List.MarketValue      = Grid.MarketValue;
                List.SellerFaction    = Grid.SellerFaction;
                List.GridMass         = Grid.GridMass;
                List.SmallGrids       = Grid.SmallGrids;
                List.LargeGrids       = Grid.LargeGrids;
                List.NumberofBlocks   = Grid.NumberofBlocks;
                List.MaxPowerOutput   = Grid.MaxPowerOutput;
                List.GridBuiltPercent = Grid.GridBuiltPercent;
                List.JumpDistance     = Grid.JumpDistance;
                List.NumberOfGrids    = Grid.NumberOfGrids;
                List.BlockTypeCount   = Grid.BlockTypeCount;
                List.PCU = Grid.GridPCU;


                //List item as server offer
                List.ServerOffer = true;



                //We need to send to all to add one item to the list!
                CrossServerMessage SendMessage = new CrossServerMessage();
                SendMessage.Type = CrossServer.MessageType.AddItem;
                SendMessage.GridDefinition.Add(GridSell);
                SendMessage.List.Add(List);


                Servers.Update(SendMessage);
            });

            return(true);
        }