Ejemplo n.º 1
0
    public override void OnBlockLoaded(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
    {
        if (_blockValue.ischild)
        {
            return;
        }

        this.shape.OnBlockLoaded(_world, _clrIdx, _blockPos, _blockValue);

        // Try to get BlockEntityData
        ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];

        if (chunkCluster == null)
        {
            DebugMsg("BlockDummyBoat OnBlockLoaded: ChunkCluster is NULL, aborting. Cannot find and set Boat.");
            return;
        }
        Chunk           chunk           = (Chunk)chunkCluster.GetChunkFromWorldPos(_blockPos);
        BlockEntityData blockEntityData = chunk.GetBlockEntity(_blockPos);

        // Try to find closest Boat, then set and offset it
        DebugMsg("BlockDummyBoat OnBlockLoaded: Entity count = " + GameManager.Instance.World.Entities.list.Count.ToString());
        if (!FindSetAndOffsetAssignedBoat(_clrIdx, _blockPos, _blockValue, blockEntityData) && GameManager.Instance.World.Entities.list.Count > 0)
        {
            // Destroying on Load output errors so I moved Destroy Orphans to OnBlockEntityTransformBeforeActivated
            DebugMsg("BlockDummyBoat OnBlockLoaded: No Boat close enough, skipping.");
        }
    }
Ejemplo n.º 2
0
        public static bool Prefix(long _key, bool _bDisplayed)
        {
            if (DistantTerrain.Instance == null)
            {
                return(true);
            }

            ChunkCluster chunkCluster = GameManager.Instance.World.ChunkClusters[0];

            if (chunkCluster == null)
            {
                return(true);
            }

            if (!GameManager.IsSplatMapAvailable())
            {
                Chunk chunkSync = chunkCluster.GetChunkSync(_key);
                if (_bDisplayed && chunkSync != null && chunkSync.NeedsOnlyCollisionMesh)
                {
                    return(true);
                }

                DistantTerrain.Instance.ActivateChunk(WorldChunkCache.extractX(_key), WorldChunkCache.extractZ(_key), !_bDisplayed);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
 public static void CheckStorage()
 {
     try
     {
         LinkedList <Chunk> chunkArray = null;
         DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
         ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
         for (int i = 0; i < chunklist.Count; i++)
         {
             ChunkCluster chunk = chunklist[i];
             chunkArray = chunk.GetChunkArray();
             if (chunkArray != null)
             {
                 foreach (Chunk c in chunkArray)
                 {
                     tiles = c.GetTileEntities();
                     if (tiles != null)
                     {
                         foreach (TileEntity tile in tiles.dict.Values)
                         {
                             if (tile.GetTileEntityType().ToString().Equals("SecureLoot"))
                             {
                                 TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                 if (GameManager.Instance.adminTools.GetUserPermissionLevel(SecureLoot.GetOwner()) > Admin_Level)
                                 {
                                     ItemStack[] items      = SecureLoot.items;
                                     int         slotNumber = 0;
                                     foreach (ItemStack item in items)
                                     {
                                         if (!item.IsEmpty())
                                         {
                                             string itemName = ItemClass.list[item.itemValue.type].Name;
                                             if (Dict.Contains(itemName))
                                             {
                                                 ItemStack itemStack = new ItemStack();
                                                 SecureLoot.UpdateSlot(slotNumber, itemStack.Clone());
                                                 tile.SetModified();
                                                 Vector3i _chestPos = SecureLoot.localChunkPos;
                                                 using (StreamWriter sw = new StreamWriter(DetectionFilepath, true, Encoding.UTF8))
                                                 {
                                                     sw.WriteLine("[SERVERTOOLS] Removed '{0}' '{1}' from a secure loot located at '{2}' owned by '{3}'", item.count, itemName, _chestPos, SecureLoot.GetOwner().CombinedString);
                                                 }
                                                 Log.Out(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from a secure loot located at '{2}' owned by '{3}'", item.count, itemName, _chestPos, SecureLoot.GetOwner().CombinedString));
                                             }
                                         }
                                         slotNumber++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in InvalidItems.CheckStorage: {0}", e.Message));
     }
 }
Ejemplo n.º 4
0
        public static bool Execute(ClientInfo sender, List <string> arguments)
        {
            World          world        = GameManager.Instance.World;
            EntityPlayer   entityPlayer = world.Players.dict[sender.entityId];
            Vector3        position     = entityPlayer.position;
            PrefabInstance prefab       = world.GetPOIAtPosition(position);

            // If no arguments just show POI info
            if (arguments.Count == 0)
            {
                if (prefab == null)
                {
                    ChatManager.Message(sender, "[FF0000]No POI found!");
                }
                else
                {
                    ChatManager.Message(sender, string.Format("[FFCC00]POI: [DDDDDD]{0}", prefab.name));
                }
                return(false);
            }

            // Fix everything around player
            int num  = World.toChunkXZ((int)position.x) - 1;
            int num2 = World.toChunkXZ((int)position.z) - 1;
            int num3 = num + 2;
            int num4 = num2 + 2;

            HashSetLong hashSetLong = new HashSetLong();

            for (int k = num; k <= num3; k++)
            {
                for (int l2 = num2; l2 <= num4; l2++)
                {
                    hashSetLong.Add(WorldChunkCache.MakeChunkKey(k, l2));
                }
            }

            ChunkCluster chunkCache = world.ChunkCache;
            ChunkProviderGenerateWorld chunkProviderGenerateWorld = world.ChunkCache.ChunkProvider as ChunkProviderGenerateWorld;

            foreach (long key in hashSetLong)
            {
                if (!chunkProviderGenerateWorld.GenerateSingleChunk(chunkCache, key, true))
                {
                    ChatManager.Message(sender, string.Format("Failed regenerating chunk at position {0}/{1}", WorldChunkCache.extractX(key) << 4, WorldChunkCache.extractZ(key) << 4));
                }
            }

            world.m_ChunkManager.ResendChunksToClients(hashSetLong);

            if (prefab != null)
            {
                prefab.Reset(world);
            }

            ChatManager.Message(sender, "[44FF44]Reseted");
            return(false);
        }
Ejemplo n.º 5
0
 public static void CheckStorage()
 {
     try
     {
         LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
         DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
         ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
         for (int i = 0; i < chunklist.Count; i++)
         {
             ChunkCluster chunk = chunklist[i];
             chunkArray = chunk.GetChunkArray();
             foreach (Chunk _c in chunkArray)
             {
                 tiles = _c.GetTileEntities();
                 foreach (TileEntity tile in tiles.dict.Values)
                 {
                     if (tile.GetTileEntityType().ToString().Equals("SecureLoot"))
                     {
                         TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                         AdminToolsClientInfo          Admin      = GameManager.Instance.adminTools.GetAdminToolsClientInfo(SecureLoot.GetOwner());
                         if (Admin.PermissionLevel > Admin_Level)
                         {
                             ItemStack[] items      = SecureLoot.items;
                             int         slotNumber = 0;
                             foreach (ItemStack item in items)
                             {
                                 if (!item.IsEmpty())
                                 {
                                     string _itemName = ItemClass.list[item.itemValue.type].Name;
                                     if (dict.Contains(_itemName))
                                     {
                                         int       _count    = item.count;
                                         ItemStack itemStack = new ItemStack();
                                         SecureLoot.UpdateSlot(slotNumber, itemStack.Clone());
                                         Vector3i _chestPos = SecureLoot.localChunkPos;
                                         using (StreamWriter sw = new StreamWriter(_filepath, true))
                                         {
                                             sw.WriteLine("[SERVERTOOLS] Removed {0} {1}, from a secure loot located at {2} {3} {4}, owned by {5}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z, SecureLoot.GetOwner());
                                             sw.WriteLine();
                                             sw.Flush();
                                             sw.Close();
                                         }
                                         Log.Out(string.Format("[SERVERTOOLS] Removed {0} {1}, from a secure loot located at {2} {3} {4}, owned by {5}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z, SecureLoot.GetOwner()));
                                     }
                                 }
                                 slotNumber++;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in InventoryCheck.ChestCheck: {0}.", e.Message));
     }
 }
Ejemplo n.º 6
0
    public static void SetSnowPrefab(Prefab prefab, ChunkCluster cluster, Vector3i position, QuestTags _questTag)
    {
        bool AlreadyFilled = false;

        if (_questTag != QuestTags.none)
        {
            AlreadyFilled = true;
            //Debug.Log("POI is resetting for a quest.");
        }
        SetSnow(position.x, position.z, prefab.size.x, prefab.size.z, cluster, Rpc, Logging, AlreadyFilled);
    }
Ejemplo n.º 7
0
        public static bool Prefix(Prefab __instance, ref Vector3i _destinationPos, ChunkCluster _cluster, QuestTags _questTags)
        {
            // If they are pre-generated Winter Project worlds, don't apply this. They'd have already been applied.
            if (GamePrefs.GetString(EnumGamePrefs.GameWorld).ToLower().Contains("winter project"))
            {
                return(true);
            }

            _destinationPos.y -= 8;
            return(true);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SurvivalKit.Events.Misc.UnknownChunkProviderEvent"/> class.
 /// </summary>
 /// <param name="args">
 /// An object array of data to pass to the event.
 /// args[0] (ChunkCluster) the ChunkCluster that fired the event.
 /// args[1] (bool) indicates whether the event is cancelled (false by default).
 /// args[2] (int) the unknown chunkProviderId.
 /// args[3] (IChunkProvider) the chunk provider (null by default).
 /// </param>
 public UnknownChunkProviderEvent(Object[] args)
 {
     if (args == null || args.Length < 4)
     {
         throw new ArgumentNullException();
     }
     cluster         = (ChunkCluster)args[0];
     cancelled       = (bool)args[1];
     chunkProviderId = (int)args[2];
     chunkProvider   = (IChunkProvider)args[3];
 }
Ejemplo n.º 9
0
    public static void SetSnowPrefab(Prefab prefab, ChunkCluster cluster, Vector3i position, QuestTags _questTag)
    {
        bool AlreadyFilled = false;

        if (_questTag != QuestTags.none)
        {
            AlreadyFilled   = true;
            prefab.yOffset -= 8;
            position.y     -= 8;
        }
        SetSnow(position.x, position.z, prefab.size.x, prefab.size.z, cluster, Rpc, Logging, AlreadyFilled, prefab.size.y);
    }
Ejemplo n.º 10
0
    public BlockEntityData GetBlockEntityData(WorldBase _world, Vector3i _blockPos, int _clrIdx)
    {
        // Try to get BlockEntityData
        ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];

        if (chunkCluster == null)
        {
            DebugMsg("BlockDummyBoat GetBlockEntityData: ChunkCluster is NULL.");
            return(null);
        }
        DebugMsg("BlockDummyBoat GetBlockEntityData: Getting BlockEntityData.");
        Chunk chunk = (Chunk)chunkCluster.GetChunkFromWorldPos(_blockPos);

        return(chunk.GetBlockEntity(_blockPos));
    }
Ejemplo n.º 11
0
    public void RemoveParentBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
    {
        ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];

        if (chunkCluster == null)
        {
            return;
        }
        Vector3i   parentPos = this.multiBlockPos.GetParentPos(_blockPos, _blockValue);
        BlockValue block     = chunkCluster.GetBlock(parentPos);

        if (!block.ischild && block.type == _blockValue.type)
        {
            chunkCluster.SetBlock(parentPos, Block.GetBlockValue("water"), true, true);
        }
    }
Ejemplo n.º 12
0
        public static void ChestCheck()
        {
            LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
            DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
            ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;

            for (int i = 0; i < chunklist.Count; i++)
            {
                ChunkCluster chunk = chunklist[i];
                chunkArray = chunk.GetChunkArray();
                foreach (Chunk _c in chunkArray)
                {
                    tiles = _c.GetTileEntities();
                    foreach (TileEntity tile in tiles.dict.Values)
                    {
                        TileEntityType type = tile.GetTileEntityType();
                        if (type.ToString().Equals("SecureLoot"))
                        {
                            TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                            AdminToolsClientInfo          Admin      = GameManager.Instance.adminTools.GetAdminToolsClientInfo(SecureLoot.GetOwner());
                            if (Admin.PermissionLevel > Admin_Level)
                            {
                                ItemStack[] items      = SecureLoot.items;
                                int         slotNumber = 0;
                                foreach (ItemStack item in items)
                                {
                                    if (!item.IsEmpty())
                                    {
                                        ItemClass _itemClass = ItemClass.list[item.itemValue.type];
                                        string    _itemName  = _itemClass.GetItemName();
                                        if (dict.Contains(_itemName))
                                        {
                                            int       _count    = item.count;
                                            ItemStack itemStack = new ItemStack();
                                            SecureLoot.UpdateSlot(slotNumber, itemStack);
                                            Vector3i _chestPos = SecureLoot.localChunkPos;
                                            Log.Out(string.Format("[SERVERTOOLS] Removed {0} {1}, from a chest located at {2} {3} {4}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z));
                                        }
                                    }
                                    slotNumber++;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try
            {
                if (_params.Count != 1)
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found '{0}'", _params.Count));

                    return;
                }
                if (!string.IsNullOrEmpty(_senderInfo.RemoteClientInfo.CrossplatformId.CombinedString))
                {
                    LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
                    DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
                    ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                    for (int i = 0; i < chunklist.Count; i++)
                    {
                        ChunkCluster chunk = chunklist[i];
                        chunkArray = chunk.GetChunkArray();
                        foreach (Chunk _c in chunkArray)
                        {
                            tiles = _c.GetTileEntities();
                            foreach (TileEntity tile in tiles.dict.Values)
                            {
                                TileEntityType type = tile.GetTileEntityType();
                                if (type.ToString().Equals("SecureLoot"))
                                {
                                    TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                    if (!SecureLoot.IsUserAllowed(_senderInfo.RemoteClientInfo.CrossplatformId))
                                    {
                                        List <PlatformUserIdentifierAbs> _users = SecureLoot.GetUsers();
                                        _users.Add(_senderInfo.RemoteClientInfo.CrossplatformId);
                                        SecureLoot.SetModified();
                                    }
                                }
                            }
                        }
                    }
                }
                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Secure loot access set for '{0}' in all loaded areas. Unloaded areas have not changed", _senderInfo.RemoteClientInfo.CrossplatformId.CombinedString));
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in SecureLootAccessConsole.Execute: {0}", e.Message));
            }
        }
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count != 1)
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found {0}", _params.Count));
             return;
         }
         if (!string.IsNullOrEmpty(_senderInfo.RemoteClientInfo.playerId))
         {
             LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
             DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
             ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
             for (int i = 0; i < chunklist.Count; i++)
             {
                 ChunkCluster chunk = chunklist[i];
                 chunkArray = chunk.GetChunkArray();
                 foreach (Chunk _c in chunkArray)
                 {
                     tiles = _c.GetTileEntities();
                     foreach (TileEntity tile in tiles.dict.Values)
                     {
                         TileEntityType type = tile.GetTileEntityType();
                         if (type.ToString().Equals("SecureDoor"))
                         {
                             TileEntitySecureDoor SecureDoor = (TileEntitySecureDoor)tile;
                             if (!SecureDoor.IsUserAllowed(_senderInfo.RemoteClientInfo.playerId))
                             {
                                 List <string> _users = SecureDoor.GetUsers();
                                 _users.Add(_senderInfo.RemoteClientInfo.playerId);
                                 SecureDoor.SetModified();
                             }
                         }
                     }
                 }
             }
         }
         SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Door access set for {0}", _senderInfo.RemoteClientInfo.playerId));
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in SecureDoorAccess.Execute: {0}", e.Message));
     }
 }
Ejemplo n.º 15
0
    public static void SetSnow(int startX, int startZ, int width, int depth, ChunkCluster cluster, bool notifyRpc, bool log, bool AlreadyFilled, int height)
    {
        Write("Set snow " + startX + "," + startZ + " by " + width + "," + depth);

        //WorldBase world = cluster.GetWorld();
        Chunk chunk = cluster.GetChunkSync(World.toChunkXZ(startX), World.toChunkXZ(startZ));

        var worldPos = new Vector3i(startX, 0, startZ);
        var size     = new Vector3i(width, height, depth);

        List <long> processed = new List <long>();

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z <= depth; z++)
            {
                int worldX      = x + startX;
                int worldZ      = z + startZ;
                int chunkWorldX = World.toChunkXZ(worldX);
                int chunkWorldZ = World.toChunkXZ(worldZ);
                //var chunkX = World.toBlockXZ(worldX);
                //var chunkZ = World.toBlockXZ(worldZ);
                if (chunk == null || chunk.X != chunkWorldX || chunk.Z != chunkWorldZ)
                {
                    Write("Getting chunk at " + chunkWorldX + "," + chunkWorldZ + "     " + worldX + "," + worldZ);
                    chunk = cluster.GetChunkSync(chunkWorldX, chunkWorldZ);

                    if (chunk != null)
                    {
                        if (processed.Contains(chunk.Key))
                        {
                            continue;
                        }
                        processed.Add(chunk.Key);
                        ProcessChunk(chunk, worldPos, size, AlreadyFilled, log, notifyRpc, true);
                    }
                }
            }
        }

        Write("Set Snow Complete");
    }
Ejemplo n.º 16
0
    /*public override void OnBlockPlaceBefore(WorldBase _world, ref BlockPlacement.Result _bpResult, EntityAlive _ea, Random _rnd)
     * {
     *  base.OnBlockPlaceBefore(_world, ref _bpResult, _ea, _rnd);
     * }*/


    public void RemoveChilds(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
    {
        ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];

        if (chunkCluster == null)
        {
            return;
        }
        byte rotation = _blockValue.rotation;

        for (int i = this.multiBlockPos.Length - 1; i >= 0; i--)
        {
            Vector3i other = this.multiBlockPos.Get(i, _blockValue.type, (int)rotation);
            if ((other.x != 0 || other.y != 0 || other.z != 0) && chunkCluster.GetBlock(_blockPos + other).type == _blockValue.type)
            {
                //chunkCluster.SetBlock(_blockPos + other, true, Block.GetBlockValue("water"), true, MarchingCubes.DensityAir, false, false, false);
                chunkCluster.SetBlock(_blockPos + other, Block.GetBlockValue("water"), false, false);
            }
        }
    }
Ejemplo n.º 17
0
    public void RemoveChilds(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
    {
        DebugMsg("BlockDummyBoat RemoveChilds");
        ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];

        if (chunkCluster == null)
        {
            DebugMsg("BlockDummyBoat RemoveChilds: Chunk is NULL");
            return;
        }
        byte rotation = _blockValue.rotation;

        for (int i = this.multiBlockPos.Length - 1; i >= 0; i--)
        {
            Vector3i other = this.multiBlockPos.Get(i, _blockValue.type, (int)rotation);
            if ((other.x != 0 || other.y != 0 || other.z != 0) && chunkCluster.GetBlock(_blockPos + other).type == _blockValue.type)
            {
                chunkCluster.SetBlock(_blockPos + other, Block.GetBlockValue("water"), false, false);
            }
        }
    }
Ejemplo n.º 18
0
    private static void testGetBiome(List <string> _params)
    {
        /* Using World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt
         *  Instead of World.getbiome */
        int x = int.Parse(_params[0]);
        int y = int.Parse(_params[1]);

        Printer.Print("testGetBiome at", x, y);
        World        w  = GameManager.Instance.World;
        ChunkCluster cc = w.ChunkCache;

        Printer.Print("testGetBiome ChunkCluster", cc);
        IChunkProvider icp = w.ChunkCache.ChunkProvider;

        Printer.Print("testGetBiome IChunkProvider", icp);
        IBiomeProvider bp = w.ChunkCache.ChunkProvider.GetBiomeProvider();

        Printer.Print("testGetBiome IBiomeProvider", bp);
        BiomeDefinition bd = w.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt(x, y);

        Printer.Print("testGetBiome BiomeDefinition", bd);
    }
Ejemplo n.º 19
0
 public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount)
 {
     if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
     {
         EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
         if (_player != null)
         {
             ItemValue _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1);
             if (_itemValue != null)
             {
                 int _coinId = _itemValue.GetItemOrBlockId();
                 if (int.TryParse(_amount, out int _value))
                 {
                     if (_value > 0)
                     {
                         int _currencyToRemove          = _value;
                         int _currencyRemoved           = 0;
                         LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                         DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                         ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                         for (int i = 0; i < _chunklist.Count; i++)
                         {
                             ChunkCluster _chunk = _chunklist[i];
                             _chunkArray = _chunk.GetChunkArray();
                             foreach (Chunk _c in _chunkArray)
                             {
                                 _tiles = _c.GetTileEntities();
                                 foreach (TileEntity _tile in _tiles.dict.Values)
                                 {
                                     TileEntityType type = _tile.GetTileEntityType();
                                     if (type.ToString().Equals("SecureLoot"))
                                     {
                                         TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                         if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                         {
                                             Vector3i vec3i = SecureLoot.ToWorldPos();
                                             if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                             {
                                                 if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                 {
                                                     ItemStack[] _items = SecureLoot.items;
                                                     if (_items != null && _items.Length > 0)
                                                     {
                                                         for (int j = 0; j < _items.Length; j++)
                                                         {
                                                             if (_currencyToRemove > 0)
                                                             {
                                                                 if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _coinId)
                                                                 {
                                                                     if (_items[j].count <= _currencyToRemove)
                                                                     {
                                                                         int _newCount  = _currencyToRemove - _items[j].count;
                                                                         int _newCount2 = _currencyRemoved + _items[j].count;
                                                                         _currencyToRemove = _newCount;
                                                                         _currencyRemoved  = _newCount2;
                                                                         _items[j]         = ItemStack.Empty.Clone();
                                                                     }
                                                                     else
                                                                     {
                                                                         int _newCount      = _currencyRemoved + _currencyToRemove;
                                                                         int _newStackCount = _items[j].count - _currencyToRemove;
                                                                         _currencyToRemove = 0;
                                                                         _currencyRemoved  = _newCount;
                                                                         _items[j]         = new ItemStack(_itemValue, _newStackCount);
                                                                     }
                                                                     _tile.SetModified();
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         if (_currencyRemoved > 0)
                         {
                             if (Deposit_Fee_Percent > 0)
                             {
                                 float _fee             = _currencyRemoved * ((float)Deposit_Fee_Percent / 100);
                                 int   _adjustedDeposit = _currencyRemoved - (int)_fee;
                                 AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                                 string _message = "Deposited {Value} {Name} from the secure loot to your bank account. " + "{Percent}" + "% deposit fee was applied.";
                                 _message = _message.Replace("{Value}", _adjustedDeposit.ToString());
                                 _message = _message.Replace("{Name}", Ingame_Coin);
                                 _message = _message.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                 {
                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _adjustedDeposit));
                                     sw.WriteLine();
                                     sw.Flush();
                                     sw.Close();
                                 }
                             }
                             else
                             {
                                 AddCoinsToBank(_cInfo.playerId, _currencyRemoved);
                                 string _message = "Deposited {Value} {Name} from the secure loot to your bank account.";
                                 _message = _message.Replace("{Value}", _currencyRemoved.ToString());
                                 _message = _message.Replace("{Name}", Ingame_Coin);
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                 {
                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _currencyRemoved));
                                     sw.WriteLine();
                                     sw.Flush();
                                     sw.Close();
                                 }
                             }
                         }
                         else
                         {
                             string _message = "Could not find any {CoinName} in a near by secure loot.";
                             _message = _message.Replace("{CoinName}", Ingame_Coin);
                             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "The bank coin is not setup correctly, contact the server Admin.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 Log.Out(string.Format("[SERVERTOOLS] Bank operation failed. Unable to find item {0}. Check the default game currency from your items.xml", Ingame_Coin));
             }
         }
     }
 }
Ejemplo n.º 20
0
        public static void CheckBox(ClientInfo _cInfo, string _price)
        {
            int _p;

            if (int.TryParse(_price, out _p))
            {
                if (_p > 0)
                {
                    if (!AuctionItems.ContainsKey(_cInfo.entityId))
                    {
                        ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                        for (int i = 0; i < chunklist.Count; i++)
                        {
                            ChunkCluster chunk = chunklist[i];
                            chunkArray = chunk.GetChunkArray();
                            for (int j = 0; j < chunkArray.Count; j++)
                            {
                                Chunk _c = chunkArray[j];
                                tiles = _c.GetTileEntities();
                                foreach (TileEntity tile in tiles.dict.Values)
                                {
                                    TileEntityType type = tile.GetTileEntityType();
                                    if (type.ToString().Equals("SecureLoot"))
                                    {
                                        EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                        TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                        Vector3i vec3i = SecureLoot.ToWorldPos();
                                        if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 1.5 * 1.5)
                                        {
                                            int _playerCount = ConnectionManager.Instance.ClientCount();
                                            if (_playerCount > 1)
                                            {
                                                List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients();
                                                for (int k = 0; k < _cInfoList.Count; k++)
                                                {
                                                    ClientInfo _cInfo2 = _cInfoList[k];
                                                    if (_cInfo != _cInfo2)
                                                    {
                                                        EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                                                        if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8)
                                                        {
                                                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            List <string> boxUsers = SecureLoot.GetUsers();
                                            if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId))
                                            {
                                                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} the local secure loot is not owned by you or a friend. You can only auction an item through a secure loot you own.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                                                return;
                                            }
                                            ItemStack[] items      = SecureLoot.items;
                                            int         count      = 0;
                                            int         slotNumber = 0;
                                            foreach (ItemStack item in items)
                                            {
                                                if (!item.IsEmpty())
                                                {
                                                    if (count < 1)
                                                    {
                                                        ItemClass _itemClass   = ItemClass.list[item.itemValue.type];
                                                        string    _itemName    = _itemClass.GetItemName();
                                                        string[]  _auctionItem = { item.count.ToString(), _itemName, item.itemValue.Quality.ToString(), _price };
                                                        SecureLoot.UpdateSlot(slotNumber, ItemStack.Empty);
                                                        AuctionItems.Add(_cInfo.entityId, _auctionItem);
                                                        PersistentContainer.Instance.Players[_cInfo.playerId, true].CancelTime  = DateTime.Now;
                                                        PersistentContainer.Instance.Players[_cInfo.playerId, true].AuctionData = _cInfo.entityId;
                                                        PersistentContainer.Instance.Players[_cInfo.playerId, true].AuctionItem = _auctionItem;
                                                        PersistentContainer.Instance.Save();
                                                        _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} your auction item {2} has been removed from the secure loot and added to the auction.[-]", Config.Chat_Response_Color, _cInfo.playerName, _itemName), Config.Server_Response_Name, false, "ServerTools", false));
                                                        using (StreamWriter sw = new StreamWriter(filepath, true))
                                                        {
                                                            sw.WriteLine(string.Format("{0}: {1} has added {2} {3}, {4} quality to the auction for {5} {6}. Entry # {7}", DateTime.Now, _cInfo.playerName, item.count, _itemName, item.itemValue.Quality, _price, Wallet.Coin_Name, _cInfo.entityId));
                                                            sw.WriteLine();
                                                            sw.Flush();
                                                            sw.Close();
                                                        }
                                                        count++;
                                                    }
                                                }
                                                slotNumber++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (!AuctionItems.ContainsKey(_cInfo.entityId))
                        {
                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} auction sell failed. No items were found in a secure chest you own near by.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                            _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} place an item in a chest and stand very close to it, then use /auction sell #.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                        }
                    }
                    else
                    {
                        _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you have auction item # {2} in the auction already. Wait for it to sell or cancel it with /auction cancel.[-]", Config.Chat_Response_Color, _cInfo.playerName, _cInfo.entityId), Config.Server_Response_Name, false, "ServerTools", false));
                    }
                }
                else
                {
                    _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you need to input a price greater than zero. This is not a transfer system.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                }
            }
            else
            {
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} your sell price must be an integer and greater than zero.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
            }
        }
Ejemplo n.º 21
0
        public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount)
        {
            ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, false);

            if (CoinCheck(_cInfo, _itemValue))
            {
                int _value;
                if (int.TryParse(_amount, out _value))
                {
                    _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1);
                    int _currencyToRemove      = _value;
                    int _currencyRemoved       = 0;
                    ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                    for (int i = 0; i < chunklist.Count; i++)
                    {
                        if (_currencyToRemove > 0)
                        {
                            ChunkCluster chunk = chunklist[i];
                            chunkArray = chunk.GetChunkArray();
                            foreach (Chunk _c in chunkArray)
                            {
                                tiles = _c.GetTileEntities();
                                foreach (TileEntity tile in tiles.dict.Values)
                                {
                                    TileEntityType type = tile.GetTileEntityType();
                                    if (type.ToString().Equals("SecureLoot"))
                                    {
                                        TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                        if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                        {
                                            Vector3i     vec3i   = SecureLoot.ToWorldPos();
                                            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                            if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 2.5 * 2.5)
                                            {
                                                ItemStack[] _items = SecureLoot.items;
                                                for (int j = 0; j < _items.Length; j++)
                                                {
                                                    if (_currencyToRemove > 0)
                                                    {
                                                        if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _itemValue.GetItemOrBlockId())
                                                        {
                                                            if (_items[j].count <= _currencyToRemove)
                                                            {
                                                                int _newCount  = _currencyToRemove - _items[j].count;
                                                                int _newCount2 = _currencyRemoved + _items[j].count;
                                                                _currencyToRemove = _newCount;
                                                                _currencyRemoved  = _newCount2;
                                                                _items[j]         = ItemStack.Empty.Clone();
                                                            }
                                                            else
                                                            {
                                                                int _newCount      = _currencyRemoved + _currencyToRemove;
                                                                int _newStackCount = _items[j].count - _currencyToRemove;
                                                                _currencyToRemove = 0;
                                                                _currencyRemoved  = _newCount;
                                                                _items[j]         = new ItemStack(_itemValue, _newStackCount);
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (_currencyRemoved > 0)
                    {
                        if (Deposit_Fee_Percent > 0)
                        {
                            int _depositFeePercent = Deposit_Fee_Percent / 100;
                            int _depositFee        = (int)_currencyRemoved * _depositFeePercent;
                            int _adjustedDeposit   = _currencyRemoved - _depositFee;
                            AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                            string _message = " deposited {Value} {Name} from the secure loot to your bank account. " + " {Percent}" + "% fee was applied.";
                            _message = _message.Replace("{Value}", _value.ToString());
                            _message = _message.Replace("{Name}", Ingame_Coin);
                            _message = _message.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                            ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            using (StreamWriter sw = new StreamWriter(filepath, true))
                            {
                                sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerName, _currencyRemoved));
                                sw.WriteLine();
                                sw.Flush();
                                sw.Close();
                            }
                            using (StreamWriter sw = new StreamWriter(filepath, true))
                            {
                                sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerName, _adjustedDeposit));
                                sw.WriteLine();
                                sw.Flush();
                                sw.Close();
                            }
                        }
                        else
                        {
                            AddCoinsToBank(_cInfo.playerId, _currencyRemoved);
                            string _message = "Removed {Total} {Name} and deposited it to your bank. ";
                            _message = _message.Replace("{Total}", _currencyRemoved.ToString());
                            _message = _message.Replace("{Name}", Ingame_Coin);
                            ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            using (StreamWriter sw = new StreamWriter(filepath, true))
                            {
                                sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerName, _currencyRemoved));
                                sw.WriteLine();
                                sw.Flush();
                                sw.Close();
                            }
                        }
                    }
                    else
                    {
                        string _message = "Could not find any {Name} in a near by secure loot.";
                        _message = _message.Replace("{Name}", Ingame_Coin);
                        ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
        }
Ejemplo n.º 22
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (int.TryParse(_price, out int _auctionPrice))
                 {
                     if (_auctionPrice > 0)
                     {
                         if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction == null)
                         {
                             Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>();
                             PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                             PersistentContainer.DataChange = true;
                         }
                         else if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count < Total_Items)
                         {
                             LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                             DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                             ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                             for (int i = 0; i < _chunklist.Count; i++)
                             {
                                 ChunkCluster _chunk = _chunklist[i];
                                 _chunkArray = _chunk.GetChunkArray();
                                 foreach (Chunk _c in _chunkArray)
                                 {
                                     _tiles = _c.GetTileEntities();
                                     foreach (TileEntity _tile in _tiles.dict.Values)
                                     {
                                         TileEntityType _type = _tile.GetTileEntityType();
                                         if (_type.ToString().Equals("SecureLoot"))
                                         {
                                             TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                             Vector3i vec3i = SecureLoot.ToWorldPos();
                                             if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                             {
                                                 if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                 {
                                                     if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                                     {
                                                         ItemStack[] items = SecureLoot.items;
                                                         ItemStack   _item = items[0];
                                                         if (_item != null && !_item.IsEmpty())
                                                         {
                                                             int _id = GenerateAuctionId();
                                                             if (_id > 0)
                                                             {
                                                                 AuctionItems.Add(_id, _cInfo.playerId);
                                                                 items[0] = ItemStack.Empty.Clone();
                                                                 if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction != null && PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count > 0)
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Add(_id, _serializedItemStack);
                                                                 }
                                                                 else
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>
                                                                     {
                                                                         { _id, _serializedItemStack }
                                                                     };
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                                                                 }
                                                                 if (PersistentContainer.Instance.AuctionPrices != null && PersistentContainer.Instance.AuctionPrices.Count > 0)
                                                                 {
                                                                     PersistentContainer.Instance.AuctionPrices.Add(_id, _auctionPrice);
                                                                 }
                                                                 else
                                                                 {
                                                                     Dictionary <int, int> _auctionPrices = new Dictionary <int, int>
                                                                     {
                                                                         { _id, _auctionPrice }
                                                                     };
                                                                     PersistentContainer.Instance.AuctionPrices = _auctionPrices;
                                                                 }
                                                                 _tile.SetModified();
                                                                 PersistentContainer.DataChange = true;
                                                                 using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                                                                 {
                                                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} {4}, {5} quality, {6} percent durability for {7} {8}.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _item.count, _item.itemValue.ItemClass.GetItemName(), _item.itemValue.Quality, _item.itemValue.UseTimes / _item.itemValue.MaxUseTimes * 100, _price, Wallet.Coin_Name));
                                                                     sw.WriteLine();
                                                                     sw.Flush();
                                                                     sw.Close();
                                                                 }
                                                                 Phrases.Dict.TryGetValue(621, out string _phrase621);
                                                                 _phrase621 = _phrase621.Replace("{Name}", _item.itemValue.ItemClass.GetLocalizedItemName() ?? _item.itemValue.ItemClass.GetItemName());
                                                                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase621 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                                                 return;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue(622, out string _phrase622);
                             _phrase622 = _phrase622.Replace("{CommandPrivate}", ChatHook.Chat_Command_Prefix1);
                             _phrase622 = _phrase622.Replace("{Command72}", Command72);
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase622 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue(623, out string _phrase623);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase623 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue(624, out string _phrase624);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase624 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in AuctionBox.CheckBox: {0}", e.Message));
     }
 }
Ejemplo n.º 23
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (int.TryParse(_price, out int _auctionPrice))
                 {
                     if (_auctionPrice > 0)
                     {
                         if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction == null)
                         {
                             Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>();
                             PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                             PersistentContainer.Instance.Save();
                         }
                         else if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count < Total_Items)
                         {
                             LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                             DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                             ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                             for (int i = 0; i < _chunklist.Count; i++)
                             {
                                 ChunkCluster _chunk = _chunklist[i];
                                 _chunkArray = _chunk.GetChunkArray();
                                 foreach (Chunk _c in _chunkArray)
                                 {
                                     _tiles = _c.GetTileEntities();
                                     foreach (TileEntity _tile in _tiles.dict.Values)
                                     {
                                         TileEntityType _type = _tile.GetTileEntityType();
                                         if (_type.ToString().Equals("SecureLoot"))
                                         {
                                             TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                             Vector3i vec3i = SecureLoot.ToWorldPos();
                                             if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                             {
                                                 if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                 {
                                                     if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                                     {
                                                         ItemStack[] items = SecureLoot.items;
                                                         ItemStack   _item = items[0];
                                                         if (_item != null && !_item.IsEmpty())
                                                         {
                                                             int _id = GenerateAuctionId();
                                                             if (_id > 0)
                                                             {
                                                                 AuctionItems.Add(_id, _cInfo.playerId);
                                                                 items[0] = ItemStack.Empty.Clone();
                                                                 if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction != null && PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count > 0)
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Add(_id, _serializedItemStack);
                                                                 }
                                                                 else
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>();
                                                                     _auctionItems.Add(_id, _serializedItemStack);
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                                                                 }
                                                                 if (PersistentContainer.Instance.AuctionPrices != null && PersistentContainer.Instance.AuctionPrices.Count > 0)
                                                                 {
                                                                     PersistentContainer.Instance.AuctionPrices.Add(_id, _auctionPrice);
                                                                 }
                                                                 else
                                                                 {
                                                                     Dictionary <int, int> _auctionPrices = new Dictionary <int, int>();
                                                                     _auctionPrices.Add(_id, _auctionPrice);
                                                                     PersistentContainer.Instance.AuctionPrices = _auctionPrices;
                                                                 }
                                                                 PersistentContainer.Instance.Save();
                                                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                                                 {
                                                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} {4}, {5} quality, {6} percent durability for {7} {8}.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _item.count, _item.itemValue.ItemClass.GetItemName(), _item.itemValue.Quality, _item.itemValue.UseTimes / _item.itemValue.MaxUseTimes * 100, _price, Wallet.Coin_Name));
                                                                     sw.WriteLine();
                                                                     sw.Flush();
                                                                     sw.Close();
                                                                 }
                                                                 string _message = "Your auction item {Name} has been removed from the secure loot and added to the auction.";
                                                                 _message = _message.Replace("{Name}", _item.itemValue.ItemClass.GetLocalizedItemName() ?? _item.itemValue.ItemClass.GetItemName());
                                                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                                 _tile.SetModified();
                                                                 return;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         else
                         {
                             string _message = "You have the max auction items already listed. Wait for one to sell or cancel it with {CommandPrivate}{Command72} #.";
                             _message = _message.Replace("{CommandPrivate}", ChatHook.Command_Private);
                             _message = _message.Replace("{Command72}", Command72);
                             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You need to input a price greater than zero. This is not a transfer system.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Your sell price must be an integer and greater than zero.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in AuctionBox.CheckBox: {0}", e.Message));
     }
 }
Ejemplo n.º 24
0
        public static void Deposit(ClientInfo _cInfo, string _amount)
        {
            bool Found = false;
            int  _coinAmount;

            if (int.TryParse(_amount, out _coinAmount))
            {
                ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                for (int i = 0; i < chunklist.Count; i++)
                {
                    ChunkCluster chunk = chunklist[i];
                    chunkArray = chunk.GetChunkArray();
                    foreach (Chunk _c in chunkArray)
                    {
                        tiles = _c.GetTileEntities();
                        foreach (TileEntity tile in tiles.dict.Values)
                        {
                            if (!Found)
                            {
                                TileEntityType type = tile.GetTileEntityType();
                                if (type.ToString().Equals("SecureLoot"))
                                {
                                    TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                    if (SecureLoot.IsUserAllowed(_cInfo.playerId))
                                    {
                                        Vector3i     vec3i   = SecureLoot.ToWorldPos();
                                        EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                        if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 1.5 * 1.5)
                                        {
                                            int _playerCount = ConnectionManager.Instance.ClientCount();
                                            if (_playerCount > 1)
                                            {
                                                List <ClientInfo> _cInfoList = ConnectionManager.Instance.Clients.List.ToList();
                                                for (int k = 0; k < _cInfoList.Count; k++)
                                                {
                                                    ClientInfo _cInfo2 = _cInfoList[k];
                                                    if (_cInfo != _cInfo2)
                                                    {
                                                        EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                                                        if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8)
                                                        {
                                                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + " you are too close to another player to deposit from your chest in to the bank.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            ItemStack[] items      = SecureLoot.items;
                                            int         slotNumber = 0;
                                            foreach (ItemStack item in items)
                                            {
                                                if (!item.IsEmpty())
                                                {
                                                    ItemClass _itemClass = ItemClass.list[item.itemValue.type];
                                                    string    _itemName  = _itemClass.GetItemName();
                                                    if (_itemName == Ingame_Coin)
                                                    {
                                                        if (item.count >= _coinAmount)
                                                        {
                                                            string    _sql    = string.Format("SELECT bank FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                                            DataTable _result = SQL.TQuery(_sql);
                                                            int       _bank;
                                                            int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bank);
                                                            _result.Dispose();
                                                            int    _percent  = Deposit_Fee / 100;
                                                            double _fee      = _coinAmount * _percent;
                                                            int    _newCoin  = _coinAmount - (int)_fee;
                                                            double _newLimit = Limit + (Limit * _percent);
                                                            if (_bank + _coinAmount <= (int)_newLimit)
                                                            {
                                                                Found = true;
                                                                int       _newCount  = item.count - _coinAmount;
                                                                ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, false);
                                                                if (_itemValue.type == ItemValue.None.type)
                                                                {
                                                                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + " the bank coin is not setup correctly, contact the server Admin.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                                    Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0}", Ingame_Coin));
                                                                    return;
                                                                }
                                                                else
                                                                {
                                                                    _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false);
                                                                }
                                                                ItemStack itemStack = new ItemStack(_itemValue, _newCount);
                                                                SecureLoot.UpdateSlot(slotNumber, itemStack);
                                                                _sql = string.Format("UPDATE Players SET bank = {0} WHERE steamid = '{1}'", _bank + _newCoin, _cInfo.playerId);
                                                                SQL.FastQuery(_sql);
                                                                using (StreamWriter sw = new StreamWriter(filepath, true))
                                                                {
                                                                    sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account.", DateTime.Now, _cInfo.playerName, _newCoin));
                                                                    sw.WriteLine();
                                                                    sw.Flush();
                                                                    sw.Close();
                                                                }
                                                                string _message = " deposited {Value} in to your bank minus the transfer fee of {Percent} percent.";
                                                                _message = _message.Replace("{Value}", _coinAmount.ToString());
                                                                _message = _message.Replace("{Percent}", Deposit_Fee.ToString());
                                                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                                return;
                                                            }
                                                            else
                                                            {
                                                                string _message = " your bank can not hold this much. The bank can hold {Limit} total. You currently have {Value}.";
                                                                _message = _message.Replace("{Limit}", Limit.ToString());
                                                                _message = _message.Replace("{Value}", _bank.ToString());
                                                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            string _message = " there is not enough {Name} in the secure loot to deposit this value.";
                                                            _message = _message.Replace("{Name}", Ingame_Coin);
                                                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                        }
                                                    }
                                                }
                                                slotNumber++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            if (Found)
            {
                string _message = "there is not enough {Value} in the secure loot to deposit this value.";
                _message = _message.Replace("{Name}", Ingame_Coin);
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you do not have enough in the secure loot to deposit that much into your bank.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Ejemplo n.º 25
0
        public static void Deposit(ClientInfo _cInfo, string _amount)
        {
            bool Found = false;
            int  _coinAmount;

            if (int.TryParse(_amount, out _coinAmount))
            {
                ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                for (int i = 0; i < chunklist.Count; i++)
                {
                    ChunkCluster chunk = chunklist[i];
                    chunkArray = chunk.GetChunkArray();
                    for (int j = 0; j < chunkArray.Count; j++)
                    {
                        Chunk _c = chunkArray[j];
                        tiles = _c.GetTileEntities();
                        foreach (TileEntity tile in tiles.dict.Values)
                        {
                            TileEntityType type = tile.GetTileEntityType();
                            if (type.ToString().Equals("SecureLoot"))
                            {
                                EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                Vector3i vec3i = SecureLoot.ToWorldPos();
                                if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 1.5 * 1.5)
                                {
                                    int _playerCount = ConnectionManager.Instance.ClientCount();
                                    if (_playerCount > 1)
                                    {
                                        List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients();
                                        for (int k = 0; k < _cInfoList.Count; k++)
                                        {
                                            ClientInfo _cInfo2 = _cInfoList[k];
                                            if (_cInfo != _cInfo2)
                                            {
                                                EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                                                if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8)
                                                {
                                                    _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    List <string> boxUsers = SecureLoot.GetUsers();
                                    if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId))
                                    {
                                        _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} the local secure loot is not owned by you. You can only deposit to the bank through a secure loot you own.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
                                        return;
                                    }
                                    ItemStack[] items      = SecureLoot.items;
                                    int         slotNumber = 0;
                                    foreach (ItemStack item in items)
                                    {
                                        if (!item.IsEmpty())
                                        {
                                            ItemClass _itemClass = ItemClass.list[item.itemValue.type];
                                            string    _itemName  = _itemClass.GetItemName();
                                            if (_itemName == Ingame_Coin)
                                            {
                                                if (item.count >= _coinAmount)
                                                {
                                                    Found = true;
                                                    int       _newCount  = item.count - _coinAmount;
                                                    ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, true);
                                                    if (_itemValue.type == ItemValue.None.type)
                                                    {
                                                        Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0}", Ingame_Coin));
                                                        return;
                                                    }
                                                    else
                                                    {
                                                        _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, true);
                                                    }
                                                    ItemStack itemStack = new ItemStack(_itemValue, _newCount);
                                                    SecureLoot.UpdateSlot(slotNumber, itemStack);
                                                    int    _oldBank = PersistentContainer.Instance.Players[_cInfo.playerId, true].Bank;
                                                    double _percent = _coinAmount * 0.05;
                                                    int    _newCoin = _coinAmount - (int)_percent;
                                                    PersistentContainer.Instance.Players[_cInfo.playerId, true].Bank = _oldBank + _newCoin;
                                                    PersistentContainer.Instance.Save();
                                                    using (StreamWriter sw = new StreamWriter(filepath, true))
                                                    {
                                                        sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account.", DateTime.Now, _cInfo.playerName, _newCoin));
                                                        sw.WriteLine();
                                                        sw.Flush();
                                                        sw.Close();
                                                    }
                                                    continue;
                                                }
                                                else
                                                {
                                                    _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} there is not enough {2} in the secure loot to deposit this value.[-]", Config.Chat_Response_Color, _cInfo.playerName, Ingame_Coin), Config.Server_Response_Name, false, "ServerTools", false));
                                                }
                                            }
                                        }
                                        slotNumber++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you input an invalid integer. Type /deposit #.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
            }
            if (Found)
            {
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} deposited {2} into your bank account from the secure loot. 5% fee was applied.[-]", Config.Chat_Response_Color, _cInfo.playerName, Ingame_Coin), Config.Server_Response_Name, false, "ServerTools", false));
            }
            else
            {
                _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you don't have enough in the secure loot to deposit that much into your bank.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false));
            }
        }
Ejemplo n.º 26
0
 public static void Postfix(Prefab __instance, Vector3i _destinationPos, ChunkCluster _cluster, QuestTags _questTags)
 {
     WinterModPrefab.SetSnowPrefab(__instance, _cluster, _destinationPos, _questTags);
 }
Ejemplo n.º 27
0
        internal static void PlayerSpawnedInWorld(ClientInfo player, RespawnType respawnReason, Vector3i _pos)
        {
            string   pId         = player.playerId;
            ModState playerState = VariableContainer.GetPlayerState(pId);
            World    world       = GameManager.Instance.World;

            if (respawnReason.Equals(RespawnType.Died))
            {
                if (playerState.Equals(ModState.RECONNECTING_TO_GAME) || playerState.Equals(ModState.IN_GAME) || playerState.Equals(ModState.START_GAME))
                {
                    if (playerState.Equals(ModState.RECONNECTING_TO_GAME))
                    {
                        Team.Member member = new Team.Member
                        {
                            entityId = player.entityId,
                            nick     = player.playerName,
                            pId      = pId
                        };

                        VariableContainer.SetPlayerState(pId, ModState.IN_GAME);
                        TeamMaker.AddPlayerToTeam(member, VariableContainer.GetPlayerLastTeam(pId));
                    }

                    // Has no items, teleport to team spawn and give items
                    Map     map   = VariableContainer.GetMap(VariableContainer.selectedMap);
                    Vector3 spawn = TeamMaker.GetPlayerTeam(pId).spawn;

                    Log.Out(string.Format("Spawn for {0} is {1}", player.playerName, spawn.ToString()));

                    // Find random spor around spawn
                    Vector3 destination = Vector3.zero;
                    //if (!world.GetRandomSpawnPositionMinMaxToPosition(spawn, 0, 2, 2, false, out destination, true))
                    // {
                    destination = spawn;
                    //}

                    player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(destination, null, false));

                    // ReGen
                    // Rebuild terrain around spawn
                    if (!refubrishedCords.Contains(spawn))
                    {
                        // But only once
                        refubrishedCords.Add(spawn);

                        PrefabInstance prefab = GameManager.Instance.World.GetPOIAtPosition(spawn);

                        int num  = World.toChunkXZ((int)spawn.x) - 1;
                        int num2 = World.toChunkXZ((int)spawn.z) - 1;
                        int num3 = num + 2;
                        int num4 = num2 + 2;

                        HashSetLong hashSetLong = new HashSetLong();
                        for (int k = num; k <= num3; k++)
                        {
                            for (int l2 = num2; l2 <= num4; l2++)
                            {
                                hashSetLong.Add(WorldChunkCache.MakeChunkKey(k, l2));
                            }
                        }

                        ChunkCluster chunkCache = world.ChunkCache;
                        ChunkProviderGenerateWorld chunkProviderGenerateWorld = world.ChunkCache.ChunkProvider as ChunkProviderGenerateWorld;

                        foreach (long key in hashSetLong)
                        {
                            if (!chunkProviderGenerateWorld.GenerateSingleChunk(chunkCache, key, true))
                            {
                                ChatManager.Message(player, string.Format("[FF4136]Failed regenerating chunk at position [FF851B]{0}[FF4136]/[FF851B]{1}", WorldChunkCache.extractX(key) << 4, WorldChunkCache.extractZ(key) << 4));
                            }
                        }

                        world.m_ChunkManager.ResendChunksToClients(hashSetLong);

                        if (prefab != null)
                        {
                            prefab.Reset(world);
                        }
                    }

                    // Give items
                    ClassManager.ApplyClass(player);

                    if (VariableContainer.GetPlayerState(pId).Equals(ModState.START_GAME))
                    {
                        VariableContainer.SetPlayerState(pId, ModState.IN_GAME);
                    }
                    else
                    {
                        HandleDiedInGame(player);
                    }
                    return;
                }
                else
                {
                    VariableContainer.SetPlayerState(pId, ModState.IN_LOBBY);
                    player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(VariableContainer.GetLobbyPosition(), null, false));
                    return;
                }
            }

            if (respawnReason.Equals(RespawnType.Teleport))
            {
                return;
            }

            if (VariableContainer.GetPlayerState(pId).Equals(ModState.RECONNECTING_TO_GAME))
            {
                // Have to kill reconected player
                Log.Out("Killing bc of reconnect: " + player.playerName);
                world.Players.dict[player.entityId].DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false, 1f);
                return;
            }

            if (VariableContainer.selectedMap == "null")
            {
                VariableContainer.SetPlayerState(pId, ModState.IN_LOBBY);
                player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(VariableContainer.GetLobbyPosition(), null, false));
            }
        }
Ejemplo n.º 28
0
        public static void CheckBox(ClientInfo _cInfo, string _price)
        {
            string    _sql    = string.Format("SELECT auctionid, steamid FROM Auction WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                int _auctionid;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _auctionid);
                string _message = "you have auction item # {Value} in the auction already. Wait for it to sell or cancel it with /auction cancel.";
                _message = _message.Replace("{Value}", _auctionid.ToString());
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                int _p;
                if (int.TryParse(_price, out _p))
                {
                    if (_p > 0)
                    {
                        ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                        for (int i = 0; i < chunklist.Count; i++)
                        {
                            ChunkCluster chunk = chunklist[i];
                            chunkArray = chunk.GetChunkArray();
                            foreach (Chunk _c in chunkArray)
                            {
                                tiles = _c.GetTileEntities();
                                foreach (TileEntity tile in tiles.dict.Values)
                                {
                                    TileEntityType type = tile.GetTileEntityType();
                                    if (type.ToString().Equals("SecureLoot"))
                                    {
                                        EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                        TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                        Vector3i vec3i = SecureLoot.ToWorldPos();
                                        if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 1.5 * 1.5)
                                        {
                                            int _playerCount = ConnectionManager.Instance.ClientCount();
                                            if (_playerCount > 1)
                                            {
                                                List <ClientInfo> _cInfoList = ConnectionManager.Instance.Clients.List.ToList();
                                                for (int k = 0; k < _cInfoList.Count; k++)
                                                {
                                                    ClientInfo _cInfo2 = _cInfoList[k];
                                                    if (_cInfo != _cInfo2)
                                                    {
                                                        EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                                                        if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8)
                                                        {
                                                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            List <string> boxUsers = SecureLoot.GetUsers();
                                            if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId))
                                            {
                                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the local secure loot is not owned by you or a friend. You can only auction an item through a secure loot you own.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                return;
                                            }
                                            ItemStack[] items      = SecureLoot.items;
                                            int         count      = 0;
                                            int         slotNumber = 0;
                                            foreach (ItemStack item in items)
                                            {
                                                if (!item.IsEmpty())
                                                {
                                                    if (count < 1)
                                                    {
                                                        ItemClass _itemClass = ItemClass.list[item.itemValue.type];
                                                        string    _itemName  = _itemClass.GetItemName();
                                                        SecureLoot.UpdateSlot(slotNumber, ItemStack.Empty);
                                                        _sql = string.Format("INSERT INTO Auction (steamid, itemName, itemCount, itemQuality, itemPrice, cancelTime, sellDate) VALUES ('{0}', '{1}', {2}, {3}, {4}, '{5}', '{6}')", _cInfo.playerId, _itemName, item.count, item.itemValue.Quality, _price, DateTime.Now, DateTime.Now);
                                                        SQL.FastQuery(_sql);
                                                        string _message = "your auction item {Name} has been removed from the secure loot and added to the auction.";
                                                        _message = _message.Replace("{Name}", _itemName);
                                                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                        using (StreamWriter sw = new StreamWriter(filepath, true))
                                                        {
                                                            sw.WriteLine(string.Format("{0}: {1} has added {2} {3}, {4} quality to the auction for {5} {6}.", DateTime.Now, _cInfo.playerName, item.count, _itemName, item.itemValue.Quality, _price, Wallet.Coin_Name));
                                                            sw.WriteLine();
                                                            sw.Flush();
                                                            sw.Close();
                                                        }
                                                        count++;
                                                    }
                                                }
                                                slotNumber++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you need to input a price greater than zero. This is not a transfer system.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", your sell price must be an integer and greater than zero.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            _result.Dispose();
        }
Ejemplo n.º 29
0
 public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount)
 {
     try
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 ItemValue _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1);
                 if (_itemValue != null)
                 {
                     int _coinId = _itemValue.GetItemOrBlockId();
                     if (int.TryParse(_amount, out int _value))
                     {
                         if (_value > 0)
                         {
                             int _currencyToRemove          = _value;
                             int _currencyRemoved           = 0;
                             LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                             DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                             ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                             for (int i = 0; i < _chunklist.Count; i++)
                             {
                                 ChunkCluster _chunkCluster = _chunklist[i];
                                 _chunkArray = _chunkCluster.GetChunkArray();
                                 foreach (Chunk _chunk in _chunkArray)
                                 {
                                     _tiles = _chunk.GetTileEntities();
                                     foreach (TileEntity _tile in _tiles.dict.Values)
                                     {
                                         TileEntityType type = _tile.GetTileEntityType();
                                         if (type.ToString().Equals("SecureLoot"))
                                         {
                                             TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                             if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                             {
                                                 Vector3i vec3i = SecureLoot.ToWorldPos();
                                                 if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                                 {
                                                     if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                     {
                                                         ItemStack[] _items = SecureLoot.items;
                                                         if (_items != null && _items.Length > 0)
                                                         {
                                                             for (int j = 0; j < _items.Length; j++)
                                                             {
                                                                 if (_currencyToRemove > 0)
                                                                 {
                                                                     if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _coinId)
                                                                     {
                                                                         if (_items[j].count <= _currencyToRemove)
                                                                         {
                                                                             int _newCount  = _currencyToRemove - _items[j].count;
                                                                             int _newCount2 = _currencyRemoved + _items[j].count;
                                                                             _currencyToRemove = _newCount;
                                                                             _currencyRemoved  = _newCount2;
                                                                             _items[j]         = ItemStack.Empty.Clone();
                                                                         }
                                                                         else
                                                                         {
                                                                             int _newCount      = _currencyRemoved + _currencyToRemove;
                                                                             int _newStackCount = _items[j].count - _currencyToRemove;
                                                                             _currencyToRemove = 0;
                                                                             _currencyRemoved  = _newCount;
                                                                             _items[j]         = new ItemStack(_itemValue, _newStackCount);
                                                                         }
                                                                         _tile.SetModified();
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                             if (_currencyRemoved > 0)
                             {
                                 if (Deposit_Fee_Percent > 0)
                                 {
                                     float _fee             = _currencyRemoved * ((float)Deposit_Fee_Percent / 100);
                                     int   _adjustedDeposit = _currencyRemoved - (int)_fee;
                                     AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                                     using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                                     {
                                         sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _adjustedDeposit));
                                         sw.WriteLine();
                                         sw.Flush();
                                         sw.Close();
                                     }
                                     Phrases.Dict.TryGetValue(643, out string _phrase643);
                                     _phrase643 = _phrase643.Replace("{Value}", _adjustedDeposit.ToString());
                                     _phrase643 = _phrase643.Replace("{CoinName}", Ingame_Coin);
                                     _phrase643 = _phrase643.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase643 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                 }
                                 else
                                 {
                                     AddCoinsToBank(_cInfo.playerId, _currencyRemoved);
                                     using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                                     {
                                         sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _currencyRemoved));
                                         sw.WriteLine();
                                         sw.Flush();
                                         sw.Close();
                                     }
                                     Phrases.Dict.TryGetValue(644, out string _phrase644);
                                     _phrase644 = _phrase644.Replace("{Value}", _currencyRemoved.ToString());
                                     _phrase644 = _phrase644.Replace("{CoinName}", Ingame_Coin);
                                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase644 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                 }
                             }
                             else
                             {
                                 Phrases.Dict.TryGetValue(645, out string _phrase645);
                                 _phrase645 = _phrase645.Replace("{CoinName}", Ingame_Coin);
                                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase645 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                             }
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue(646, out string _phrase646);
                             _phrase646 = _phrase646.Replace("{CommandPrivate}", ChatHook.Chat_Command_Prefix1);
                             _phrase646 = _phrase646.Replace("{Command95}", Command95);
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase646 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue(646, out string _phrase646);
                         _phrase646 = _phrase646.Replace("{CommandPrivate}", ChatHook.Chat_Command_Prefix1);
                         _phrase646 = _phrase646.Replace("{Command95}", Command95);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase646 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue(647, out string _phrase647);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase647 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     Log.Out(string.Format("[SERVERTOOLS] Bank operation failed. Unable to find item {0}. Check the default game currency from your items.xml", Ingame_Coin));
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bank.ChestToBankDeposit: {0}", e.Message));
     }
 }
Ejemplo n.º 30
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         if (AuctionItems.ContainsKey(_cInfo.entityId))
         {
             string _message = " you have auction item # {Value} in the auction already. Wait for it to sell or cancel it with {CommandPrivate}{Command72}.";
             _message = _message.Replace("{Value}", _cInfo.entityId.ToString());
             _message = _message.Replace("{CommandPrivate}", ChatHook.Command_Private);
             _message = _message.Replace("{Command72}", Command72);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         else
         {
             int _p;
             if (int.TryParse(_price, out _p))
             {
                 if (_p > 0)
                 {
                     LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
                     DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
                     ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                     for (int i = 0; i < chunklist.Count; i++)
                     {
                         ChunkCluster chunk = chunklist[i];
                         chunkArray = chunk.GetChunkArray();
                         foreach (Chunk _c in chunkArray)
                         {
                             tiles = _c.GetTileEntities();
                             foreach (TileEntity tile in tiles.dict.Values)
                             {
                                 TileEntityType type = tile.GetTileEntityType();
                                 if (type.ToString().Equals("SecureLoot"))
                                 {
                                     EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                     TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                     Vector3i vec3i = SecureLoot.ToWorldPos();
                                     if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 2.5f * 2.5f)
                                     {
                                         if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                         {
                                             ItemStack[] items = SecureLoot.items;
                                             ItemStack   _item = items[0];
                                             if (_item != null && !_item.IsEmpty())
                                             {
                                                 ItemClass _itemClass = ItemClass.list[_item.itemValue.type];
                                                 string    _itemName  = _item.itemValue.ItemClass.GetItemName();
                                                 SecureLoot.UpdateSlot(0, ItemStack.Empty.Clone());
                                                 AuctionItems.Add(_cInfo.entityId, _cInfo.playerId);
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionId          = _cInfo.entityId;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemName    = _itemName;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemCount   = _item.count;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemQuality = _item.itemValue.Quality;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemPrice   = _p;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionCancelTime  = DateTime.Now;
                                                 PersistentContainer.Instance.Save();
                                                 string _message = " your auction item {Name} has been removed from the secure loot and added to the auction.";
                                                 _message = _message.Replace("{Name}", _itemName);
                                                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                 Log.Out(string.Format("{0} has added {1} {2}, {3} quality to the auction for {4} {5}.", _cInfo.playerName, _item.count, _itemName, _item.itemValue.Quality, _price, Wallet.Coin_Name));
                                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                                 {
                                                     sw.WriteLine(string.Format("{0}: {1} has added {2} {3}, {4} quality to the auction for {5} {6}.", DateTime.Now, _cInfo.playerName, _item.count, _itemName, _item.itemValue.Quality, _price, Wallet.Coin_Name));
                                                     sw.WriteLine();
                                                     sw.Flush();
                                                     sw.Close();
                                                 }
                                                 return;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " no item was found in the first slot of the secure chest near you." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you need to input a price greater than zero. This is not a transfer system.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " your sell price must be an integer and greater than zero.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in AuctionBox.CheckBox: {0}.", e));
     }
 }