public static void PlayerCheck()
 {
     try
     {
         if (!IsRunning)
         {
             IsRunning = true;
             List <ClientInfo> _cInfoList = PersistentOperations.ClientList();
             if (_cInfoList != null && _cInfoList.Count > 0)
             {
                 for (int i = 0; i < _cInfoList.Count; i++)
                 {
                     ClientInfo _cInfo = _cInfoList[i];
                     if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0)
                     {
                         EntityAlive _player = PersistentOperations.GetPlayerAlive(_cInfo.playerId);
                         if (_player != null)
                         {
                             if (!_player.IsDead())
                             {
                                 if (_player.IsSpawned() && _player.IsAlive())
                                 {
                                     if (Zones.IsEnabled)
                                     {
                                         Zones.ZoneCheck(_cInfo, _player);
                                     }
                                     if (Lobby.IsEnabled)
                                     {
                                         Lobby.LobbyCheck(_cInfo, _player);
                                     }
                                     if (Market.IsEnabled)
                                     {
                                         Market.MarketCheck(_cInfo, _player);
                                     }
                                 }
                             }
                             else if (BloodmoonWarrior.IsEnabled && BloodmoonWarrior.WarriorList.Contains(_cInfo.playerId))
                             {
                                 BloodmoonWarrior.WarriorList.Remove(_cInfo.playerId);
                                 BloodmoonWarrior.KilledZombies.Remove(_cInfo.playerId);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in PersistentOperations.PlayerCheck: {0}", e.Message));
     }
     IsRunning = false;
 }
 public static void Exec()
 {
     try
     {
         if (!BloodmoonStarted)
         {
             if (PersistentOperations.BloodMoonSky())
             {
                 BloodmoonStarted = true;
                 List <ClientInfo> _cInfoList = PersistentOperations.ClientList();
                 if (_cInfoList != null)
                 {
                     for (int i = 0; i < _cInfoList.Count; i++)
                     {
                         ClientInfo _cInfo = _cInfoList[i];
                         if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0)
                         {
                             EntityAlive _player = (EntityAlive)PersistentOperations.GetEntity(_cInfo.entityId);
                             if (_player != null && _player.IsSpawned() && _player.IsAlive() && _player.Died > 0 && _player.Progression.GetLevel() >= 10 && random.Next(0, 11) < 6)
                             {
                                 WarriorList.Add(_cInfo.entityId);
                                 KilledZombies.Add(_cInfo.entityId, 0);
                                 string _response = "Hades has called upon you. Survive this night and kill {ZombieCount} zombies to be rewarded by the king of the underworld.";
                                 _response = _response.Replace("{ZombieCount}", Zombie_Kills.ToString());
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _response + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                             }
                         }
                     }
                 }
             }
         }
         else if (!PersistentOperations.BloodMoonSky())
         {
             BloodmoonStarted = false;
             RewardWarriors();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}.", e.Message));
     }
 }
 public static void Exec()
 {
     if (!BloodmoonStarted)
     {
         if (PersistentOperations.BloodMoonSky())
         {
             BloodmoonStarted = true;
             List <ClientInfo> _cInfoList = PersistentOperations.ClientList();
             if (_cInfoList != null)
             {
                 for (int i = 0; i < _cInfoList.Count; i++)
                 {
                     ClientInfo _cInfo = _cInfoList[i];
                     if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0)
                     {
                         EntityAlive _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                         if (_player != null && _player.IsSpawned() && _player.IsAlive())
                         {
                             WarriorList.Add(_cInfo.entityId);
                             KilledZombies.Add(_cInfo.entityId, 0);
                             if (_cInfo != null)
                             {
                                 string _response = "Hades has called upon you. Survive this night and kill {ZombieCount} zombies to be rewarded by the king of the underworld.";
                                 _response = _response.Replace("{ZombieCount}", Zombie_Kills.ToString());
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _response + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                             }
                         }
                     }
                 }
             }
         }
     }
     else if (!PersistentOperations.BloodMoonSky())
     {
         BloodmoonStarted = false;
         RewardWarriors();
     }
 }
Пример #4
0
 public static void Exec()
 {
     try
     {
         if ((int)GameManager.Instance.fps.Counter > 4)
         {
             List <ClientInfo> _cInfoList = PersistentOperations.ClientList();
             if (_cInfoList != null)
             {
                 for (int i = 0; i < _cInfoList.Count; i++)
                 {
                     ClientInfo _cInfo = _cInfoList[i];
                     if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0)
                     {
                         AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId);
                         if (Admin.PermissionLevel > Admin_Level)
                         {
                             EntityAlive _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                             if (_player != null && _player.IsSpawned() && _player.IsAlive() && !_player.IsStuck)
                             {
                                 float _x = _player.position.x;
                                 float _y = _player.position.y;
                                 float _z = _player.position.z;
                                 if (_player.AttachedToEntity == null && (AirCheck(_x, _y, _z) || GroundCheck(_x, _y, _z)))
                                 {
                                     if (OldY.ContainsKey(_cInfo.entityId))
                                     {
                                         float lastY;
                                         OldY.TryGetValue(_cInfo.entityId, out lastY);
                                         OldY[_cInfo.entityId] = _y;
                                         if (lastY - _y >= 4)
                                         {
                                             if (Flag.ContainsKey(_cInfo.entityId))
                                             {
                                                 Flag.Remove(_cInfo.entityId);
                                             }
                                             continue;
                                         }
                                     }
                                     else
                                     {
                                         OldY.Add(_cInfo.entityId, _y);
                                     }
                                     int _flags;
                                     if (Flag.TryGetValue(_cInfo.entityId, out _flags))
                                     {
                                         if (_flags + 1 >= Flags)
                                         {
                                             Flag.Remove(_cInfo.entityId);
                                             ChatHook.ChatMessage(null, "[FF0000]" + "Cheater! Player " + _cInfo.playerName + " detected flying!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                             Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, flying @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, _x, _y, _z);
                                             string _file     = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy"));
                                             string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file);
                                             using (StreamWriter sw = new StreamWriter(_filepath, true))
                                             {
                                                 sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, flying @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, _x, _y, _z));
                                                 sw.WriteLine();
                                                 sw.Flush();
                                                 sw.Close();
                                             }
                                             Penalty(_cInfo);
                                             continue;
                                         }
                                         else
                                         {
                                             Flag[_cInfo.entityId] = _flags + 1;
                                         }
                                     }
                                     else
                                     {
                                         Flag.Add(_cInfo.entityId, 1);
                                     }
                                 }
                                 else if (Flag.ContainsKey(_cInfo.entityId))
                                 {
                                     Flag.Remove(_cInfo.entityId);
                                 }
                             }
                             else
                             {
                                 if (OldY.ContainsKey(_cInfo.entityId))
                                 {
                                     OldY.Remove(_cInfo.entityId);
                                 }
                                 if (Flag.ContainsKey(_cInfo.entityId))
                                 {
                                     Flag.Remove(_cInfo.entityId);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Flying.Exec: {0}.", e.Message));
     }
 }
Пример #5
0
        public static void BankToPlayerWithdraw(ClientInfo _cInfo, string _amount)
        {
            ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, false);

            if (CoinCheck(_cInfo, _itemValue))
            {
                int _value;
                if (int.TryParse(_amount, out _value))
                {
                    int _bank = GetCurrentBank(_cInfo.playerId);
                    if (_bank >= _value)
                    {
                        int _maxAllowed = _itemValue.ItemClass.Stacknumber.Value;
                        if (_value <= _maxAllowed)
                        {
                            EntityAlive _player   = GameManager.Instance.World.Players.dict[_cInfo.entityId] as EntityAlive;
                            ItemStack   itemStack = new ItemStack(_itemValue, _value);
                            if (_player.IsSpawned() && _player.bag.CanTakeItem(itemStack))
                            {
                                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                                {
                                    entityClass     = EntityClass.FromString("item"),
                                    id              = EntityFactory.nextEntityID++,
                                    itemStack       = itemStack,
                                    pos             = _player.position,
                                    rot             = new Vector3(20f, 0f, 20f),
                                    lifetime        = 60f,
                                    belongsPlayerId = _cInfo.entityId
                                });
                                GameManager.Instance.World.SpawnEntityInWorld(entityItem);
                                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId));
                                GameManager.Instance.World.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed);
                                SubtractCoinsFromBank(_cInfo.playerId, _value);
                                string _message = " you have received the {Name} in your bag.";
                                _message = _message.Replace("{Name}", Ingame_Coin);
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                using (StreamWriter sw = new StreamWriter(filepath, true))
                                {
                                    sw.WriteLine(string.Format("{0}: {1} has removed {2} from their bank account as {3}.", DateTime.Now, _cInfo.playerName, _value, Ingame_Coin));
                                    sw.WriteLine();
                                    sw.Flush();
                                    sw.Close();
                                }
                            }
                            else
                            {
                                var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData
                                {
                                    entityClass     = EntityClass.FromString("item"),
                                    id              = EntityFactory.nextEntityID++,
                                    itemStack       = itemStack,
                                    pos             = _player.position,
                                    rot             = new Vector3(20f, 0f, 20f),
                                    lifetime        = 60f,
                                    belongsPlayerId = _cInfo.entityId
                                });
                                GameManager.Instance.World.SpawnEntityInWorld(entityItem);
                                SubtractCoinsFromBank(_cInfo.playerId, _value);
                                string _message = " your bag could not take all of the {Name}. Dropped the stack on the ground by your feet.";
                                _message = _message.Replace("{Name}", Ingame_Coin);
                                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            }
                        }
                        else
                        {
                            string _message = " you can only withdraw a full stack at a time. The maximum stack size is {Max}.";
                            _message = _message.Replace("{Max}", _maxAllowed.ToString());
                            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                        }
                    }
                    else
                    {
                        string _message = " your bank account does not have enough to withdraw that value. Bank account is currently {Total}";
                        _message = _message.Replace("{Total}", _bank.ToString());
                        ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message, -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you input an invalid integer. Type " + ChatHook.Command_Private + Command96 + " #.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
        }