using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Classes; using ReallifeGamemode.Server.DrivingSchool; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Finance; using ReallifeGamemode.Server.Inventory; using ReallifeGamemode.Server.Inventory.Interfaces; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.WeaponDeal; /** * @overview Life of German Reallife - Event Key (Key.cs) * @author VegaZ * @copyright (c) 2008 - 2018 Life of German */ namespace ReallifeGamemode.Server.Events { public class Key : Script { #region User Key [RemoteEvent("keyPress:NUM2")] public void KeyPressNUM2(Player player) { if (!player.IsLoggedIn()) return; if (player.GetData("editmode") == true && player.GetUser().IsAdmin(AdminLevel.HEADADMIN) == true) { var saveMode = player.GetData("quicksavemode"); switch (saveMode) { case "none": ChatService.SendMessage(player, "~r~Keinen Modus ausgewählt! ~y~/quicksavemode ~r~für mehr Infos!"); break; case "blip": TempBlip tempBlip = NAPI.Data.GetWorldData("blipTemplate"); SaveManager.OnSaveBlipData(player, tempBlip.Sprite.ToString(), tempBlip.Name, tempBlip.Scale.ToString(), tempBlip.Color.ToString(), tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString()); player.SendNotification("~y~Blip~s~ erstellt!", false); break; case "atm": SaveManager.OnSaveBlipData(player, "500", "Geldautomat", 0.7.ToString(), "11", "0", "200", true.ToString(), 0.ToString(), 0.ToString()); player.SendNotification("~y~ATM~s~ erstellt!", false); break; } } GroundItem.PickUpGroundItem(player); } /* [RemoteEvent("keyPress:LEFT_ARROW")] public void KeyPressLeftArrow(Player player) { if (!player.IsLoggedIn()) return; List nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player); if (nearbyPlayers.Count > 1) { List nearbyPlayerList = new List(); foreach (Player nearPlayer in nearbyPlayers) { if (nearPlayer.Name != player.Name) { nearbyPlayerList.Add(nearPlayer.Name); } else { continue; } } player.TriggerEvent("showPlayerInteraction", JsonConvert.SerializeObject(nearbyPlayerList)); } } */ [RemoteEvent("keyPress:RIGHT_ARROW")] public void KeyPressRightArrow(Player player) { if (!player.IsLoggedIn()) return; User user = player.GetUser(); if (!player.IsDuty()) { return; } switch (user.FactionId) { //LSPD case 1: case 3: player.TriggerEvent("showFactionInteractionLSPD", user.FactionId, user.GetData("duty"), user.Faction.Name, user.FactionLeader); break; //Medic case 2: player.TriggerEvent("showFactionInteractionMedic", user.FactionId, user.GetData("duty"), user.Faction.Name, user.FactionLeader, Medic.ReviveTasks.Count.ToString(), Medic.HealTasks.Count.ToString(), Medic.FireTasks.Count.ToString()); break; } } [RemoteEvent("keyPress:M")] public void KeyPressM(Player player) { using var dbContext = new DatabaseContext(); User u = player.GetUser(dbContext); if (u == null) return; var vehicles = dbContext.UserVehicles.Where(veh => veh.UserId == u.Id).OrderBy(veh => veh.Id).Select(v => new { v.Id, v.Model, Price = (v.Price ?? 0) * 0.6 }); var factionVehicles = dbContext.FactionVehicles.ToList().Where(f => f.GetOwners().Contains(u.FactionId ?? -1)).Select(f => new { f.Id, f.Model, Price = f.BuyPrice }); Paycheck paycheck = null; if (Economy.Paychecks.ContainsKey(u.Id)) paycheck = Economy.Paychecks[u.Id]; Licenses licenses = new Licenses(u.DriverLicenseVehicle, u.DriverLicenseBike, u.FlyingLicensePlane, u.WeaponLicense); var accountData = new { regDate = u.RegistrationDate.ToShortDateString(), adminLevel = u.AdminLevel.GetName(), points = u.Points, faction = u.Faction?.Name ?? "Zivilist", factionleader = u.Faction?.Name ?? "Zivilist", //factionleader = u.FactionLeader, stateFaction = u.Faction?.StateOwned, factionRank = u.GetFactionRank().RankName, group = u.Group?.Name ?? "Keine", groupRank = u.GroupRank.GetName(), job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner", paycheck, licenses, vehicles, factionVehicles, nextPayday = u.PaydayTimer, playTime = u.PlayedMinutes / 60, userWarn = u.warn, }; string faction = u.Faction?.Name ?? "Zivilist"; string factionleader = u.FactionLeader ? u.Faction.Name : null; string group = u.Group != null ? u.Group.Name : null; bool factionInvite = player.HasData("accept_faction_invite"); bool groupInvite = player.HasData("accept_group_invite"); bool ticket_boolean = player.HasData("ticket_boolean"); int ticket_amount = 0; int pay_amount = 0; bool house = false; if(u.House != null) { house = true; } if (player.HasData("ticket_amount")) { ticket_amount = player.GetData("ticket_amount"); } if (player.HasData("pay_amount")) { pay_amount = player.GetData("pay_amount"); } player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount, house); } [RemoteEvent("keyPress:E")] public void KeyPressE(Player player) { if (!player.IsLoggedIn()) return; var user = player.GetUser(); if (player.HasData("nearATM")) { ATMManager.ShowAtmUi(player, player.GetData("nearATM")); return; } if(!player.IsInVehicle) { if(GroundItem.PickUpGroundItem(player)) { return; } } DutyPoint nearestDuty = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId); WeaponPoint nearestWeapon = PositionManager.WeaponPoints.Find(w => w.Position.DistanceTo(player.Position) <= 1.5 && w.FactionId == user.FactionId); JailReleasePoint nearestJailReleasePoint = PositionManager.JailReleasePoints.Find(j => j.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3) && user.GetData("duty")); ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 2 || user.FactionId == 3)); ClotheshopPoint nearestClotheShopPoint = PositionManager.clotheshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); FriseurPoint nearestFriseurPoint = PositionManager.friseurPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6); if (user?.FactionId != null) { BehindVehiclePoint nearestBehindVehiclePoint = MarkerBehinVehicle.behindVehiclePoints.Find(s => s.marker.Position.DistanceTo(player.Position) <= 3 && (user.FactionId == 8 || user.FactionId == 7 || user.FactionId == 1 || user.FactionId == 3)); if (nearestBehindVehiclePoint != null) { if (player.HasAttachment("ammobox")) return; using (var dbContext = new DatabaseContext()) { List vehicleItems = dbContext.VehicleItems.ToList().Where(f => f.GetVehicle().GetVehicle() == nearestBehindVehiclePoint.vehicle && InventoryManager.GetItemById(f.ItemId) is IWeaponDealItem).ToList(); if (vehicleItems.Count == 0) { GTANetworkAPI.Vehicle vehicle = nearestBehindVehiclePoint.vehicle; if (vehicle.HasAttachment("weapondeal")) { vehicle.AddAttachment("weapondeal", true); vehicle.AddAttachment("weapondeal1", true); vehicle.AddAttachment("weapondeal2", true); } if (WeaponDealManager.checkWeaponDbyVehicle(vehicle)) { vehicle.ResetData("WeaponDealLoad"); vehicle.ResetData("weaponDeal"); vehicle.ResetData("dealPoint"); } nearestBehindVehiclePoint.vehicle.RemoveMarkerBehind(); return; } foreach (var v in vehicleItems) { int itemToAdd = 0; for (int i = 1; i <= v.Amount; i++) { if (InventoryManager.GetUserInventoryWeight(player) + (i * InventoryManager.GetItemById(v.ItemId).Gewicht) > 40000) { break; } else { itemToAdd = i; } } if (itemToAdd == 0) break; v.Amount -= itemToAdd; if (v.Amount <= 0) { itemToAdd += v.Amount; dbContext.VehicleItems.Remove(v); } InventoryManager.AddItemToInventory(player, v.ItemId, itemToAdd); nearestBehindVehiclePoint.usePoint(player); dbContext.SaveChanges(); return; } } } if (nearestDuty != null)// Duty Point { var factionId = user.FactionId; if (user.GetData("duty") == false) { user.SetData("duty", true); player.SendNotification("Du bist nun ~g~im Dienst."); player.TriggerEvent("toggleDutyMode", true); if (player.GetUser().FactionId == 2) //Fire Department { Medic.UpdateDutyMedics(1); } switch (factionId) { //LSPD case 1: //nameTagColor = new Color(28, 134, 238); //player.TriggerEvent("setNameTag", JsonConvert.SerializeObject(new int[] { 28, 134, 238 })); player.SetSharedData("nameTagColor", factionId); player.SetSharedData("blipColor", 38); break; //Medic case 2: //nameTagColor = new Color(255, 0, 0); //player.TriggerEvent("setNameTag", JsonConvert.SerializeObject(new int[] { 255, 0, 0 })); player.SetSharedData("nameTagColor", factionId); player.SetSharedData("blipColor", 6); break; //FBI case 3: //nameTagColor = new Color(173, 0, 118); player.SetSharedData("nameTagColor", factionId); player.SetSharedData("blipColor", 63); player.SetAccessories(2, 2, 0); break; } using (var context = new DatabaseContext()) { List clothes = context.CharacterClothes.Where(u => u.UserId == user.Id && u.Duty == true).ToList(); foreach (var cloth in clothes) { if (cloth.SlotType == 0) { player.SetClothes(cloth.SlotId, cloth.ClothId, 0); } else { if (cloth.ClothId != -1) { player.SetAccessories(cloth.SlotId, cloth.ClothId, 0); } else { player.ClearAccessory(cloth.SlotId); } } } } } else { user.SetData("duty", false); player.SendNotification("Du bist nun ~r~außer Dienst."); player.TriggerEvent("toggleDutyMode", false); Medic.UpdateDutyMedics(-1); player.SetSharedData("blipColor", 0); player.SetSharedData("nameTagColor", 0); UpdateCharacterCloth.LoadCharacterDefaults(player); } } if (nearestWeapon != null) // Weapon Point { List primarys = new List(); List secondarys = new List(); List melees = new List(); List specials = new List(); List armor = new List(); List timer = new List(); int pistol_Amount = 0; int pistol50_Amount = 0; int Pistol_mk2_Amount = 0; int Combatpistol_Amount = 0; int SMG_Amount = 0; int Carbinerifle_Amount = 0; int Compactrifle_Amount = 0; int sniperrifle_Amount = 0; int Pumpshotgun_Amount = 0; int Schutzweste_Amount = 0; int Stungun_Amount = 0; string dealTime = "Starten"; primarys.Add("Keine"); secondarys.Add("Keine"); melees.Add("Keine"); specials.Add("Keine"); armor.Add("Keine"); using (var context = new DatabaseContext()) { if (player.HasAttachment("ammobox")) { player.AddAttachment("ammobox", true); player.StopAnimation(); } bool unloadedWeaponPackage = false; List fItem = context.UserItems.Where(u => u.UserId == user.Id).ToList(); foreach (var item in fItem) { IItem iItem = InventoryManager.GetItemById(item.ItemId); if (iItem is IWeaponDealItem obj) { FactionWeapon weapon = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == iItem.Name).FirstOrDefault(); if (weapon == null) { context.Remove(item); continue; } weapon.Ammount += item.Amount; ChatService.SendMessage(player, item.Amount + " " + iItem.Name + " wurden im Waffenlager hinzugefügt."); unloadedWeaponPackage = true; context.Remove(item); } } context.SaveChanges(); if (unloadedWeaponPackage) { return; } List weapons = context.FactionWeapons.Where(w => w.FactionId == user.FactionId).ToList(); Database.Entities.Faction faction = context.Factions.Where(fac => fac.Id == user.FactionId).FirstOrDefault(); if (faction.WeaponDealTime > 0) dealTime = "noch " + faction.WeaponDealTime.ToString() + " min. übrig"; timer.Add(dealTime); foreach (var weapon in weapons) { if (weapon.Ammount <= 0) continue; switch (weapon.SlotID) { case 1: if (user.FactionRank.Order >= weapon.Rank) primarys.Add(weapon.WeaponModel.ToString()); break; case 2: if (user.FactionRank.Order >= weapon.Rank) secondarys.Add(weapon.WeaponModel.ToString()); break; case 3: if (user.FactionRank.Order >= weapon.Rank) melees.Add(weapon.WeaponModel.ToString()); break; case 4: if (user.FactionRank.Order >= weapon.Rank) specials.Add(weapon.WeaponModel.ToString()); break; case 5: if (user.FactionRank.Order >= weapon.Rank) armor.Add(weapon.WeaponModel.ToString()); break; } } foreach (var weapon in weapons) { if (weapon.WeaponModel == "Pistol") { pistol_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "Pistol50") { pistol50_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "Pistol_MK2") { Pistol_mk2_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "Combatpistol") { Combatpistol_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "SMG") { SMG_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "CarbineRifle") { Carbinerifle_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "CompactRifle") { Compactrifle_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "sniperrifle") { sniperrifle_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "PumpShotgun") { Pumpshotgun_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "Schutzweste") { Schutzweste_Amount = weapon.Ammount; } else if (weapon.WeaponModel == "Stungun") { Stungun_Amount = weapon.Ammount; } } } player.TriggerEvent("showWeaponMenu", primarys.ToArray(), secondarys.ToArray(), melees.ToArray(), specials.ToArray(), armor.ToArray(), JsonConvert.SerializeObject(timer.ToArray()), pistol_Amount.ToString(), pistol50_Amount.ToString(), Pistol_mk2_Amount.ToString(), Combatpistol_Amount.ToString(), SMG_Amount.ToString(), Carbinerifle_Amount.ToString(), Compactrifle_Amount.ToString(), sniperrifle_Amount.ToString(), Pumpshotgun_Amount.ToString(), Schutzweste_Amount.ToString(), Stungun_Amount.ToString()); ; } if (nearestJailReleasePoint != null) { List criminals = new List(); criminals.Add("Keiner"); foreach (Player target in NAPI.Pools.GetAllPlayers()) { User c = target.GetUser(); if (c.JailTime > 0) { criminals.Add(c.Name); } } player.TriggerEvent("showJailMenu", JsonConvert.SerializeObject(criminals.ToArray())); } } if (nearestElevatorPoint != null) { List stages = new List(); foreach (var e in PositionManager.ElevatorPoints) { if (e.Position.DistanceTo2D(player.Position) <= 25 && e.Position.DistanceTo(player.Position) > 1.5) { stages.Add(e.Stage); } } player.TriggerEvent("showElevatorMenu", JsonConvert.SerializeObject(stages.ToArray())); } if (nearestClotheShopPoint != null) { nearestClotheShopPoint.clotheShop.LoadShopNUI(player); } if (nearestItemShopPoint != null) { nearestItemShopPoint.itemShop.LoadShopNUI(player); } if (nearestFriseurPoint != null) { nearestFriseurPoint.friseurShop.LoadShopNUI(player); } if (user.FactionLeader) { player.TriggerEvent("CLIENT:StartGangwar"); } if (nearestJobPoint != null) { if (player.Vehicle != null) return; Job.JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1); JobManager jobb = new JobManager(); if (nearestJobPoint.jobId != 3 && nearestJobPoint.jobId == player.GetUser().JobId) { if (job.GetUsersInJob().Contains(player)) { jobb.StopJob(player); return; } if (!job.GetUsersInJob().Contains(player)) { jobb.StartJobEvent(player); player.TriggerEvent("renderTextOnScreen", "Steige nun in eines der Fahrzeuge und starte den Motor mit der Taste 'N'."); return; } } else if (nearestJobPoint.jobId == 3 && player.GetUser().JobId == 3) { if (nearestJobPoint.Skill < 300 && player.GetUser().PilotSkill >= 0) { if (job.GetUsersInJob().Contains(player)) { player.SetData("PilotenBase", 1); jobb.StopJob(player); return; } if (!job.GetUsersInJob().Contains(player)) { player.SetData("PilotenBase", 1); jobb.StartJobEvent(player); player.TriggerEvent("renderTextOnScreen", "Steige nun in eines der Flugzeuge und starte den Motor mit der Taste 'N'."); return; } } if (nearestJobPoint.Skill >= 300 && player.GetUser().PilotSkill >= 300) { if (job.GetUsersInJob().Contains(player)) { player.SetData("PilotenBase", 2); jobb.StopJob(player); return; } if (!job.GetUsersInJob().Contains(player)) { player.SetData("PilotenBase", 2); jobb.StartJobEvent(player); player.TriggerEvent("renderTextOnScreen", "Steige nun in eines der Flugzeuge und starte den Motor mit der Taste 'N'."); return; } } { player.SendChatMessage("~y~[JOB] ~r~Dein Skilllevel ist noch zu niedrig."); return; } } else { player.SendNotification("~r~[Fehler] ~w~ Du hast diesen Job nicht angenommen."); return; } } } [RemoteEvent("keyPress:I")] public void KeyPressI(Player player) { if (!player.IsLoggedIn()) return; player.TriggerEvent("inventoryShow"); InventoryManager.SetBackpackItems(player); } [RemoteEvent("keyPress:O")] public void KeyPressO(Player player) { if (!player.IsLoggedIn()) return; List players = NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn() == true).OrderBy(o => o.Handle.Value).ToList(); var listPlayers = players.Select(p => new { Id = p.Handle.Value, p.Name, p.Ping, FactionName = p.GetUser()?.Faction?.Name ?? "Zivilist", }); player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers)); } [RemoteEvent("keyPress:K")] public void KeyPressK(Player player) { if (!player.IsLoggedIn()) return; var user = player.GetUser(); if (user == null) { return; } if (user?.FactionId != null) { DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5); if (nearest == null) return; if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId) { List hats = new List(); List tops = new List(); List legs = new List(); List shoes = new List(); using (var context = new DatabaseContext()) { var gender = user.GetCharacter().Gender; List clothes = context.DutyClothes.Where(c => c.FactionId == user.FactionId && c.Gender == gender).ToList(); foreach (var cloth in clothes) { if (cloth.SlotType == 1) { if (cloth.ClothId != -1) { hats.Add(cloth.ClothId.ToString()); } else { hats.Add("Keinen"); } continue; } switch (cloth.SlotId) { case 11: tops.Add(cloth.ClothId.ToString()); break; case 4: legs.Add(cloth.ClothId.ToString()); break; case 6: shoes.Add(cloth.ClothId.ToString()); break; } } } player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray()); } } } [RemoteEvent("keyPress:L")] public void KeyPressL(Player player) { if (!player.IsLoggedIn()) return; DoorManager.ChangeDoorState(player); } [RemoteEvent("keyPress:N")] public void KeyPressN(Player player) { if (!player.IsLoggedIn()) return; if (!player.IsInVehicle) return; if (player.VehicleSeat != 0) return; GTANetworkAPI.Vehicle v = player.Vehicle; User u = player.GetUser(); if (u == null) return; if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16) { player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true); return; } bool state = VehicleStreaming.GetEngineState(v); ServerVehicle sV = v.GetServerVehicle(); if (sV != null) { if (sV is ShopVehicle) { VehicleStreaming.SetEngineState(v, false); return; } else if (sV is FactionVehicle fV) { if(fV.Model == VehicleHash.Burrito3 && u.FactionId == 1 || fV.Model == VehicleHash.Burrito3 && u.FactionId == 3 || fV.Model == VehicleHash.Burrito3 && u.FactionId == 7 || fV.Model == VehicleHash.Burrito3 && u.FactionId == 8 || fV.Model == VehicleHash.Policet && u.FactionId == 1 || fV.Model == VehicleHash.Policet && u.FactionId == 3 || fV.Model == VehicleHash.Policet && u.FactionId == 7 || fV.Model == VehicleHash.Policet && u.FactionId == 8) { VehicleStreaming.SetEngineState(v, !state); } else if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && player.IsAdminDuty())) { player.SendNotification("~r~Du hast keinen Schlüssel."); return; } } else if (sV is GroupVehicle gV) { if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3) && player.IsAdminDuty()) { player.SendNotification("~r~Du hast keinen Schlüssel."); return; } } else if (sV is JobVehicle jV) { if (jV.JobId != player.GetUser().JobId && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && player.IsAdminDuty())) { player.SendNotification("~r~Du hast keinen Schlüssel."); return; } else { if (!jV.GetJob().GetUsersInJob().Contains(player) && !player.IsAdminDuty()) { player.SendNotification("~y~[JOB] ~w~Du musst den Job vorher starten!"); return; } else { /*if(player.IsAdminDuty()) { player.SendChatMessage(""); }*/ if (jV.JobId == 3 && player.GetUser().JobId == 3 && jV.GetJob().GetUsersInJob().Contains(player)) { Job.PilotJob c = new Job.PilotJob(); if ((VehicleHash)jV.Model == VehicleHash.Cuban800 && !state) { if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) { player.SetData("HatRoute", true); c.StartPilotRoute(player, "RouteStart"); } } if ((VehicleHash)jV.Model == VehicleHash.Velum && !state || (VehicleHash)jV.Model == VehicleHash.Velum2 && !state) { if (player.GetUser().PilotSkill >= 300) { if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) { player.SetData("HatRoute", true); c.StartPilotRoute(player, "RouteStart"); } } else { player.SendNotification("~y~[JOB] ~r~Du besitzt nicht das nötige Skilllevel(2) "); return; } } } if (jV.JobId == 4 && player.GetUser().JobId == 4 && jV.GetJob().GetUsersInJob().Contains(player)) { Job.BusDriverJob c = new Job.BusDriverJob(); if ((VehicleHash)jV.Model == VehicleHash.Bus && !state) { if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) { player.SetData("HatRoute", true); c.StartBusRoute(player, "RouteStart"); player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 45); } } if ((VehicleHash)jV.Model == VehicleHash.Coach && !state) { if (player.GetUser().BusSkill >= 300) { if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) { player.SetData("HatRoute", true); c.StartBusRoute(player, "RouteStart"); player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 45); } } else { player.SendNotification("~y~[JOB] ~r~Du besitzt nicht das nötige Skilllevel(2) "); return; } } if ((VehicleHash)jV.Model == VehicleHash.Tourbus && !state) { if (player.GetUser().BusSkill >= 800) { if (!player.HasData("HatRoute") || player.GetData("HatRoute") == false) { player.SetData("HatRoute", true); c.StartBusRoute(player, "RouteStart"); player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 45); } } else { player.SendNotification("~y~[JOB] ~r~Du besitzt nicht das nötige Skilllevel(3) "); return; } } } } } } else if (sV is UserVehicle uV) { if (u.IsAdmin(AdminLevel.HEADADMIN) && player.IsAdminDuty()) { } else if (uV.UserId != u.Id && !u.IsAdmin(AdminLevel.HEADADMIN)) { player.SendNotification("~r~Du hast keinen Schlüssel."); return; } } } VehicleStreaming.SetEngineState(v, !state); } [RemoteEvent("keyPress:X")] public void KeyPressX(Player player) { if (!player.IsLoggedIn()) return; if (!player.IsInVehicle) { Vehicle.VehicleMenuLockCarEvent(player); } if (player.IsInVehicle && player.VehicleSeat == 0) { ServerVehicle veh = player.Vehicle.GetServerVehicle(); if (veh != null) { User u = player.GetUser(); if (veh is FactionVehicle fV && !fV.GetOwners().Contains(u.FactionId ?? 0) && (!u.IsAdmin(AdminLevel.ADMIN3))) { return; } else if (veh is ShopVehicle) { return; } } player.TriggerEvent("ToggleVehicleMenu"); } } #endregion #region Faction Key #endregion } }