public static bool IsAllowed(int _entityIdThatOpenedIt, TileEntityLootContainer lootContainer)
 {
     if (Backpacks.ContainsKey(lootContainer.entityId))
     {
         Backpacks.TryGetValue(lootContainer.entityId, out int ownerId);
         if (_entityIdThatOpenedIt == ownerId)
         {
             Backpacks.Remove(lootContainer.entityId);
             PersistentContainer.Instance.Backpacks.Remove(lootContainer.entityId);
             PersistentContainer.DataChange = true;
             return(true);
         }
         else if (Friend_Access)
         {
             PersistentPlayerData ppdAccess = PersistentOperations.GetPersistentPlayerDataFromEntityId(_entityIdThatOpenedIt);
             PersistentPlayerData ppdOwner  = PersistentOperations.GetPersistentPlayerDataFromEntityId(ownerId);
             if (ppdAccess != null && ppdOwner != null)
             {
                 if (ppdAccess.ACL.Contains(ppdAccess.UserIdentifier) && ppdOwner.ACL.Contains(ppdOwner.UserIdentifier))
                 {
                     Backpacks.Remove(lootContainer.entityId);
                     PersistentContainer.Instance.Backpacks.Remove(lootContainer.entityId);
                     PersistentContainer.DataChange = true;
                     return(true);
                 }
             }
         }
         return(false);
     }
     return(true);
 }
    public PersistentPlayerData Load()
    {
        PersistentPlayerData persistentPlayerData = new PersistentPlayerData();

        if (File.Exists(saveFilePath))
        {
            FileStream fs = new FileStream(saveFilePath, FileMode.Open);

            try
            {
                var bf = new BinaryFormatter();
                persistentPlayerData = (PersistentPlayerData)bf.Deserialize(fs);
            }
            catch (SerializationException e)
            {
                Debug.LogWarning($"Failed to load file '{saveFilePath}'. Reason: {e}");
            }
            finally
            {
                fs.Close();
                Debug.Log("Save file loaded");
            }
        }
        else
        {
            Debug.Log($"No save file found at {saveFilePath}");
        }

        return(persistentPlayerData);
    }
Beispiel #3
0
        public void NotifyPersistentPlayerDataEventHandlers(PersistentPlayerData player, PersistentPlayerData otherPlayer, EnumPersistentPlayerDataReason reason)
        {
            if (OnPersistentPlayerDataEvent != null)
            {
                OnPersistentPlayerDataEvent(player, otherPlayer, reason);
            }
            switch (reason)
            {
            case EnumPersistentPlayerDataReason.ACL_Invite:
                NotifyPlayerACLInviteSentHandlers(player, otherPlayer);
                break;

            case EnumPersistentPlayerDataReason.ACL_AcceptedInvite:
                NotifyPlayerACLInviteAcceptedHandlers(player, otherPlayer);
                break;

            case EnumPersistentPlayerDataReason.ACL_DeclinedInvite:
                NotifyPlayerACLInviteDeclinedHandlers(player, otherPlayer);
                break;

            case EnumPersistentPlayerDataReason.ACL_Removed:
                NotifyPlayerACLRemovedHandlers(player, otherPlayer);
                break;
            }
        }
Beispiel #4
0
        public static void CheckLP(ClientInfo _cInfo)
        {
            EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);

            if (player != null)
            {
                Vector3              position = player.GetPosition();
                int                  x        = (int)position.x;
                int                  y        = (int)position.y;
                int                  z        = (int)position.z;
                Vector3i             vector   = new Vector3i(x, y, z);
                PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
                PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(player.entityId);
                EnumLandClaimOwner   _owner = GameManager.Instance.World.GetLandClaimOwner(vector, _persistentPlayerData);
                if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally || _owner == EnumLandClaimOwner.None)
                {
                    if (CheckStuck(position.x, position.y, position.z))
                    {
                        TeleToSurface(_cInfo, player);
                    }
                    else
                    {
                        Phrases.Dict.TryGetValue("Stuck4", out string _phrase);
                        ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    Phrases.Dict.TryGetValue("Stuck2", out string _phrase);
                    ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                }
            }
        }
Beispiel #5
0
        public static void RemoveAllACL(string _playerId)
        {
            PersistentPlayerData persistentPlayerData = GetPersistentPlayerDataFromId(_playerId);

            if (persistentPlayerData != null)
            {
                PersistentPlayerList persistentPlayerList = GetPersistentPlayerList();
                foreach (KeyValuePair <PlatformUserIdentifierAbs, PersistentPlayerData> persistentPlayerData2 in persistentPlayerList.Players)
                {
                    if (persistentPlayerData2.Key != persistentPlayerData.UserIdentifier)
                    {
                        if (persistentPlayerData2.Value.ACL != null && persistentPlayerData2.Value.ACL.Contains(persistentPlayerData.UserIdentifier))
                        {
                            persistentPlayerData2.Value.RemovePlayerFromACL(persistentPlayerData.UserIdentifier);
                            persistentPlayerData2.Value.Dispatch(persistentPlayerData, EnumPersistentPlayerDataReason.ACL_Removed);
                        }
                        if (persistentPlayerData.ACL != null && persistentPlayerData.ACL.Contains(persistentPlayerData2.Value.UserIdentifier))
                        {
                            persistentPlayerData.RemovePlayerFromACL(persistentPlayerData2.Key);
                            persistentPlayerData.Dispatch(persistentPlayerData2.Value, EnumPersistentPlayerDataReason.ACL_Removed);
                        }
                    }
                }
                SavePersistentPlayerDataXML();
            }
        }
Beispiel #6
0
        public static bool ClaimedByAllySelfOrParty(string _id, Vector3i _position)
        {
            PersistentPlayerData _persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromSteamId(_id);

            if (_persistentPlayerData != null)
            {
                EnumLandClaimOwner _owner = GameManager.Instance.World.GetLandClaimOwner(_position, _persistentPlayerData);
                if (_owner == EnumLandClaimOwner.Ally || _owner == EnumLandClaimOwner.Self)
                {
                    return(true);
                }
                EntityPlayer _player = PersistentOperations.GetEntityPlayer(_id);
                if (_player != null)
                {
                    List <EntityPlayer> _party = _player.Party.MemberList;
                    if (_party.Count > 0)
                    {
                        for (int i = 0; i < _party.Count; i++)
                        {
                            EntityPlayer _partyMember = _party[i];
                            _persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromEntityId(_partyMember.entityId);
                            if (_persistentPlayerData != null)
                            {
                                _owner = GameManager.Instance.World.GetLandClaimOwner(_position, _persistentPlayerData);
                                if (_owner == EnumLandClaimOwner.Self)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #7
0
 public static void SaveClaimCheck(ClientInfo _cInfo, string _waypoint)
 {
     if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId))
     {
         World                world                 = GameManager.Instance.World;
         EntityPlayer         _player               = world.Players.dict[_cInfo.entityId];
         Vector3              _position             = _player.GetPosition();
         int                  x                     = (int)_position.x;
         int                  y                     = (int)_position.y;
         int                  z                     = (int)_position.z;
         Vector3i             _vec3i                = new Vector3i(x, y, z);
         PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
         PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId);
         EnumLandClaimOwner   _owner                = world.GetLandClaimOwner(_vec3i, _persistentPlayerData);
         if (_owner == EnumLandClaimOwner.None)
         {
             SetPoint(_cInfo, _waypoint);
         }
         else
         {
             string _phrase586;
             if (!Phrases.Dict.TryGetValue(586, out _phrase586))
             {
                 _phrase586 = " you can only save a waypoint that is outside of a claimed space.";
             }
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase586 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you can not use waypoint commands while signed up for or in an event.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Beispiel #8
0
 public void NotifyPlayerACLRemovedHandlers(PersistentPlayerData player, PersistentPlayerData otherPlayer)
 {
     if (OnPlayerACLRemoved != null)
     {
         OnPlayerACLRemoved(player, otherPlayer);
     }
 }
 public static void PlayerLoginRPC_Prefix(string _playerId, out bool __state)
 {
     __state = false;
     try
     {
         if (_playerId != null && _playerId.Length == 17)
         {
             int __maxPlayers = GamePrefs.GetInt(EnumGamePrefs.ServerMaxPlayerCount);
             if (ReservedSlots.IsEnabled && ConnectionManager.Instance.ClientCount() > __maxPlayers)
             {
                 if (ReservedSlots.FullServer(_playerId))
                 {
                     GamePrefs.Set(EnumGamePrefs.ServerMaxPlayerCount, __maxPlayers + 1);
                     __state = true;
                     return;
                 }
             }
             if (NewPlayer.IsEnabled && NewPlayer.Block_During_Bloodmoon && SkyManager.BloodMoon())
             {
                 PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerDataFromSteamId(_playerId);
                 if (_ppd == null)
                 {
                     ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_playerId);
                     if (_cInfo != null)
                     {
                         _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerDenied>().Setup(new GameUtils.KickPlayerData(GameUtils.EKickReason.ManualKick, 0, default, "[ServerTools] - New players are kicked during the bloodmoon. Please return after the bloodmoon is over")));
Beispiel #10
0
 public static void PlayerKilled(EntityPlayer _player1, EntityPlayer _player2, ClientInfo _cInfo1, ClientInfo _cInfo2)
 {
     try
     {
         if (_cInfo1.playerId != null && _player1 != null && _player2 != null && _cInfo2.playerId != null)
         {
             PersistentPlayerData _ppd1 = PersistentOperations.GetPersistentPlayerDataFromSteamId(_cInfo1.playerId);
             PersistentPlayerData _ppd2 = PersistentOperations.GetPersistentPlayerDataFromSteamId(_cInfo2.playerId);
             if (_ppd1.ACL != null && !_ppd1.ACL.Contains(_cInfo2.playerId) && _ppd2.ACL != null && !_ppd2.ACL.Contains(_cInfo1.playerId))
             {
                 if (_player1.Party != null && !_player1.Party.ContainsMember(_player2) && _player2.Party != null && !_player2.Party.ContainsMember(_player1))
                 {
                     ProcessPlayerKilled(_cInfo1, _cInfo2);
                 }
             }
             else if (_player1.Party != null && !_player1.Party.ContainsMember(_player2) && _player2.Party != null && !_player2.Party.ContainsMember(_player1))
             {
                 ProcessPlayerKilled(_cInfo1, _cInfo2);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bounties.PlayerKilled: {0}", e.Message));
     }
 }
        public static void RemoveAllClaims(string _playerId)
        {
            PersistentPlayerData _persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_playerId);

            if (_persistentPlayerData != null)
            {
                List <Vector3i> landProtectionBlocks = _persistentPlayerData.LPBlocks;
                if (landProtectionBlocks != null)
                {
                    PersistentPlayerList _persistentPlayerList = GetPersistentPlayerList();
                    for (int i = 0; i < landProtectionBlocks.Count; i++)
                    {
                        Vector3i   _position   = landProtectionBlocks[i];
                        World      world       = GameManager.Instance.World;
                        BlockValue _blockValue = world.GetBlock(_position);
                        Block      _block      = _blockValue.Block;
                        if (_block != null && _block is BlockLandClaim)
                        {
                            world.SetBlockRPC(0, _position, BlockValue.Air);
                            ConnectionManager.Instance.SendPackage(NetPackageManager.GetPackage <NetPackageEntityMapMarkerRemove>().Setup(EnumMapObjectType.LandClaim, _position.ToVector3()), false, -1, -1, -1, -1);
                            world.ObjectOnMapRemove(EnumMapObjectType.LandClaim, _position.ToVector3());
                            LandClaimBoundsHelper.RemoveBoundsHelper(_position.ToVector3());
                        }
                        GameManager.Instance.persistentPlayers.m_lpBlockMap.Remove(_position);
                        _persistentPlayerData.LPBlocks.Remove(_position);
                    }
                    SavePersistentPlayerDataXML();
                }
            }
        }
 public static void Disconnect(ClientInfo _cInfo)
 {
     try
     {
         EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_cInfo.entityId);
         if (entityPlayer != null)
         {
             if (_cInfo.entityId != -1)
             {
                 Log.Out("Player {0} disconnected after {1} minutes", new object[]
                 {
                     GameUtils.SafeStringFormat(entityPlayer.EntityName),
                     ((Time.timeSinceLevelLoad - entityPlayer.CreationTimeSinceLevelLoad) / 60f).ToCultureInvariantString("0.0")
                 });
             }
         }
         GC.Collect();
         MemoryPools.Cleanup();
         PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromSteamId(_cInfo.playerId);
         if (persistentPlayerData != null)
         {
             persistentPlayerData.LastLogin = DateTime.Now;
             persistentPlayerData.EntityId  = -1;
         }
         PersistentOperations.SavePersistentPlayerDataXML();
         ConnectionManager.Instance.DisconnectClient(_cInfo, false);
         GameManager.Instance.World.aiDirector.RemoveEntity(entityPlayer);
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in BattleLogger.Disconnect: {0}.", e.Message));
     }
 }
Beispiel #13
0
 public void NotifyPlayerACLInviteSentHandlers(PersistentPlayerData player, PersistentPlayerData otherPlayer)
 {
     if (OnPlayerACLInviteSent != null)
     {
         OnPlayerACLInviteSent(player, otherPlayer);
     }
 }
Beispiel #14
0
        public static void RemoveAllClaims(string _id)
        {
            PersistentPlayerData persistentPlayerData = GetPersistentPlayerDataFromId(_id);

            if (persistentPlayerData != null)
            {
                List <Vector3i> landProtectionBlocks = persistentPlayerData.LPBlocks;
                if (landProtectionBlocks != null)
                {
                    for (int i = 0; i < landProtectionBlocks.Count; i++)
                    {
                        Vector3i   position   = landProtectionBlocks[i];
                        World      world      = GameManager.Instance.World;
                        BlockValue blockValue = world.GetBlock(position);
                        Block      block      = blockValue.Block;
                        if (block != null && block is BlockLandClaim)
                        {
                            world.SetBlockRPC(0, position, BlockValue.Air);
                            SingletonMonoBehaviour <ConnectionManager> .Instance.SendPackage(NetPackageManager.GetPackage <NetPackageEntityMapMarkerRemove>().Setup(EnumMapObjectType.LandClaim, position.ToVector3()), false, -1, -1, -1, -1);

                            world.ObjectOnMapRemove(EnumMapObjectType.LandClaim, position.ToVector3());
                            LandClaimBoundsHelper.RemoveBoundsHelper(position.ToVector3());
                        }
                        GameManager.Instance.persistentPlayers.m_lpBlockMap.Remove(position);
                        persistentPlayerData.LPBlocks.Remove(position);
                    }
                    SavePersistentPlayerDataXML();
                }
            }
        }
Beispiel #15
0
    public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
    {
        var tileEntity       = _world.GetTileEntity(_clrIdx, _blockPos);
        var secureLootEntity = tileEntity as TileEntitySecureLootContainer;

        if (secureLootEntity == null)
        {
            return(new BlockActivationCommand[0]);
        }
        string _steamID = GamePrefs.GetString(EnumGamePrefs.PlayerId);
        PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(secureLootEntity.GetOwner());
        bool flag = !secureLootEntity.IsOwner(_steamID) && (playerData != null && playerData.ACL != null && playerData.ACL.Contains(_steamID));

        _activationCommands[0].enabled = true;
        _activationCommands[1].enabled = !secureLootEntity.IsLocked() && (secureLootEntity.IsOwner(_steamID) || flag);
        _activationCommands[2].enabled = secureLootEntity.IsLocked() && secureLootEntity.IsOwner(_steamID);
        _activationCommands[3].enabled = !secureLootEntity.IsUserAllowed(_steamID) && secureLootEntity.HasPassword() && secureLootEntity.IsLocked() || secureLootEntity.IsOwner(_steamID);
        bool isMyLandProtectedBlock = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);

        _activationCommands[4].enabled = isMyLandProtectedBlock && secureLootEntity.IsOwner(_steamID) && _takeDelay > 0.0;

        _activationCommands[5].enabled = secureLootEntity.IsOwner(_steamID);

        return(_activationCommands);
    }
Beispiel #16
0
        public static PersistentPlayerData GetPPD(string playerName)
        {
            PersistentPlayerList playerList = GameManager.Instance.GetPersistentPlayerList();
            PersistentPlayerData ppd        = playerList.GetPlayerData(playerName);

            return(ppd);
        }
        public static void RemoveAllACL(string _playerId)
        {
            PersistentPlayerData _persistentPlayerData = GetPersistentPlayerData(_playerId);

            if (_persistentPlayerData != null)
            {
                PersistentPlayerList _persistentPlayerList = PersistentOperations.GetPersistentPlayerList();
                foreach (KeyValuePair <string, PersistentPlayerData> _persistentPlayerData2 in _persistentPlayerList.Players)
                {
                    if (_persistentPlayerData2.Key != _persistentPlayerData.PlayerId)
                    {
                        if (_persistentPlayerData2.Value.ACL != null && _persistentPlayerData2.Value.ACL.Contains(_persistentPlayerData.PlayerId))
                        {
                            _persistentPlayerData2.Value.RemovePlayerFromACL(_persistentPlayerData.PlayerId);
                            _persistentPlayerData2.Value.Dispatch(_persistentPlayerData, EnumPersistentPlayerDataReason.ACL_Removed);
                        }
                        if (_persistentPlayerData.ACL != null && _persistentPlayerData.ACL.Contains(_persistentPlayerData2.Value.PlayerId))
                        {
                            _persistentPlayerData.RemovePlayerFromACL(_persistentPlayerData2.Key);
                            _persistentPlayerData.Dispatch(_persistentPlayerData2.Value, EnumPersistentPlayerDataReason.ACL_Removed);
                        }
                    }
                }
                SavePersistentPlayerDataXML();
            }
        }
Beispiel #18
0
        private static void FClaimCheck(ClientInfo _cInfo, string _waypoint)
        {
            World                world                 = GameManager.Instance.World;
            EntityPlayer         _player               = world.Players.dict[_cInfo.entityId];
            Vector3              _position             = _player.GetPosition();
            int                  x                     = (int)_position.x;
            int                  y                     = (int)_position.y;
            int                  z                     = (int)_position.z;
            Vector3i             _vec3i                = new Vector3i(x, y, z);
            PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
            PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId);
            EnumLandClaimOwner   _owner                = world.GetLandClaimOwner(_vec3i, _persistentPlayerData);

            if (_owner == EnumLandClaimOwner.None)
            {
                FCommandCost(_cInfo, _waypoint, _player);
            }
            else
            {
                string _phrase576;
                if (!Phrases.Dict.TryGetValue(576, out _phrase576))
                {
                    _phrase576 = " you can only use a waypoint that is outside of a claimed space.";
                }
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase576 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Beispiel #19
0
        public static void CheckLP(ClientInfo _cInfo)
        {
            World                world                 = GameManager.Instance.World;
            EntityPlayer         _player               = world.Players.dict[_cInfo.entityId];
            Vector3              _position             = _player.GetPosition();
            int                  x                     = (int)_position.x;
            int                  y                     = (int)_position.y;
            int                  z                     = (int)_position.z;
            Vector3i             _vec3i                = new Vector3i(x, y, z);
            PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
            PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId);
            EnumLandClaimOwner   _owner                = world.GetLandClaimOwner(_vec3i, _persistentPlayerData);

            if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally || _owner == EnumLandClaimOwner.None)
            {
                if (CheckStuck(_position.x, _position.y, _position.z))
                {
                    TeleToSurface(_cInfo, _player);
                }
                else
                {
                    Phrases.Dict.TryGetValue(554, out string _phrase554);
                    ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase554 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            else
            {
                Phrases.Dict.TryGetValue(552, out string _phrase552);
                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase552 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Beispiel #20
0
    public void LoadPlayer()
    {
        PersistentPlayerData data = SaveSystem.LoadPlayer();

        if (data != null)
        {
            playerName                 = data.playerName;
            playerXp                   = data.playerXp;
            playerXpAfterLevel         = data.playerXpAfterLevel;
            playerLevel                = data.playerLevel;
            playerLevelUp              = data.playerLevelUp;
            playerKill                 = data.playerKill;
            playerCoin                 = data.playerCoin;
            lastSelectedMapIndex       = data.lastSelectedMapIndex;
            unlockedTopAccessories     = data.unlockedTopAccessories;
            unlockedFrontAccessories   = data.unlockedFrontAccessories;
            unlockedBottomAccessories  = data.unlockedBottomAccessories;
            unlockedSpecialAccessories = data.unlockedSpecialAccessories;
            unlockedBodies             = data.unlockedBodies;
            currentTopAccessory        = data.currentTopAccessory;
            currentBody                = data.currentBody;
            currentFlag                = data.currentFlag;
            currentFrontAccessory      = data.currentFrontAccessory;
            currentBottomAccessory     = data.currentBottomAccessory;
            currentSpecialAccessory    = data.currentSpecialAccessory;
        }
        else
        {
            //if save file doesn't exist, set default values and create it
            SetDefault();
            SavePlayer();
        }
    }
Beispiel #21
0
 public static void CheckLocation(ClientInfo _cInfo, string _amount, int _exec)
 {
     if (Inside_Claim)
     {
         World                world                 = GameManager.Instance.World;
         EntityPlayer         _player               = world.Players.dict[_cInfo.entityId];
         Vector3              _position             = _player.GetPosition();
         int                  x                     = (int)_position.x;
         int                  y                     = (int)_position.y;
         int                  z                     = (int)_position.z;
         Vector3i             _vec3i                = new Vector3i(x, y, z);
         PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
         PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId);
         EnumLandClaimOwner   _owner                = world.GetLandClaimOwner(_vec3i, _persistentPlayerData);
         if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally)
         {
             if (_exec == 1)
             {
                 Deposit(_cInfo, _amount);
             }
             if (_exec == 2)
             {
                 Withdraw(_cInfo, _amount);
             }
             if (_exec == 3)
             {
                 WalletDeposit(_cInfo, _amount);
             }
             if (_exec == 4)
             {
                 WalletWithdraw(_cInfo, _amount);
             }
         }
         else
         {
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you can not use this command here.Stand in your own or a friend's claimed space.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     else
     {
         if (_exec == 1)
         {
             Deposit(_cInfo, _amount);
         }
         if (_exec == 2)
         {
             Withdraw(_cInfo, _amount);
         }
         if (_exec == 3)
         {
             WalletDeposit(_cInfo, _amount);
         }
         if (_exec == 4)
         {
             WalletWithdraw(_cInfo, _amount);
         }
     }
 }
        public static void SetHome2(ClientInfo _cInfo, string _playerName, bool _announce)
        {
            bool                 Found                 = false;
            EntityPlayer         _player               = GameManager.Instance.World.Players.dict[_cInfo.entityId];
            Vector3              _position             = _player.GetPosition();
            int                  x                     = (int)_position.x;
            int                  y                     = (int)_position.y;
            int                  z                     = (int)_position.z;
            int                  _claimSize            = GameStats.GetInt(EnumGameStats.LandClaimSize) / 2;
            PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
            PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_cInfo.playerId);
            List <Vector3i>      _blocks               = _persistentPlayerData.LPBlocks;

            for (int i = 0; i < _blocks.Count; i++)
            {
                Vector3i _vec3i = _blocks[i];
                if ((_vec3i.x - x) * (_vec3i.x - x) + (_vec3i.z - z) * (_vec3i.z - z) <= _claimSize * _claimSize)
                {
                    Found = true;
                    string _sposition = x + "," + y + "," + z;
                    PersistentContainer.Instance.Players[_cInfo.playerId, true].HomePosition2 = _sposition;
                    PersistentContainer.Instance.Save();
                    string _phrase607;
                    if (!Phrases.Dict.TryGetValue(607, out _phrase607))
                    {
                        _phrase607 = "{PlayerName} your home2 has been saved.";
                    }
                    _phrase607 = _phrase607.Replace("{PlayerName}", _cInfo.playerName);
                    if (_announce)
                    {
                        GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase607), Config.Server_Response_Name, false, "ServerTools", true);
                    }
                    else
                    {
                        _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase607), Config.Server_Response_Name, false, "ServerTools", false));
                    }
                }
            }
            if (!Found)
            {
                string _phrase817;
                if (!Phrases.Dict.TryGetValue(817, out _phrase817))
                {
                    _phrase817 = "{PlayerName} you are not inside your own claimed space. You can not save this as your home.";
                }
                _phrase817 = _phrase817.Replace("{PlayerName}", _cInfo.playerName);
                if (_announce)
                {
                    GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase817), Config.Server_Response_Name, false, "ServerTools", true);
                }
                else
                {
                    _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase817), Config.Server_Response_Name, false, "ServerTools", false));
                }
            }
        }
Beispiel #23
0
    private static void Prefix(Vector3i blockPos, ref EntityAlive lpRelative, ref PersistentPlayerData ppData)
    {
        if (!(lpRelative is EntityEnemy))
        {
            return;
        }

        lpRelative = _entityDummy;
        ppData     = null;
    }
Beispiel #24
0
    public static void SavePlayer(PlayerData player)
    {
        string          path      = Application.persistentDataPath + "/player.happy";
        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PersistentPlayerData data = new PersistentPlayerData(player);

        formatter.Serialize(stream, data);
        stream.Close();
    }
        public static bool ClaimedByUnknown(string _id, Vector3i _position)
        {
            PersistentPlayerData _persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_id);

            if (_persistentPlayerData != null)
            {
                EnumLandClaimOwner _owner = GameManager.Instance.World.GetLandClaimOwner(_position, _persistentPlayerData);
                if (_owner != EnumLandClaimOwner.None && _owner != EnumLandClaimOwner.Ally && _owner != EnumLandClaimOwner.Self)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #26
0
        public static bool ClaimedByParty(int _entityId, Vector3i _position)
        {
            PersistentPlayerData _persistentPlayerData = PersistentOperations.GetPersistentPlayerDataFromEntityId(_entityId);

            if (_persistentPlayerData != null)
            {
                EnumLandClaimOwner _owner = GameManager.Instance.World.GetLandClaimOwner(_position, _persistentPlayerData);
                if (_owner == EnumLandClaimOwner.Self)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #27
0
        public static PersistentPlayerData GetPersistentPlayerDataFromEntityId(int _entityId)
        {
            PersistentPlayerList _persistentPlayerList = GameManager.Instance.persistentPlayers;

            if (_persistentPlayerList != null)
            {
                PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_entityId);
                if (_persistentPlayerData != null)
                {
                    return(_persistentPlayerData);
                }
            }
            return(null);
        }
        public static PersistentPlayerData GetPersistentPlayerData(string _playerId)
        {
            PersistentPlayerList _persistentPlayerList = GameManager.Instance.persistentPlayers;

            if (_persistentPlayerList != null)
            {
                PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_playerId);
                if (_persistentPlayerData != null)
                {
                    return(_persistentPlayerData);
                }
            }
            return(null);
        }
        public static EntityPlayer GetEntityPlayer(string _playerId)
        {
            PersistentPlayerData _persistentPlayerData = GetPersistentPlayerData(_playerId);

            if (_persistentPlayerData != null)
            {
                EntityPlayer _entityPlayer = GameManager.Instance.World.Players.dict[_persistentPlayerData.EntityId];
                if (_entityPlayer != null)
                {
                    return(_entityPlayer);
                }
            }
            return(null);
        }
Beispiel #30
0
        public static bool ClaimedByAllyOrSelf(string _id, Vector3i _position)
        {
            PersistentPlayerData _persistentPlayerData = GetPersistentPlayerDataFromSteamId(_id);

            if (_persistentPlayerData != null)
            {
                EnumLandClaimOwner _owner = GameManager.Instance.World.GetLandClaimOwner(_position, _persistentPlayerData);
                if (_owner == EnumLandClaimOwner.Ally || _owner == EnumLandClaimOwner.Self)
                {
                    return(true);
                }
            }
            return(false);
        }