Esempio n. 1
0
 private static void TeleportPlayer(ClientInfo _cInfo)
 {
     if (DeathTime.ContainsKey(_cInfo.entityId))
     {
         DateTime _time;
         if (DeathTime.TryGetValue(_cInfo.entityId, out _time))
         {
             TimeSpan varTime           = DateTime.Now - _time;
             double   fractionalMinutes = varTime.TotalMinutes;
             int      _timepassed       = (int)fractionalMinutes;
             if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay)
             {
                 if (ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                 {
                     DateTime _dt;
                     ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                     if (DateTime.Now > _dt)
                     {
                         int _newTime = _timepassed / 2;
                         _timepassed = _newTime;
                     }
                 }
             }
             if (_timepassed < 2)
             {
                 string _value;
                 if (LastDeathPos.TryGetValue(_cInfo.entityId, out _value))
                 {
                     int      x, y, z;
                     string[] _cords = _value.Split(',');
                     int.TryParse(_cords[0], out x);
                     int.TryParse(_cords[1], out y);
                     int.TryParse(_cords[2], out z);
                     _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false));
                     DeathTime.Remove(_cInfo.entityId);
                     LastDeathPos.Remove(_cInfo.entityId);
                     if (Wallet.IsEnabled && Command_Cost >= 1)
                     {
                         Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                     }
                     PersistentContainer.Instance.Players[_cInfo.playerId].LastDied = DateTime.Now;
                     PersistentContainer.Instance.Save();
                     string _phrase736;
                     if (!Phrases.Dict.TryGetValue(736, out _phrase736))
                     {
                         _phrase736 = "Teleporting you to your last death position. You can use this again in {DelayBetweenUses} minutes.";
                     }
                     _phrase736 = _phrase736.Replace("{DelayBetweenUses}", Delay_Between_Uses.ToString());
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase736 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Your last death occurred too long ago. Command unavailable.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have no death position. Die first.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Esempio n. 2
0
 public static void GiveAnimals(ClientInfo _cInfo)
 {
     if (Animal_List.Length > 0)
     {
         string[] _animalList = { };
         if (Animal_List.Contains(","))
         {
             if (Animal_List.Contains(" "))
             {
                 Animal_List.Replace(" ", "");
             }
             _animalList = Animal_List.Split(',').ToArray();
         }
         else if (Animal_List.Contains(" "))
         {
             _animalList = Animal_List.Split(' ').ToArray();
         }
         int minRad = 0;
         int maxRad = 0;
         if (Maximum_Spawn_Radius < Minimum_Spawn_Radius)
         {
             minRad = 40;
             maxRad = 60;
         }
         else
         {
             minRad = Minimum_Spawn_Radius;
             maxRad = Maximum_Spawn_Radius;
         }
         List <string> _animalId = new List <string>();
         foreach (string i in _animalList)
         {
             _animalId.Add(i);
         }
         int _r = rnd.Next(_animalId.Count);
         int _newId;
         int.TryParse(_animalId[_r], out _newId);
         int _nextRadius = rnd.Next(minRad, maxRad + 1);
         Dictionary <int, EntityClass> .KeyCollection entityTypesCollection = EntityClass.list.Dict.Keys;
         int counter = 1;
         foreach (int i in entityTypesCollection)
         {
             EntityClass eClass = EntityClass.list[i];
             if (!eClass.bAllowUserInstantiate)
             {
                 continue;
             }
             if (_newId == counter)
             {
                 SdtdConsole.Instance.ExecuteSync(string.Format("ser {0} {1} @ {2}", _cInfo.entityId, _nextRadius, _newId), (ClientInfo)null);
             }
             counter++;
         }
         Phrases.Dict.TryGetValue(393, out string _phrase393);
         _phrase393 = _phrase393.Replace("{Radius}", _nextRadius.ToString());
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase393 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
         }
         PersistentContainer.Instance.Players[_cInfo.playerId].LastAnimal = DateTime.Now;
         PersistentContainer.Instance.Save();
     }
     else
     {
         Phrases.Dict.TryGetValue(394, out string _phrase394);
         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase394 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Esempio n. 3
0
        public static void TeleVehicle(ClientInfo _cInfo, Entity _player, int _vehicle)
        {
            int _vehicleId = 0;

            if (_vehicle == 1)
            {
                _vehicleId = PersistentContainer.Instance.Players[_cInfo.playerId].BikeId;
            }
            else if (_vehicle == 2)
            {
                _vehicleId = PersistentContainer.Instance.Players[_cInfo.playerId].MiniBikeId;
            }
            else if (_vehicle == 3)
            {
                _vehicleId = PersistentContainer.Instance.Players[_cInfo.playerId].MotorBikeId;
            }
            else if (_vehicle == 4)
            {
                _vehicleId = PersistentContainer.Instance.Players[_cInfo.playerId].JeepId;
            }
            else if (_vehicle == 5)
            {
                _vehicleId = PersistentContainer.Instance.Players[_cInfo.playerId].GyroId;
            }
            if (_vehicleId != 0)
            {
                List <Entity> Entities = GameManager.Instance.World.Entities.list;
                for (int i = 0; i < Entities.Count; i++)
                {
                    Entity _entity = Entities[i];
                    if (!_entity.IsClientControlled())
                    {
                        if (_entity.entityId == _vehicleId)
                        {
                            if ((_player.position.x - _entity.position.x) * (_player.position.x - _entity.position.x) + (_player.position.z - _entity.position.z) * (_player.position.z - _entity.position.z) <= Distance * Distance)
                            {
                                if (_entity.AttachedToEntity == false)
                                {
                                    _entity.SetPosition(_player.position);
                                    if (Wallet.IsEnabled && Command_Cost >= 1)
                                    {
                                        Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                                    }
                                    if (_vehicle == 1)
                                    {
                                        PersistentContainer.Instance.Players[_cInfo.playerId].LastBike = DateTime.Now;
                                    }
                                    if (_vehicle == 2)
                                    {
                                        PersistentContainer.Instance.Players[_cInfo.playerId].LastMiniBike = DateTime.Now;
                                    }
                                    if (_vehicle == 3)
                                    {
                                        PersistentContainer.Instance.Players[_cInfo.playerId].LastMotorBike = DateTime.Now;
                                    }
                                    if (_vehicle == 4)
                                    {
                                        PersistentContainer.Instance.Players[_cInfo.playerId].LastJeep = DateTime.Now;
                                    }
                                    if (_vehicle == 5)
                                    {
                                        PersistentContainer.Instance.Players[_cInfo.playerId].LastGyro = DateTime.Now;
                                    }
                                    PersistentContainer.DataChange = true;
                                    Phrases.Dict.TryGetValue(493, out string _phrase493);
                                    ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase493 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                    return;
                                }
                                else
                                {
                                    Phrases.Dict.TryGetValue(496, out string _phrase496);
                                    ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase496 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                    return;
                                }
                            }
                        }
                    }
                }
                Phrases.Dict.TryGetValue(495, out string _phrase495);
                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase495 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                Phrases.Dict.TryGetValue(494, out string _phrase494);
                ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase494 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Esempio n. 4
0
 public static void WalletToBankDeposit(ClientInfo _cInfo, string _amount)
 {
     try
     {
         int _value;
         if (int.TryParse(_amount, out _value))
         {
             int _walletTotal = Wallet.GetCurrentCoins(_cInfo.playerId);
             if (_walletTotal >= _value)
             {
                 Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _value);
                 if (Deposit_Fee_Percent > 0)
                 {
                     float _fee             = _value * ((float)Deposit_Fee_Percent / 100);
                     int   _adjustedDeposit = _value - (int)_fee;
                     AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                     using (StreamWriter sw = new StreamWriter(filepath, true))
                     {
                         sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from their wallet.", DateTime.Now, _cInfo.playerName, _adjustedDeposit));
                         sw.WriteLine();
                         sw.Flush();
                         sw.Close();
                     }
                     Phrases.Dict.TryGetValue(653, out string _phrase653);
                     _phrase653 = _phrase653.Replace("{Value}", _value.ToString());
                     _phrase653 = _phrase653.Replace("{CoinName}", Wallet.Coin_Name);
                     _phrase653 = _phrase653.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase653 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     AddCoinsToBank(_cInfo.playerId, _value);
                     using (StreamWriter sw = new StreamWriter(filepath, true))
                     {
                         sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from their wallet.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _value));
                         sw.WriteLine();
                         sw.Flush();
                         sw.Close();
                     }
                     Phrases.Dict.TryGetValue(654, out string _phrase654);
                     _phrase654 = _phrase654.Replace("{Value}", _value.ToString());
                     _phrase654 = _phrase654.Replace("{CoinName}", Wallet.Coin_Name);
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase654 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 Phrases.Dict.TryGetValue(655, out string _phrase655);
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase655 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             Phrases.Dict.TryGetValue(656, out string _phrase656);
             _phrase656 = _phrase656.Replace("{CommandPrivate}", ChatHook.Command_Private);
             _phrase656 = _phrase656.Replace("{Command97}", Command97);
             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase656 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bank.WalletToBankDeposit: {0}", e.Message));
     }
 }
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 1 || _params.Count > 2)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             Wallet.IsEnabled = false;
             SdtdConsole.Instance.Output(string.Format("Wallet has been set to off"));
             return;
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             Wallet.IsEnabled = true;
             SdtdConsole.Instance.Output(string.Format("Wallet has been set to on"));
             return;
         }
         else if (_params.Count == 2)
         {
             if (_params[1].Length < 1 || _params[1].Length > 5)
             {
                 SdtdConsole.Instance.Output(string.Format("Can not adjust wallet. Value {0} is invalid", _params[1]));
                 return;
             }
             int _adjustCoins;
             if (!int.TryParse(_params[1], out _adjustCoins))
             {
                 SdtdConsole.Instance.Output(string.Format("Can not adjust wallet. Value {0} is invalid", _params[1]));
                 return;
             }
             else
             {
                 string    _steamid = SQL.EscapeString(_params[0]);
                 string    _sql     = string.Format("SELECT playerSpentCoins FROM Players WHERE steamid = '{0}'", _steamid);
                 DataTable _result  = SQL.TQuery(_sql);
                 if (_result.Rows.Count != 0)
                 {
                     Wallet.AddCoinsToWallet(_steamid, _adjustCoins);
                     if (_adjustCoins >= 0)
                     {
                         SdtdConsole.Instance.Output(string.Format("Added {0} {1} to player id {2} wallet", _params[1], Wallet.Coin_Name, _steamid));
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Subtracted {0} {1} from player id {2} wallet", _params[1], Wallet.Coin_Name, _steamid));
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Player id not found: {0}", _steamid));
                 }
                 _result.Dispose();
             }
         }
         else if (_params.Count == 1)
         {
             string    _steamid = SQL.EscapeString(_params[0]);
             string    _sql     = string.Format("SELECT playerSpentCoins, zkills, kills, deaths FROM Players WHERE steamid = '{0}'", _steamid);
             DataTable _result  = SQL.TQuery(_sql);
             if (_result.Rows.Count != 0)
             {
                 int   currentCoins;
                 World world = GameManager.Instance.World;
                 int   _playerSpentCoins;
                 int   _zkills;
                 int   _kills;
                 int   _deaths;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins);
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _zkills);
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _kills);
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _deaths);
                 int gameMode = world.GetGameMode();
                 if (gameMode == 7)
                 {
                     currentCoins = (_zkills * Wallet.Zombie_Kills) + (_kills * Wallet.Player_Kills) - (_deaths * Wallet.Deaths) + _playerSpentCoins;
                 }
                 else
                 {
                     currentCoins = (_zkills * Wallet.Zombie_Kills) - (_deaths * Wallet.Deaths) + _playerSpentCoins;
                 }
                 SdtdConsole.Instance.Output(string.Format("Wallet for id {0}: {1} {2}", _params[0], currentCoins, Wallet.Coin_Name));
                 return;
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Player id not found: {0}", _steamid));
             }
             _result.Dispose();
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in WalletConsole.Run: {0}.", e));
     }
 }
Esempio n. 6
0
        public static void NewBounty(ClientInfo _cInfo, string _message, string _playerName)
        {
            int _id;

            string[] _idAndBounty = { };
            int      _cost;

            if (_message.Contains(" "))
            {
                _idAndBounty = _message.Split(' ').ToArray();
                if (int.TryParse(_idAndBounty[0], out _id))
                {
                    if (int.TryParse(_idAndBounty[1], out _cost))
                    {
                        ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForEntityId(_id);
                        if (_cInfo1 != null)
                        {
                            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo1.entityId];
                            if (_cost < Minimum_Bounty)
                            {
                                _cost = Minimum_Bounty;
                            }
                            int _currentCoins = Wallet.GetcurrentCoins(_cInfo);
                            if (_currentCoins >= _cost)
                            {
                                Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _cost);
                                string    _sql    = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo1.playerId);
                                DataTable _result = SQL.TQuery(_sql);
                                int       _bounty;
                                int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty);
                                _result.Dispose();
                                _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _bounty + _cost, _cInfo1.playerId);
                                SQL.FastQuery(_sql, "Bounties");
                                string _message1 = " you have added {Value} bounty to {PlayerName}.[-]";
                                _message1 = _message1.Replace("{Value}", _cost.ToString());
                                _message1 = _message1.Replace("{PlayerName}", _cInfo1.playerName);
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            }
                            else
                            {
                                string _message1 = " you do not have enough in your wallet for this bounty: {Value}.[-]";
                                _message1 = _message1.Replace("{Value}", _cost.ToString());
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            }
                        }
                    }
                    else
                    {
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", to add a custom bounty value, type " + ChatHook.Command_Private + Command83 + " Id# Value, or the minimum with " + ChatHook.Command_Private + Command83 + " Id#.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
            }
            else
            {
                if (int.TryParse(_message, out _id))
                {
                    ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.ForEntityId(_id);
                    if (_cInfo1 != null)
                    {
                        EntityPlayer _player       = GameManager.Instance.World.Players.dict[_cInfo1.entityId];
                        int          _currentCoins = Wallet.GetcurrentCoins(_cInfo);
                        if (_currentCoins >= Minimum_Bounty)
                        {
                            Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Minimum_Bounty);
                            string    _sql    = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo1.playerId);
                            DataTable _result = SQL.TQuery(_sql);
                            int       _bounty;
                            int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty);
                            _result.Dispose();
                            _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _bounty + Minimum_Bounty, _cInfo1.playerId);
                            SQL.FastQuery(_sql, "Bounties");
                            string _message1 = " you have added {Value} bounty to {PlayerName}.[-]";
                            _message1 = _message1.Replace("{Value}", Minimum_Bounty.ToString());
                            _message1 = _message1.Replace("{PlayerName}", _cInfo1.playerName);
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                        else
                        {
                            string _message1 = " you do not have enough in your wallet for this bounty: {Value}.[-]";
                            _message1 = _message1.Replace("{Value}", Minimum_Bounty.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message1 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public static void Tele(ClientInfo _cInfo)
        {
            if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
            {
                EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                if (_player != null)
                {
                    if (Box.Count > 0)
                    {
                        int      _playerX = (int)_player.position.x;
                        int      _playerY = (int)_player.position.y;
                        int      _playerZ = (int)_player.position.z;
                        int      xMin, yMin, zMin, xMax, yMax, zMax, xDest, yDest, zDest;
                        string[] _xyzCorner1 = { }, _xyzCorner2 = { }, _xyzDestCords = { };
                        foreach (KeyValuePair <string, string[]> kvpCorners in Box)
                        {
                            _xyzCorner1 = kvpCorners.Value[0].Split(',');
                            int.TryParse(_xyzCorner1[0], out xMin);
                            int.TryParse(_xyzCorner1[1], out yMin);
                            int.TryParse(_xyzCorner1[2], out zMin);
                            _xyzCorner2 = kvpCorners.Value[1].Split(',');
                            int.TryParse(_xyzCorner2[0], out xMax);
                            int.TryParse(_xyzCorner2[1], out yMax);
                            int.TryParse(_xyzCorner2[2], out zMax);
                            _xyzDestCords = kvpCorners.Value[2].Split(',');
                            int.TryParse(_xyzDestCords[0], out xDest);
                            int.TryParse(_xyzDestCords[1], out yDest);
                            int.TryParse(_xyzDestCords[2], out zDest);

                            if (xMin >= 0 & xMax >= 0)
                            {
                                if (xMin < xMax)
                                {
                                    if (_playerX >= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_playerX <= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_playerX <= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_playerX >= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                            }
                            else if (xMin <= 0 & xMax <= 0)
                            {
                                if (xMin < xMax)
                                {
                                    if (_playerX >= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_playerX <= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_playerX <= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_playerX >= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                            }
                            else if (xMin <= 0 & xMax >= 0)
                            {
                                if (_playerX >= xMin)
                                {
                                    _xMinCheck = 1;
                                }
                                else
                                {
                                    _xMinCheck = 0;
                                }
                                if (_playerX <= xMax)
                                {
                                    _xMaxCheck = 1;
                                }
                                else
                                {
                                    _xMaxCheck = 0;
                                }
                            }
                            else if (xMin >= 0 & xMax <= 0)
                            {
                                if (_playerX <= xMin)
                                {
                                    _xMinCheck = 1;
                                }
                                else
                                {
                                    _xMinCheck = 0;
                                }
                                if (_playerX >= xMax)
                                {
                                    _xMaxCheck = 1;
                                }
                                else
                                {
                                    _xMaxCheck = 0;
                                }
                            }

                            if (yMin >= 0 & yMax >= 0)
                            {
                                if (yMin < yMax)
                                {
                                    if (_playerY >= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_playerY <= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_playerY <= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_playerY >= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                            }
                            else if (yMin <= 0 & yMax <= 0)
                            {
                                if (yMin < yMax)
                                {
                                    if (_playerY >= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_playerY <= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_playerY <= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_playerY >= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                            }
                            else if (yMin <= 0 & yMax >= 0)
                            {
                                if (_playerY >= yMin)
                                {
                                    _yMinCheck = 1;
                                }
                                else
                                {
                                    _yMinCheck = 0;
                                }
                                if (_playerY <= yMax)
                                {
                                    _yMaxCheck = 1;
                                }
                                else
                                {
                                    _yMaxCheck = 0;
                                }
                            }
                            else if (yMin >= 0 & yMax <= 0)
                            {
                                if (_playerY <= yMin)
                                {
                                    _yMinCheck = 1;
                                }
                                else
                                {
                                    _yMinCheck = 0;
                                }
                                if (_playerY >= yMax)
                                {
                                    _yMaxCheck = 1;
                                }
                                else
                                {
                                    _yMaxCheck = 0;
                                }
                            }

                            if (zMin >= 0 & zMax >= 0)
                            {
                                if (zMin < zMax)
                                {
                                    if (_playerZ >= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_playerZ <= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_playerZ <= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_playerZ >= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                            }
                            else if (zMin <= 0 & zMax <= 0)
                            {
                                if (zMin < zMax)
                                {
                                    if (_playerZ >= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_playerZ <= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_playerZ <= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_playerZ >= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                            }
                            else if (zMin <= 0 & zMax >= 0)
                            {
                                if (_playerZ >= zMin)
                                {
                                    _zMinCheck = 1;
                                }
                                else
                                {
                                    _zMinCheck = 0;
                                }
                                if (_playerZ <= zMax)
                                {
                                    _zMaxCheck = 1;
                                }
                                else
                                {
                                    _zMaxCheck = 0;
                                }
                            }
                            else if (zMin >= 0 & zMax <= 0)
                            {
                                if (_playerY <= zMin)
                                {
                                    _zMinCheck = 1;
                                }
                                else
                                {
                                    _zMinCheck = 0;
                                }
                                if (_playerY >= zMax)
                                {
                                    _zMaxCheck = 1;
                                }
                                else
                                {
                                    _zMaxCheck = 0;
                                }
                            }
                            if (_xMinCheck == 1 & _yMinCheck == 1 & _zMinCheck == 1 & _xMaxCheck == 1 & _yMaxCheck == 1 & _zMaxCheck == 1)
                            {
                                if (PvP_Check)
                                {
                                    if (Teleportation.PCheck(_cInfo, _player))
                                    {
                                        return;
                                    }
                                }
                                if (Zombie_Check)
                                {
                                    if (Teleportation.ZCheck(_cInfo, _player))
                                    {
                                        return;
                                    }
                                }
                                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(xDest, yDest, zDest), null, false));
                                if (Wallet.IsEnabled && Command_Cost >= 1)
                                {
                                    Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                                }
                                PersistentContainer.Instance.Players[_cInfo.playerId].LastTravel = DateTime.Now;
                                PersistentContainer.Instance.Save();
                                string _phrase603;
                                if (!Phrases.Dict.TryGetValue(603, out _phrase603))
                                {
                                    _phrase603 = "You have traveled to {Destination}.";
                                }
                                _phrase603 = _phrase603.Replace("{Destination}", kvpCorners.Key);
                                ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase603 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                return;
                            }
                        }
                        string _phrase604;
                        if (!Phrases.Dict.TryGetValue(604, out _phrase604))
                        {
                            _phrase604 = "You are not in a travel location.";
                        }
                        ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase604 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        return;
                    }
                }
            }
        }
Esempio n. 8
0
 public static void GiveAnimals(ClientInfo _cInfo, bool _announce)
 {
     if (Animal_List.Length > 0)
     {
         string[] _animalList = { };
         if (Animal_List.Contains(","))
         {
             if (Animal_List.Contains(" "))
             {
                 Animal_List.Replace(" ", "");
             }
             _animalList = Animal_List.Split(',').ToArray();
         }
         else if (Animal_List.Contains(" "))
         {
             _animalList = Animal_List.Split(' ').ToArray();
         }
         int minRad = 0;
         int maxRad = 0;
         if (Maximum_Spawn_Radius < Minimum_Spawn_Radius)
         {
             minRad = 40;
             maxRad = 60;
         }
         else
         {
             minRad = Minimum_Spawn_Radius;
             maxRad = Maximum_Spawn_Radius;
         }
         int _r = rnd.Next(0, Animal_List.Length);
         int _newId;
         int.TryParse(_animalList[_r], out _newId);
         int         _nextRadius = rnd.Next(minRad, maxRad + 1);
         EntityClass eClass      = EntityClass.list[_newId];
         if (!eClass.bAllowUserInstantiate)
         {
             return;
         }
         SdtdConsole.Instance.ExecuteSync(string.Format("ser {0} {1} @ {2}", _cInfo.entityId, _nextRadius, _newId), (ClientInfo)null);
         string _phrase715;
         if (!Phrases.Dict.TryGetValue(715, out _phrase715))
         {
             _phrase715 = " you have tracked down an animal to within {Radius} metres.";
         }
         _phrase715 = _phrase715.Replace("{Radius}", _nextRadius.ToString());
         if (_announce)
         {
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase715 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
         }
         else
         {
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase715 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         string _sql;
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
         }
         _sql = string.Format("UPDATE Players SET lastAnimals = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
         SQL.FastQuery(_sql);
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", animal list is empty. Contact an administrator.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Esempio n. 9
0
 public static void NewBounty(ClientInfo _cInfo, string _message)
 {
     try
     {
         if (_message.Contains(" "))
         {
             string[] idAndBounty = _message.Split(' ').ToArray();
             if (int.TryParse(idAndBounty[0], out int id))
             {
                 if (int.TryParse(idAndBounty[1], out int bounty))
                 {
                     ClientInfo cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(id);
                     if (cInfo2 != null)
                     {
                         if (bounty < Minimum_Bounty)
                         {
                             bounty = Minimum_Bounty;
                         }
                         int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
                         if (currentCoins >= bounty)
                         {
                             Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, bounty);
                             int _currentbounty = PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty;
                             PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty = _currentbounty + bounty;
                             PersistentContainer.DataChange = true;
                             using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                             {
                                 sw.WriteLine(string.Format("{0}: '{1}' named '{2}' added '{3}' bounty to '{4}' '{5}' named '{6}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, bounty, cInfo2.PlatformId.CombinedString, cInfo2.CrossplatformId.CombinedString, cInfo2.playerName));
                                 sw.WriteLine();
                                 sw.Flush();
                                 sw.Close();
                             }
                             Phrases.Dict.TryGetValue("Bounties5", out string phrase);
                             phrase = phrase.Replace("{Value}", bounty.ToString());
                             phrase = phrase.Replace("{PlayerName}", cInfo2.playerName);
                             ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null);
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue("Bounties4", out string phrase);
                             phrase = phrase.Replace("{Value}", bounty.ToString());
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Bounties6", out string phrase);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
         else
         {
             if (int.TryParse(_message, out int _id))
             {
                 ClientInfo cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_id);
                 if (cInfo2 != null)
                 {
                     int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString);
                     if (currentCoins >= Minimum_Bounty)
                     {
                         Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Minimum_Bounty);
                         int _currentbounty = PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty;
                         PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty = _currentbounty + Minimum_Bounty;
                         PersistentContainer.DataChange = true;
                         using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                         {
                             sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' added '{4}' bounty to '{5}' '{6}' named '{7}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, Minimum_Bounty, cInfo2.PlatformId.CombinedString, cInfo2.CrossplatformId.CombinedString, cInfo2.playerName));
                             sw.WriteLine();
                             sw.Flush();
                             sw.Close();
                         }
                         Phrases.Dict.TryGetValue("Bounties5", out string phrase);
                         phrase = phrase.Replace("{Value}", Minimum_Bounty.ToString());
                         phrase = phrase.Replace("{PlayerName}", cInfo2.playerName);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue("Bounties4", out string phrase);
                         phrase = phrase.Replace("{Value}", Minimum_Bounty.ToString());
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bounties.NewBounty: {0}", e.Message));
     }
 }
Esempio n. 10
0
        private static void RandomItem(ClientInfo _cInfo, bool _announce)
        {
            string    _randomItem = list.RandomObject();
            ItemValue _itemValue  = ItemClass.GetItem(_randomItem, false);

            _itemValue = new ItemValue(_itemValue.type, false);
            EntityPlayer _player  = GameManager.Instance.World.Players.dict[_cInfo.entityId];
            int          _quality = 1;

            if (_itemValue.HasQuality)
            {
                _quality           = random.Next(1, 7);
                _itemValue.Quality = _quality;
            }
            int[] _counts;
            if (dict.TryGetValue(_randomItem, out _counts))
            {
                int       _count    = random.Next(_counts[0], _counts[1] + 1);
                ItemStack _itemDrop = new ItemStack(_itemValue, _count);
                ItemValue itemValue;
                itemValue = new ItemValue(ItemClass.GetItem(_randomItem).type, _quality, _quality, false);
                World world      = GameManager.Instance.World;
                var   entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                {
                    entityClass     = EntityClass.FromString("item"),
                    id              = EntityFactory.nextEntityID++,
                    itemStack       = new ItemStack(itemValue, _count),
                    pos             = world.Players.dict[_cInfo.entityId].position,
                    rot             = new Vector3(20f, 0f, 20f),
                    lifetime        = 60f,
                    belongsPlayerId = _cInfo.entityId
                });
                world.SpawnEntityInWorld(entityItem);
                _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId));
                world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                string _phrase7;
                if (!Phrases.Dict.TryGetValue(7, out _phrase7))
                {
                    _phrase7 = " received {ItemCount} {ItemName} from gimme.";
                }
                _phrase7 = _phrase7.Replace("{ItemCount}", _count.ToString());
                string _name;
                if (dict1.TryGetValue(_randomItem, out _name))
                {
                    _phrase7 = _phrase7.Replace("{ItemName}", _name);
                }
                if (_announce)
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase7 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase7 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
                string _sql;
                if (Wallet.IsEnabled && Command_Cost >= 1)
                {
                    Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                }
                _sql = string.Format("UPDATE Players SET last_gimme = '{0}' WHERE steamid = '{1}'", DateTime.Now.ToString(), _cInfo.playerId);
                SQL.FastQuery(_sql);
            }
        }
Esempio n. 11
0
 public static void Tele(ClientInfo _cInfo)
 {
     try
     {
         EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
         if (player != null)
         {
             if (Dict.Count > 0)
             {
                 int x = (int)player.position.x;
                 int y = (int)player.position.y;
                 int z = (int)player.position.z;
                 foreach (KeyValuePair <string, string[]> travel in Dict)
                 {
                     string[] c1 = travel.Value[0].Split(',');
                     int.TryParse(c1[0], out int x1);
                     int.TryParse(c1[1], out int y1);
                     int.TryParse(c1[2], out int z1);
                     string[] c2 = travel.Value[1].Split(',');
                     int.TryParse(c2[0], out int x2);
                     int.TryParse(c2[1], out int y2);
                     int.TryParse(c2[2], out int z2);
                     if (x >= x1 && x <= x2 && y >= y1 && y <= y2 && z >= z1 && z <= z2)
                     {
                         if (Player_Check)
                         {
                             if (Teleportation.PCheck(_cInfo, player))
                             {
                                 return;
                             }
                         }
                         if (Zombie_Check)
                         {
                             if (Teleportation.ZCheck(_cInfo, player))
                             {
                                 return;
                             }
                         }
                         string[] destination = travel.Value[2].Split(',');
                         int.TryParse(destination[0], out int destinationX);
                         int.TryParse(destination[1], out int destinationY);
                         int.TryParse(destination[2], out int destinationZ);
                         _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(destinationX, destinationY, destinationZ), null, false));
                         if (Wallet.IsEnabled && Command_Cost >= 1)
                         {
                             Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost);
                         }
                         PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastTravel = DateTime.Now;
                         PersistentContainer.DataChange = true;
                         Phrases.Dict.TryGetValue("Travel1", out string phrase);
                         phrase = phrase.Replace("{Destination}", travel.Value[2]);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         return;
                     }
                 }
                 Phrases.Dict.TryGetValue("Travel2", out string phrase1);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 return;
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Travel.Tele: {0}", e.Message));
     }
 }