/// <summary> /// Проинициализировать гараж /// </summary> private void InitializeGarage(HouseInfo house) { if (string.IsNullOrEmpty(house.GaragePosition)) { // не у всех домов может быть гараж? return; } // вход в гараж var enterPos = PositionConverter.ToVector3(house.GaragePosition); var enter = _pointCreator.CreateMarker(Marker.Stripes, enterPos, Colors.Yellow, 2f); API.setEntityRotation(enter.Marker, PositionConverter.ToVector3(house.RotationAfterExit)); enter.ColShape.onEntityEnterColShape += (shape, entity) => { _houseEventManager.OnPlayerWentToGarageEnter(entity, house.Id); }; enter.ColShape.onEntityExitColShape += (shape, entity) => _houseEventManager.OnPlayerAway(entity); // выход var exits = HousesPositionsGetter.GetGarageInnerPositions(house.Type).GarageExits; foreach (var exit in exits) { var garageExit = API.createSphereColShape(exit, 2f); garageExit.dimension = (int)-house.Id; garageExit.onEntityEnterColShape += (shape, entity) => { _houseEventManager.OnPlayerExitGarage(entity, house.Id); }; garageExit.onEntityExitColShape += (shape, entity) => _houseEventManager.OnPlayerAway(entity); } }
/// <summary> /// Обработать данные владельца дома /// </summary> private void ProcessOwner(HouseInfo house) { var player = _playerInfoManager.GetWithData(house.OwnerId); if (PlayerHelper.PlayerCorrect(player.Player)) { var houseId = PlayerHelper.GetData(player.Player, HouseMenuHandler.IN_HOUSE, NO_OWNER); if (houseId == house.Id) { player.Player.resetData(HouseMenuHandler.IN_HOUSE); API.setEntityPosition(player.Player, PositionConverter.ToVector3(house.Position)); API.setEntityDimension(player.Player, 0); } MoveVehiclesOnParking(player.PlayerInfo.Vehicles.Values, player.Player); _playerInfoManager.RefreshUI(player.Player, player.PlayerInfo); API.sendNotificationToPlayer(player.Player, "~b~Аренда дома подошла к концу"); } else { MoveVehiclesOnParking(player.PlayerInfo.Vehicles.Values); player.PlayerInfo.LastPosition = house.Position; player.PlayerInfo.Dimension = 0; _playerInfoManager.Set(player.PlayerInfo); } }
/// <summary> /// Поместить игрока на позицию до выхода /// </summary> private void SetPosition(Client player, PlayerInfo info) { var lastPosition = !string.IsNullOrEmpty(info.LastPosition) ? PositionConverter.ToVector3(info.LastPosition) : null; if (info.Wanted.JailTime > 0) { _jailManager.SetInJail(player, lastPosition); } else { API.setEntityPosition(player, lastPosition ?? MainPosition.StartSpawn); } API.setEntityDimension(player, info.Dimension); }
/// <summary> /// Выйти из дома /// </summary> private void ExitHouse(Client player, object[] args) { var house = GetHouse(args[0]); if (IsLocked(player, house)) { return; } var position = PositionConverter.ToVector3(house.Position); SetPlayerPosition(player, position, 0); player.resetData(IN_HOUSE); API.sendNativeToPlayer(player, Hash.DISPLAY_RADAR, true); API.triggerClientEvent(player, ServerEvent.HIDE_HOUSE_MENU); }
/// <summary> /// Запускает войну за район /// </summary> public void StartWar() { ClientEventHandler.Add(ClientEvent.CAPTURE_DISTRICT, CaptureStreet); _district = _districtsProvider.GetNext(); _clanManager.RemoveDistrict(_district.Id); var position = PositionConverter.ToVector3(_district.Position); _blip = _pointCreator.CreateBlip(position, 439, 4, scale: 2f, name: "Война за район"); _capturePoint = _pointCreator.CreateMarker(Marker.VerticalCylinder, position, Colors.White, 3.7f, "Точка захвата района"); _capturePoint.ColShape.onEntityEnterColShape += PlayerComeToCapturePoint; _capturePoint.ColShape.onEntityExitColShape += PlayerAwayFromCapturePoint; API.setMarkerScale(_capturePoint.Marker, new Vector3(4, 4, 4)); API.setEntityPosition(_capturePoint.Label, _capturePoint.Label.position.Add(new Vector3(0, 0, 2))); API.sendChatMessageToAll($"~b~[Банды] Началось сражение за район \"{_district.Name}\"!"); }
/// <summary> /// Выйти из гаража /// </summary> private void ExitGarage(Client player, object[] args) { var house = GetHouse(args[0]); if (player.isInVehicle) { UnparkVehicle(player, house); } var garageExit = PositionConverter.ToVector3(house.GaragePosition); var rotationAfterExit = PositionConverter.ToVector3(house.RotationAfterExit); SetGaragePosition(player, garageExit, rotationAfterExit, 0); RemoveVehicles(player, house); API.sendNativeToPlayer(player, Hash.DISPLAY_RADAR, true); API.triggerClientEvent(player, ServerEvent.HIDE_HOUSE_MENU); }
/// <summary> /// Загрузить дома /// </summary> public void Initialize() { API.requestIpl("apa_v_mp_h_04_a"); API.requestIpl("TrevorsTrailerTidy"); ServerState.Houses = _housesProvider.GetHouses().ToDictionary(e => e.Id); foreach (var house in ServerState.Houses.Values) { var position = PositionConverter.ToVector3(house.Position); CreateBlips(house, position); var enter = _pointCreator.CreateMarker(Marker.UpsideDownCone, position, Colors.Yellow, SHAPE_RANGE); enter.ColShape.onEntityEnterColShape += (shape, entity) => _houseEventManager.OnPlayerWentToEnter(entity, house.Id); enter.ColShape.onEntityExitColShape += (shape, entity) => _houseEventManager.OnPlayerAway(entity); InitializeHouseInside(house); InitializeGarage(house); } _storageManager.Initialize(); ActionHelper.StartTimer(PLAYER_HEAL_TIMEOUT, HealPlayersInHouses); ActionHelper.StartTimer(RENT_CHECK_TIMEOUT, SyncroizeRent); }
private void TriggerActionMenu(Client player, object[] args) { var isOpen = (bool)args[0]; if (isOpen) { var accountId = (long)player.getData(PlayerInfoManager.ID_KEY); var housesPositions = _houseManager.GetPlayerHouses(accountId).Select(e => PositionConverter.ToVector3(e.Position)); API.triggerClientEvent(player, ServerEvent.SHOW_PLAYER_ACTION_MENU, JsonConvert.SerializeObject(housesPositions)); } else { API.triggerClientEvent(player, ServerEvent.HIDE_PLAYER_ACTION_MENU); } }