예제 #1
0
        private static void RandomItem(ClientInfo _cInfo, bool _announce)
        {
            string    _randomItem = list.RandomObject();
            ItemValue _itemValue  = ItemClass.GetItem(_randomItem, true);

            _itemValue = new ItemValue(_itemValue.type, true);
            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, true);
                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);
            }
        }
예제 #2
0
        public static void ReturnToPosition(ClientInfo _cInfo)
        {
            bool      _donator = false;
            string    _sql     = string.Format("SELECT respawnTime FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result  = SQL.TQuery(_sql);
            DateTime  _respawnTime;

            DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _respawnTime);
            _result.Dispose();
            TimeSpan varTime           = DateTime.Now - _respawnTime;
            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)
                    {
                        _donator = true;
                        if (_timepassed <= 6)
                        {
                            string _deathPos;
                            if (Victim.TryGetValue(_cInfo.entityId, out _deathPos))
                            {
                                int      x, y, z;
                                string[] _cords = _deathPos.Split(',');
                                int.TryParse(_cords[0], out x);
                                int.TryParse(_cords[1], out y);
                                int.TryParse(_cords[2], out z);
                                _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
                                Victim.Remove(_cInfo.entityId);
                            }
                        }
                        else
                        {
                            string _phrase811;
                            if (!Phrases.Dict.TryGetValue(606, out _phrase811))
                            {
                                _phrase811 = " you can only use {CommandPrivate}{Command50} for six minutes after being killed in a pve zone. Time has expired.";
                            }
                            _phrase811 = _phrase811.Replace("{PlayerName}", _cInfo.playerName);
                            _phrase811 = _phrase811.Replace("{CommandPrivate}", ChatHook.Command_Private);
                            _phrase811 = _phrase811.Replace("{Command50}", Zones.Command50);
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase811 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            Victim.Remove(_cInfo.entityId);
                        }
                    }
                }
            }
            if (!_donator)
            {
                if (_timepassed <= 3)
                {
                    string _deathPos;
                    if (Victim.TryGetValue(_cInfo.entityId, out _deathPos))
                    {
                        int      x, y, z;
                        string[] _cords = _deathPos.Split(',');
                        int.TryParse(_cords[0], out x);
                        int.TryParse(_cords[1], out y);
                        int.TryParse(_cords[2], out z);
                        _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false));
                        Victim.Remove(_cInfo.entityId);
                    }
                }
                else
                {
                    string _phrase606;
                    if (!Phrases.Dict.TryGetValue(606, out _phrase606))
                    {
                        _phrase606 = " you can only use {CommandPrivate}{Command50} for three minutes after being killed in a pve zone. Time has expired.";
                    }
                    _phrase606 = _phrase606.Replace("{PlayerName}", _cInfo.playerName);
                    _phrase606 = _phrase606.Replace("{CommandPrivate}", ChatHook.Command_Private);
                    _phrase606 = _phrase606.Replace("{Command50}", Command50);
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase606 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    Victim.Remove(_cInfo.entityId);
                }
            }
        }
예제 #3
0
        public static void Checkplayer(ClientInfo _cInfo, bool _announce, string _playerName)
        {
            bool _donator = false;

            if (Delay_Between_Uses < 1)
            {
                if (Wallet.IsEnabled && Command_Cost >= 1)
                {
                    CommandCost(_cInfo, _announce);
                }
                else
                {
                    GiveItem(_cInfo, _announce);
                }
            }
            else
            {
                string    _sql    = string.Format("SELECT last_gimme FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                DataTable _result = SQL.TQuery(_sql);
                if (_result.Rows.Count > 0)
                {
                    DateTime _lastgimme;
                    DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastgimme);
                    _result.Dispose();
                    TimeSpan varTime           = DateTime.Now - _lastgimme;
                    double   fractionalMinutes = varTime.TotalMinutes;
                    int      _timepassed       = (int)fractionalMinutes;
                    if (ReservedSlots.IsEnabled)
                    {
                        if (ReservedSlots.Reduced_Delay && ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                        {
                            DateTime _dt;
                            ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                            if (DateTime.Now < _dt)
                            {
                                _donator = true;
                                int _newDelay = Delay_Between_Uses / 2;
                                if (_timepassed >= _newDelay)
                                {
                                    if (Wallet.IsEnabled && Command_Cost >= 1)
                                    {
                                        CommandCost(_cInfo, _announce);
                                    }
                                    else
                                    {
                                        GiveItem(_cInfo, _announce);
                                    }
                                }
                                else
                                {
                                    int    _timeleft = _newDelay - _timepassed;
                                    string _phrase6;
                                    if (!Phrases.Dict.TryGetValue(6, out _phrase6))
                                    {
                                        _phrase6 = "you can only use /gimme once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                                    }
                                    _phrase6 = _phrase6.Replace("{DelayBetweenUses}", _newDelay.ToString());
                                    _phrase6 = _phrase6.Replace("{TimeRemaining}", _timeleft.ToString());
                                    if (_announce)
                                    {
                                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase6 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                    }
                                    else
                                    {
                                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase6 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                    }
                                }
                            }
                        }
                    }
                    if (!_donator)
                    {
                        if (_timepassed >= Delay_Between_Uses)
                        {
                            if (Wallet.IsEnabled && Command_Cost >= 1)
                            {
                                CommandCost(_cInfo, _announce);
                            }
                            else
                            {
                                GiveItem(_cInfo, _announce);
                            }
                        }
                        else
                        {
                            int    _timeleft = Delay_Between_Uses - _timepassed;
                            string _phrase6;
                            if (!Phrases.Dict.TryGetValue(6, out _phrase6))
                            {
                                _phrase6 = "you can only use /gimme once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes.";
                            }
                            _phrase6 = _phrase6.Replace("{DelayBetweenUses}", Delay_Between_Uses.ToString());
                            _phrase6 = _phrase6.Replace("{TimeRemaining}", _timeleft.ToString());
                            if (_announce)
                            {
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase6 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                            }
                            else
                            {
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase6 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            }
                        }
                    }
                }
                else
                {
                    _result.Dispose();
                }
            }
        }