Пример #1
0
        public void distress(string reason = "")
        {
            if (Context.Player == null)
            {
                Context.Respond("no no console no distress");
                return;
            }


            IMyFaction playerFac = FacUtils.GetPlayersFaction(Context.Player.Identity.IdentityId);

            if (playerFac == null)
            {
                Context.Respond("You dont have a faction.");
                return;
            }
            if (reason != "")
            {
                reason = Context.RawArgs;
            }
            MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId);

            if (fac == null)
            {
                Context.Respond("A faction is required to use alliance features.");
                return;
            }

            if (distressCooldowns.TryGetValue(Context.Player.IdentityId, out DateTime time))
            {
                if (DateTime.Now < time)
                {
                    Context.Respond(AllianceCommands.GetCooldownMessage(time));
                    return;
                }
                else
                {
                    distressCooldowns[Context.Player.IdentityId] = DateTime.Now.AddSeconds(30);
                }
            }
            else
            {
                distressCooldowns.Add(Context.Player.IdentityId, DateTime.Now.AddSeconds(30));
            }
            Alliance alliance = AlliancePlugin.GetAllianceNoLoading(fac);

            if (alliance != null)
            {
                distressCount++;
                AllianceChat.SendChatMessage(alliance.AllianceId, "Distress Signal", CreateGps(Context.Player.Character.GetPosition(), Color.Yellow, 600, distressCount.ToString(), reason).ToString(), true, 0);
            }
        }
Пример #2
0
 public static bool IsOwnerOrFactionOwned(MyCubeGrid grid, long playerId, bool doFactionCheck)
 {
     if (grid.BigOwners.Contains(playerId))
     {
         return(true);
     }
     else
     {
         if (!doFactionCheck)
         {
             return(false);
         }
         long ownerId = GetOwner(grid);
         //check if the owner is a faction member, i honestly dont know the difference between grid.BigOwners and grid.SmallOwners
         return(FacUtils.InSameFaction(playerId, ownerId));
     }
 }
Пример #3
0
        public void DoTags()
        {
            Dictionary <String, String> tagsAndNames = new Dictionary <string, string>();
            Dictionary <String, String> friends      = new Dictionary <string, string>();
            Dictionary <String, String> neutrals     = new Dictionary <string, string>();
            Dictionary <String, String> alliances    = new Dictionary <String, string>();

            foreach (MyPlayer player in MySession.Static.Players.GetOnlinePlayers())
            {
                string     name     = MyMultiplayer.Static.GetMemberName(player.Id.SteamId);
                MyIdentity identity = AlliancePlugin.GetIdentityByNameOrId(player.Id.SteamId.ToString());
                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId) != null)
                {
                    IMyFaction playerFac = null;
                    if (FacUtils.GetPlayersFaction(Context.Player.Identity.IdentityId) != null)
                    {
                        playerFac = FacUtils.GetPlayersFaction(Context.Player.Identity.IdentityId);
                    }
                    if (playerFac == null)
                    {
                        Context.Respond("Make a faction. This command does not work without being in a faction.");
                        return;
                    }
                    if (FacUtils.GetPlayersFaction(player.Identity.IdentityId) == null)
                    {
                        continue;
                    }
                    Alliance alliance = AlliancePlugin.GetAllianceNoLoading(FacUtils.GetPlayersFaction(player.Identity.IdentityId) as MyFaction);
                    if (alliance != null)
                    {
                        if (alliances.ContainsKey(alliance.name))
                        {
                            alliances.TryGetValue(alliance.name, out String temp);


                            if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                            {
                                temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                            }
                            else
                            {
                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                }

                                else
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                }
                            }
                            alliances.Remove(alliance.name);
                            alliances.Add(alliance.name, temp);
                        }
                        else
                        {
                            String temp = "";
                            if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                            {
                                temp += " [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                            }
                            else
                            {
                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                {
                                    temp += " [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                }

                                else
                                {
                                    temp += " [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                }
                            }

                            alliances.Add(alliance.name, temp);
                        }
                    }
                    else
                    {
                        if (friends.ContainsKey(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag))
                        {
                            friends.TryGetValue(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, out String temp);


                            if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                            {
                                temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                            }
                            else
                            {
                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                }

                                else
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                }
                            }
                            friends.Remove(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag);
                            friends.Add(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, temp);
                        }
                        if (MySession.Static.Factions.AreFactionsEnemies(playerFac.FactionId, FacUtils.GetPlayersFaction(player.Identity.IdentityId).FactionId))
                        {
                            if (tagsAndNames.ContainsKey(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag))
                            {
                                tagsAndNames.TryGetValue(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, out String temp);


                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                                }
                                else
                                {
                                    if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                    }

                                    else
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                    }
                                }
                                tagsAndNames.Remove(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag);
                                tagsAndNames.Add(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, temp);
                            }
                            else
                            {
                                String temp = "";
                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                                }
                                else
                                {
                                    if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                    }

                                    else
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                    }
                                }

                                tagsAndNames.Add(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, temp);
                            }
                        }
                        else
                        {
                            if (neutrals.ContainsKey(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag))
                            {
                                neutrals.TryGetValue(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, out String temp);


                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                                }
                                else
                                {
                                    if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                    }

                                    else
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                    }
                                }
                                neutrals.Remove(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag);
                                neutrals.Add(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, temp);
                            }
                            else
                            {
                                String temp = "";
                                if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsFounder(player.Identity.IdentityId))
                                {
                                    temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Founder)";
                                }
                                else
                                {
                                    if (FacUtils.GetPlayersFaction(player.Identity.IdentityId).IsLeader(player.Identity.IdentityId))
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName + " (Leader)";
                                    }

                                    else
                                    {
                                        temp += "\n [" + FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag + "] - " + player.DisplayName;
                                    }
                                }

                                neutrals.Add(FacUtils.GetPlayersFaction(player.Identity.IdentityId).Tag, temp);
                            }
                        }
                    }
                }
            }
            var sb = new StringBuilder();

            foreach (KeyValuePair <String, String> keys in alliances)
            {
                sb.AppendLine(keys.Key);
                sb.AppendLine(keys.Value);
                sb.AppendLine("");
            }
            sb.Append("At War");
            foreach (KeyValuePair <String, String> keys in tagsAndNames)
            {
                sb.Append(keys.Value);
            }
            sb.Append("\n ");
            sb.Append("\n Friends");
            foreach (KeyValuePair <String, String> keys in friends)
            {
                sb.Append(keys.Value);
            }
            sb.Append("\n ");
            sb.Append("\n Neutral");
            foreach (KeyValuePair <String, String> keys in neutrals)
            {
                sb.Append(keys.Value);
            }

            DialogMessage m = new DialogMessage("Tags of online players", "", sb.ToString());

            ModCommunication.SendMessageTo(m, Context.Player.SteamUserId);
        }
Пример #4
0
        public static bool PatchRequestJump(long entityId, Vector3D jumpTarget, long userId)
        {
            MyCubeGrid grid = MyAPIGateway.Entities.GetEntityById(entityId) as MyCubeGrid;

            if (grid == null)
            {
                return(false);
            }


            //return false;
            if (userId == 0)
            {
                Log.Info("grid name " + grid.DisplayName);
                Log.Info(FacUtils.GetOwner(grid) + " grid owner id, requested by 0, which is probably a hacker or some shit, these are the people online at the time");
                StringBuilder players = new StringBuilder();
                foreach (MyPlayer player in MySession.Static.Players.GetOnlinePlayers())
                {
                    if (player.Id != null && player.Id.SteamId != null && player.DisplayName != null)
                    {
                        players.AppendLine(player.Id.SteamId + " " + player.DisplayName);
                    }
                    else
                    {
                        players.AppendLine("Something null here, identity id " + player.Identity.IdentityId);
                    }
                }
                Log.Info(players);
                if (AlliancePlugin.config.DisableJumpsWithId0)
                {
                    return(false);
                }
            }
            else
            {
                Log.Info(FacUtils.GetOwner(grid) + " grid owner id, requested by " + userId + " grid name " + grid.DisplayName);
            }
            foreach (JumpZone zone in Zones)
            {
                float distance = Vector3.Distance(zone.GetPosition(), grid.PositionComp.GetPosition());

                if (distance <= zone.Radius && !zone.AllowExit)
                {
                    if (zone.GetExcludedExit() != null && zone.AllowExcludedExit)
                    {
                        bool canExit = false;
                        foreach (MyJumpDrive drive in grid.GetFatBlocks().OfType <MyJumpDrive>())
                        {
                            if (!zone.GetExcludedExit().Contains(drive.BlockDefinition.BlockPairName))
                            {
                                drive.Enabled = false;
                            }
                            else
                            {
                                canExit = true;
                            }
                        }
                        if (canExit)
                        {
                            // newPos = grid.WorldMatrix.Forward + 1000;
                            //worldMatrix = MatrixD.CreateWorld(newPos, grid.WorldMatrix.Forward, grid.WorldMatrix.Up);
                            return(true);
                        }
                    }
                    NotificationMessage message = new NotificationMessage("You cannot jump out of this area.", 8000, "Red");
                    //this is annoying, need to figure out how to check the exact world time so a duplicate message isnt possible
                    ModCommunication.SendMessageTo(message, MySession.Static.Players.TryGetSteamId(userId));
                    return(false);
                }

                distance = Vector3.Distance(zone.GetPosition(), jumpTarget);

                if (distance <= zone.Radius && !zone.AllowEntry)
                {
                    if (zone.GetExcludedEntry() != null && zone.AllowExcludedEntry)
                    {
                        bool canExit = false;
                        foreach (MyJumpDrive drive in grid.GetFatBlocks().OfType <MyJumpDrive>())
                        {
                            if (!zone.GetExcludedExit().Contains(drive.BlockDefinition.BlockPairName))
                            {
                                drive.Enabled = false;
                            }
                            else
                            {
                                canExit = true;
                            }
                        }
                        if (canExit)
                        {
                            //newPos = grid.WorldMatrix.Forward + 1000;
                            // worldMatrix = MatrixD.CreateWorld(newPos, grid.WorldMatrix.Forward, grid.WorldMatrix.Up);
                            return(true);
                        }
                    }
                    NotificationMessage message = new NotificationMessage("You cannot jump into this area.", 8000, "Red");
                    //this is annoying, need to figure out how to check the exact world time so a duplicate message isnt possible
                    ModCommunication.SendMessageTo(message, MySession.Static.Players.TryGetSteamId(userId));
                    return(false);
                }
            }
            JumpThing thing = new JumpThing();

            //MyCockpit controller = null;
            //foreach (MyCockpit cockpit in grid.GetFatBlocks().OfType<MyCockpit>())
            //{
            //    if (cockpit.Pilot != null)
            //    {
            //        if (cockpit.Pilot.ControlSteamId.Equals(MySession.Static.Players.TryGetSteamId(userId)))
            //        {
            //            controller = cockpit;
            //        }
            //    }
            //}
            //AlliancePlugin.Log.Info("1");
            //if (controller != null)
            //{
            //    AlliancePlugin.Log.Info("2");
            //    MatrixD worldMatrix = MatrixD.CreateWorld(controller.WorldMatrix.Translation, controller.WorldMatrix.Forward, controller.WorldMatrix.Up);
            //    Vector3D distance2 = worldMatrix.Forward * 1000;
            //    worldMatrix.Translation += distance2;
            //    thing.matrix = worldMatrix;
            //    thing.gridId = grid.EntityId;
            //    AlliancePlugin.jumpies.Add(thing);

            //    Vector3D? newPosition = MyEntities.FindFreePlace(worldMatrix.Translation, (float)GridManager.FindBoundingSphere(controller.CubeGrid).Radius);
            //    return false;

            //}
            return(true);
        }