Пример #1
0
 /// <summary>
 /// Updates the lisenced player.
 /// </summary>
 /// <param name="lisencedPlayer">The lisenced player.</param>
 /// <param name="boatID">The boat identifier.</param>
 private void UpdateLisencedPlayer(LisencedPlayer lisencedPlayer, uint boatID)
 {
     if (lisencedPlayer.rowBoat.Id == boatID)
     {
         lisencedPlayer.rowBoat.Id = 0;
     }
     if (lisencedPlayer.rhibBoat.Id == boatID)
     {
         lisencedPlayer.rhibBoat.Id = 0;
     }
 }
Пример #2
0
        /// <summary>
        /// Checks the boats.
        /// </summary>
        private void CheckBoats()
        {
            foreach (var boat in _boatsCache.ToList())
            {
                LisencedPlayer lisencedPlayer  = boat.Value;
                var            boatNetworkable = BaseNetworkable.serverEntities.Find(boat.Key);
                if (boatNetworkable == null)
                {
                    continue;
                }
                var boatEntity = boatNetworkable.GetComponent <BaseBoat>();
                if (boatEntity == null)
                {
                    continue;
                }
                if (boatEntity.IsMounted())
                {
                    continue;
                }
                if (lisencedPlayer.rowBoat.Id == boat.Key)
                {
                    if (BoatIsActive(lisencedPlayer.rowBoat.LastDismount))
                    {
                        continue;
                    }
                    RemoveBoat(boat.Key, lisencedPlayer);
                    var player = BasePlayer.FindByID(lisencedPlayer.Userid);
                    if (player == null)
                    {
                        continue;
                    }
                    SendReply(player, Msg("boatRecalled", player.UserIDString));
                }
                else if (lisencedPlayer.rhibBoat.Id == boat.Key)
                {
                    if (BoatIsActive(lisencedPlayer.rhibBoat.LastDismount))
                    {
                        continue;
                    }
                    RemoveBoat(boat.Key, lisencedPlayer);
                    var player = BasePlayer.FindByID(lisencedPlayer.Userid);
                    if (player == null)
                    {
                        continue;
                    }
                    SendReply(player, Msg("boatRecalled", player.UserIDString));
                }
            }

            timer.Once(_intervalToCheckBoat * 60f, () => CheckBoats());
        }
Пример #3
0
 /// <summary>
 /// Removes the boat.
 /// </summary>
 /// <param name="boatID">The boat identifier.</param>
 /// <param name="lisencedPlayer">The lisenced player.</param>
 private void RemoveBoat(uint boatID, LisencedPlayer lisencedPlayer)
 {
     lisencedPlayer.ResetBoat(boatID);
     _boatsCache.Remove(boatID);
     BaseNetworkable.serverEntities.Find(boatID)?.Kill();
 }
Пример #4
0
        void CmdBuyBoat(BasePlayer player, string command, string[] args)
        {
            LisencedPlayer lisencedPlayer;

            if (args.Length == 0)
            {
                SendReply(player, Msg("helpBuyBoat", player.UserIDString));
            }
            if (args.Length >= 1)
            {
                switch (args[0].ToLower())
                {
                case "row":
                    if (!_canBuyRowBoat)
                    {
                        SendReply(player, Msg("rowBoatCannotBeBuyed", player.UserIDString));
                        break;
                    }
                    if (!_lisencedPlayer.TryGetValue(player.userID, out lisencedPlayer))
                    {
                        lisencedPlayer = new LisencedPlayer(player.userID);
                        _lisencedPlayer.Add(player.userID, lisencedPlayer);
                        if (Economics != null && _useEconomics && Economics.Call <bool>("Withdraw", player.userID, _rowBoatCost) ||
                            ServerRewards != null && _useServerRewards && ServerRewards.Call <bool>("TakePoints", player.userID, _rowBoatCost) ||
                            !_useEconomics && !_useServerRewards && Withdraw(player, _rowBoatCost))
                        {
                            lisencedPlayer.rowBoat.Buyed = true;
                            SendReply(player, Msg("boatPurchased", player.UserIDString));
                        }
                        else
                        {
                            SendReply(player, Msg("noMoney", player.UserIDString));
                        }
                    }
                    else if (!lisencedPlayer.rowBoat.Buyed)
                    {
                        if (Economics != null && _useEconomics && Economics.Call <bool>("Withdraw", player.userID, _rowBoatCost) ||
                            ServerRewards != null && _useServerRewards && ServerRewards.Call <bool>("TakePoints", player.userID, _rowBoatCost) ||
                            !_useEconomics && !_useServerRewards && Withdraw(player, _rowBoatCost))
                        {
                            lisencedPlayer.rowBoat.Buyed = true;
                            SendReply(player, Msg("boatPurchased", player.UserIDString));
                        }
                        else
                        {
                            SendReply(player, Msg("noMoney", player.UserIDString));
                        }
                    }
                    else
                    {
                        SendReply(player, Msg("boatAlreadyPurchased", player.UserIDString));
                    }
                    break;

                case "rhib":
                    if (!_canBuyRhibBoat)
                    {
                        SendReply(player, Msg("rhibCannotBeBuyed", player.UserIDString));
                        break;
                    }
                    if (!_lisencedPlayer.TryGetValue(player.userID, out lisencedPlayer))
                    {
                        lisencedPlayer = new LisencedPlayer(player.userID);
                        _lisencedPlayer.Add(player.userID, lisencedPlayer);
                        if (Economics != null && _useEconomics && Economics.Call <bool>("Withdraw", player.userID, _rhibBoatCost) ||
                            ServerRewards != null && _useServerRewards && ServerRewards.Call <bool>("TakePoints", player.userID, _rhibBoatCost) ||
                            !_useEconomics && !_useServerRewards && Withdraw(player, _rhibBoatCost))
                        {
                            lisencedPlayer.rhibBoat.Buyed = true;
                            SendReply(player, Msg("boatPurchased", player.UserIDString));
                        }
                        else
                        {
                            SendReply(player, Msg("noMoney", player.UserIDString));
                        }
                    }
                    else if (!lisencedPlayer.rhibBoat.Buyed)
                    {
                        if (Economics != null && _useEconomics && Economics.Call <bool>("Withdraw", player.userID, _rhibBoatCost) ||
                            ServerRewards != null && _useServerRewards && ServerRewards.Call <bool>("TakePoints", player.userID, _rhibBoatCost) ||
                            !_useEconomics && !_useServerRewards && Withdraw(player, _rhibBoatCost))
                        {
                            lisencedPlayer.rhibBoat.Buyed = true;
                            SendReply(player, Msg("boatPurchased", player.UserIDString));
                        }
                        else
                        {
                            SendReply(player, Msg("noMoney", player.UserIDString));
                        }
                    }
                    else
                    {
                        SendReply(player, Msg("boatAlreadyPurchased", player.UserIDString));
                    }
                    break;

                default:
                    SendReply(player, Msg("helpOptionNotFound", player.UserIDString));
                    break;
                }
            }
        }