private async Task OnTick() { var player = Cache.Player; if (player?.Entity != null) { var entity = Cache.Entity; if (API.IsPedSittingInAnyVehicle(entity.Id) && Game.IsControlJustPressed(0, Control.InteractionMenu) && !Game.IsControlPressed(0, Control.Sprint)) { OpenVehicleMenu(); } if (API.IsPedInAnyVehicle(entity.Id, false)) { var decors = new EntityDecorModule { Id = API.GetVehiclePedIsIn(entity.Id, false) }; if (!SeatShuffle) { if (API.GetPedInVehicleSeat(API.GetVehiclePedIsIn(entity.Id, false), 0) == entity.Id) { if (API.GetIsTaskActive(entity.Id, 165)) { API.SetPedIntoVehicle(entity.Id, API.GetVehiclePedIsIn(entity.Id, false), 0); } } } var vehicleOff = decors.GetBoolean("Vehicle.Engine.Off"); if (vehicleOff) { API.SetVehicleEngineOn(decors.Id, false, true, false); } } } await Task.FromResult(0); }
private void OpenVehicleMenu() { new Menu("Fordonsmeny") { Items = new List <MenuItem> { new MenuItem("engine_toggle", "Sätt på/av motor"), new MenuItem("swap_seats", "Ändra säte"), new MenuItem("doors", "Dörrar"), new MenuItem("windows", "Veva upp/ner rutor") }, Callback = async(menu, item, operation) => { var entity = Cache.Entity; if (operation.Type != MenuOperationType.Select) { return; } if (!API.IsPedSittingInAnyVehicle(entity.Id)) { return; } var vehicleId = API.GetVehiclePedIsIn(entity.Id, false); var decors = new EntityDecorModule { Id = vehicleId }; if (item.Seed == "windows") { var windowIndex = 0; for (var i = 0; i < 3; i++) { if (API.GetPedInVehicleSeat(vehicleId, i) != entity.Id) { continue; } windowIndex = i; break; } var rolledDown = decors.GetBoolean("Vehicle.Windows.RolledDown"); if (!rolledDown) { API.RollDownWindow(vehicleId, windowIndex); } else { API.RollUpWindow(vehicleId, windowIndex); } decors.Set("Vehicle.Windows.RolledDown", !rolledDown); } else if (item.Seed == "swap_seats") { SeatShuffle = true; await BaseScript.Delay(5000); SeatShuffle = false; } else if (item.Seed == "engine_toggle") { var toggle = !API.IsVehicleEngineOn(vehicleId); API.SetVehicleEngineOn(vehicleId, toggle, false, false); decors.Set("Vehicle.Engine.Off", !toggle); } else if (item.Seed == "doors") { menu.Hide(); OpenDoorMenu(vehicleId); } } }.Commit(); }
private void OpenInteractionMenu() { new Menu($"{Label} | Interaktionsmeny") { Items = new List <MenuItem> { new MenuItem("handcuff", "Sätt på handbojor"), new MenuItem("remove_handcuffs", "Ta bort handbojor"), new MenuItem("drag", "Dra närmsta person"), new MenuItem("bill", "Skriv en böter") }, Callback = (menu, item, operation) => { if (operation.Type != MenuOperationType.Select) { return; } if (item.Seed == "handcuff") { var player = GetClosestPlayer(1.5f, self => { var decors = new EntityDecorModule { Id = API.GetPlayerPed(self) }; return(!decors.GetBoolean("Player.IsHandcuffed")); }); if (player != -1) { var user = new AtlasUser { Handle = API.GetPlayerServerId(player) }; user.Send("handcuff:toggle", true); } else { Cache.Player.ShowNotification("Det finns ingen i närheten som du kan handboja!"); } } else if (item.Seed == "remove_handcuffs") { var player = GetClosestPlayer(1.5f, self => { var decors = new EntityDecorModule { Id = API.GetPlayerPed(self) }; return(decors.GetBoolean("Player.IsHandcuffed")); }); if (player != -1) { var user = new AtlasUser { Handle = API.GetPlayerServerId(player) }; user.Send("handcuff:toggle", false); } else { Cache.Player.ShowNotification("Det finns ingen i närheten som har handbojor på sig!"); } } else if (item.Seed == "drag") { var player = GetClosestPlayer(2f, self => { var decors = new EntityDecorModule { Id = API.GetPlayerPed(self) }; return(decors.GetBoolean("Player.IsHandcuffed")); }); if (player != -1) { var user = new AtlasUser { Handle = API.GetPlayerServerId(player) }; user.Send("handcuff:drag:toggle", API.GetPlayerServerId(API.PlayerId())); } else { Cache.Player.ShowNotification("Det finns ingen i närheten som har handbojor på sig!"); } } else if (item.Seed == "bill") { var character = Cache.Character; BillingManager.GetModule().CreateBill(new BillSender { Business = Label, Individual = character.Fullname }, new BillReceiver { Type = BillReceiverType.Individual, Name = "" }); } } }.Commit(); }