예제 #1
0
        public static void RegionThread()
        {
            string name;

            while (true)
            {
                Thread.Sleep(1000);
                foreach (TSPlayer player in TShock.Players.Where((TSPlayer p) => p?.Active ?? false))
                {
                    try
                    {
                        name = CRegion.GetCurrentRegion(player);
                        Players[player.Index].CurrentRegion = name;
                        if (name == null)
                        {
                            Players[player.Index].Seconds = -1;
                        }
                        else
                        {
                            if (Players[player.Index].Seconds == -1)
                            {
                                Players[player.Index].Seconds   = 5;
                                Players[player.Index].OldRegion = name;
                            }
                            if (Players[player.Index].CurrentRegion == Players[player.Index].OldRegion)
                            {
                                if (Players[player.Index].Seconds == 0)
                                {
                                    Players[player.Index].Seconds = -1;
                                    CRegions.Find((CRegion c) => c.Name == name).Execute(player);
                                    player.SendData(PacketTypes.CreateCombatTextExtended, name + "!", (int)new Color(169, 55, 255).PackedValue, player.TPlayer.Center.X, player.TPlayer.Center.Y);
                                }
                                else
                                {
                                    player.SendData(PacketTypes.CreateCombatTextExtended, Players[player.Index].Seconds.ToString(), (int)new Color(169, 55, 255).PackedValue, player.TPlayer.Center.X, player.TPlayer.Center.Y);
                                    Players[player.Index].Seconds--;
                                }
                            }
                            else
                            {
                                Players[player.Index].Seconds   = 5;
                                Players[player.Index].OldRegion = name;
                            }
                        }
                    }
                    catch (NullReferenceException)
                    {
                    }
                }
            }
        }
예제 #2
0
 public static void OnGetData(GetDataEventArgs args)
 {
     if (!args.Handled && !args.Handled && args.MsgID == PacketTypes.Tile)
     {
         using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(args.Msg.readBuffer, args.Index, args.Length)))
         {
             TSPlayer tSPlayer = TShock.Players[args.Msg.whoAmI];
             byte     type     = binaryReader.ReadByte();
             short    x        = binaryReader.ReadInt16();
             short    y        = binaryReader.ReadInt16();
             if ((type == 0 || type == 1) && tSPlayer.HasPermission("server.admin"))
             {
                 if (Players[tSPlayer.Index].Set[0])
                 {
                     Players[tSPlayer.Index].Pos1.X = x;
                     Players[tSPlayer.Index].Pos1.Y = y;
                     Players[tSPlayer.Index].Set[0] = false;
                     Players[tSPlayer.Index].Set[1] = true;
                     tSPlayer.SendMessage($"[c/595959:»]  Ustawiono punkt pierwszy. ({x}, {y})", Color.Gray);
                     tSPlayer.SendMessage("[c/595959:»]  Teraz ustaw drugi punkt w prawym dolnym rogu.", Color.Gray);
                     tSPlayer.SendTileSquare(x, y);
                     args.Handled = true;
                 }
                 else if (Players[tSPlayer.Index].Set[1])
                 {
                     Players[tSPlayer.Index].Pos2.X = x;
                     Players[tSPlayer.Index].Pos2.Y = y;
                     Players[tSPlayer.Index].Set[1] = false;
                     tSPlayer.SendMessage($"[c/595959:»]  Ustawiono punkt drugi. ({x}, {y})", Color.Gray);
                     tSPlayer.SendTileSquare(x, y);
                     args.Handled = true;
                 }
                 else if (Players[tSPlayer.Index].Destroy)
                 {
                     CRegion region = CRegion.GetRegion(x, y);
                     if (region == null)
                     {
                         tSPlayer.SendErrorMessage("[c/595959:»]  Nie znaleziono regionu.");
                     }
                     else
                     {
                         CRegions.Remove(region);
                         CrDatabase.DestroyRegion(region.Name);
                         tSPlayer.SendMessage("[c/595959:»]  Pomyslnie usunieto region [c/66ff66:" + region.Name + "].", Color.Gray);
                     }
                     Players[tSPlayer.Index].Destroy = false;
                     tSPlayer.SendTileSquare(x, y);
                     args.Handled = true;
                 }
                 else if (Players[tSPlayer.Index].Modify)
                 {
                     CRegion region = CRegion.GetRegion(x, y);
                     if (region == null)
                     {
                         tSPlayer.SendErrorMessage("[c/595959:»]  Nie znaleziono regionu.");
                     }
                     else
                     {
                         CRegions.Find((CRegion c) => c == region).Action = Players[tSPlayer.Index].Cmd;
                         CrDatabase.ModifyRegion(region.Name, Players[tSPlayer.Index].Cmd);
                         tSPlayer.SendMessage("[c/595959:»]  Pomyslnie zmodyfikowano region [c/66ff66:" + region.Name + "].", Color.Gray);
                     }
                     Players[tSPlayer.Index].Modify = false;
                     tSPlayer.SendTileSquare(x, y);
                     args.Handled = true;
                 }
             }
         }
     }
 }