Esempio n. 1
0
        static void WriteXml()
        {
            using (StreamWriter sw = new StreamWriter(ConfigFilePath))
            {
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                sw.WriteLine("<Mod>");
                sw.WriteLine("  <LobbyPosition>");

                Vector3 v = VariableContainer.GetLobbyPosition();

                sw.WriteLine(string.Format("    <X>{0}</X>", v.x));
                sw.WriteLine(string.Format("    <Y>{0}</Y>", v.y));
                sw.WriteLine(string.Format("    <Z>{0}</Z>", v.z));

                sw.WriteLine("  </LobbyPosition>");

                sw.WriteLine("  <Maps>");

                foreach (Map map in VariableContainer.ListMaps())
                {
                    sw.WriteLine("    <Map>");
                    sw.WriteLine(string.Format("      <Name>{0}</Name>", map.name));
                    sw.WriteLine("      <Spawns>");

                    foreach (KeyValuePair <string, List <Spawn> > pair in map.spawns.ToList())
                    {
                        foreach (Spawn spawn in pair.Value)
                        {
                            sw.WriteLine("        <Spawn>");

                            sw.WriteLine(string.Format("          <Type>{0}</Type>", pair.Key));
                            sw.WriteLine(string.Format("          <X>{0}</X>", spawn.location.x));
                            sw.WriteLine(string.Format("          <Y>{0}</Y>", spawn.location.y));
                            sw.WriteLine(string.Format("          <Z>{0}</Z>", spawn.location.z));
                            sw.WriteLine("        </Spawn>");
                        }
                    }

                    sw.WriteLine("      </Spawns>");
                    sw.WriteLine("    </Map>");
                }

                sw.WriteLine("  </Maps>");

                sw.WriteLine("</Mod>");
                sw.Flush();
                sw.Close();
            }
        }
Esempio n. 2
0
        public static bool Execute(ClientInfo sender, List <string> arguments)
        {
            World world = GameManager.Instance.World;

            if (arguments.Count < 1)
            {
                ChatManager.Message(sender, "[85144b]You ugly bitch  [FF4136]/tp who or what");
                return(false);
            }

            string  what        = arguments[0].Trim();
            Vector3 destination = Vector3.zero;

            // Search in players
            bool found = false;

            foreach (ClientInfo clientInfo in ConnectionManager.Instance.Clients.List)
            {
                if (clientInfo.playerName == null)
                {
                    continue;
                }
                if (!clientInfo.playerName.Contains(what))
                {
                    continue;
                }

                EntityPlayer entityPlayer = world.Players.dict[clientInfo.entityId];
                destination = entityPlayer.position;
                found       = true;
                break;
            }

            if (found)
            {
                sender.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(destination, null, false));
                return(false);
            }

            // Chceck all maps
            foreach (Map map in VariableContainer.ListMaps())
            {
                if (!map.name.Contains(what))
                {
                    continue;
                }

                string spawnFor = "team";

                if (arguments.Count >= 2)
                {
                    spawnFor = arguments[1].Trim();
                }

                if (!map.spawns.ContainsKey(spawnFor))
                {
                    ChatManager.Message(sender, string.Format("[DDDDDD]Group [FFDC00]{0} [DDDDDD]does not exist", spawnFor));
                    return(false);
                }

                // Get latest
                int index = map.spawns[spawnFor].Count - 1;

                if (arguments.Count == 3)
                {
                    try
                    {
                        index = int.Parse(arguments[2].Trim());
                    }
                    catch { }
                }

                destination = map.spawns[spawnFor][index].location;
                found       = true;
                break;
            }

            if (found)
            {
                sender.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(destination, null, false));
                return(false);
            }

            if (arguments.Count == 2)
            {
                int x = int.Parse(arguments[0].Trim());
                int z = int.Parse(arguments[1].Trim());

                int y = 128;
                if (world.IsChunkAreaLoaded(x, 0, z))
                {
                    Chunk c = (Chunk)world.GetChunkFromWorldPos(x, 0, z);
                    y = c.GetTerrainHeight(x & 0xF, z & 0xF) + 1;
                }

                destination = new Vector3(x, y, z);

                sender.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(destination, null, false));
                return(false);
            }

            ChatManager.Message(sender, "[85144b]You ugly bitch  [FF4136]I can't find Your dreamed up hero!");
            return(false);
        }