Example #1
0
        public static void ProcessInteractionMenu(Client client, string itemvalue)
        {
            if (!client.hasData("player"))
            {
                return;
            }
            Player       player       = client.getData("player");
            OwnedVehicle ownedVehicle = null;
            Player       otherPlayer  = null;

            switch (itemvalue)
            {
            case "togglecuffed":
                otherPlayer = CharacterService.CharacterService.GetNextPlayerInNearOfPlayer(player);
                if (otherPlayer != null)
                {
                    SetPlayerCuffed(otherPlayer.Character.Player, !otherPlayer.Character.IsCuffed);
                }
                CloseInteractionMenu(client);
                break;

            case "vehicleimpound":
                ownedVehicle = VehicleService.VehicleService.OwnedVehicleList.FirstOrDefault(x => x.ActiveHandle.position.DistanceTo(player.Character.Player.position) <= 4f);
                if (ownedVehicle != null)
                {
                    if (client.hasData("impoundtimer"))
                    {
                        CloseInteractionMenu(client); return;
                    }
                    client.setData("impoundtimercount", 0);
                    client.setData("impoundvehicle", ownedVehicle);
                    InterfaceService.ProgressBarService.ShowBar(client, 0, 30, "Impound " + ownedVehicle.ModelName);
                    client.setData("impoundtimer", API.shared.startTimer(1000, false, () => {
                        OwnedVehicle impoundveh = client.getData("impoundvehicle");
                        int count = client.getData("impoundtimercount");
                        if (count == 30)
                        {
                            ImpoundVehicle(client, impoundveh);
                            return;
                        }

                        if (client.position.DistanceTo(impoundveh.ActiveHandle.position) > 6f)
                        {
                            API.shared.sendNotificationToPlayer(client, "~r~Impound canceled!~n~~o~Too far away from target vehicle.");
                            StopImpoundTimer(client);
                            return;
                        }

                        count++;
                        InterfaceService.ProgressBarService.ChangeProgress(client, count);
                        client.setData("impoundtimercount", count);
                    }));

                    CloseInteractionMenu(client);
                }
                break;

            case "pulloutcuffedplayer":
                ownedVehicle = VehicleService.VehicleService.OwnedVehicleList.FirstOrDefault(x => x.ActiveHandle.position.DistanceTo(player.Character.Player.position) <= 4f);
                if (ownedVehicle != null)
                {
                    ownedVehicle.ActiveHandle.occupants.ToList().ForEach(occ => {
                        if (occ.hasData("player"))
                        {
                            Player occplr = occ.getData("player");
                            if (occplr.Character.IsCuffed)
                            {
                                API.shared.warpPlayerOutOfVehicle(occ);
                            }
                        }
                    });
                    CloseInteractionMenu(client);
                }
                break;
            }
        }
        private void AddVehicleInteractionMenu(Client client, Menu menu)
        {
            OwnedVehicle vehicle = ExistingVehicles.FirstOrDefault(x => x.Handle.Value == menu.ExtraInt);

            if (vehicle == null)
            {
                MenuController.CloseAllMenus(client);
                return;
            }
            if (client.isInVehicle)
            {
                if (client.vehicleSeat == -1 && client.HasPlayerVehicleKey(client.vehicle))
                {
                    if (client.vehicle.engineStatus)
                    {
                        menu.Items.Add(new MenuItem("Motor abschalten")
                        {
                            EventTrigger = "vehicle_toggle_engine", EventInt = menu.ExtraInt
                        });
                    }
                    else
                    {
                        menu.Items.Add(new MenuItem("Motor anschalten")
                        {
                            EventTrigger = "vehicle_toggle_engine", EventInt = menu.ExtraInt
                        });
                    }
                }
                if (client.seatbelt)
                {
                    menu.Items.Add(new MenuItem("Sicherheitsgurt ablegen")
                    {
                        EventTrigger = "vehicle_toggle_seatbelt", EventInt = menu.ExtraInt
                    });
                }
                else
                {
                    menu.Items.Add(new MenuItem("Sicherheitsgurt anlegen")
                    {
                        EventTrigger = "vehicle_toggle_seatbelt", EventInt = menu.ExtraInt
                    });
                }
            }
            if (client.HasPlayerVehicleKey(vehicle))
            {
                if (vehicle.Handle.locked)
                {
                    menu.Items.Add(new MenuItem("Fahrzeug aufschließen")
                    {
                        EventTrigger = "vehicle_toggle_locked", EventInt = menu.ExtraInt
                    });
                }
                else
                {
                    menu.Items.Add(new MenuItem("Fahrzeug abschließen")
                    {
                        EventTrigger = "vehicle_toggle_locked", EventInt = menu.ExtraInt
                    });
                }
            }
        }
Example #3
0
        public static List <MenuItem> BuildInteractionMenu(Player player)
        {
            List <MenuItem> menuItemList = new List <MenuItem>();

            // Person Options
            Player otherPlayer = CharacterService.CharacterService.GetNextPlayerInNearOfPlayer(player);

            if (otherPlayer != null)
            {
                if (otherPlayer.Character.IsCuffed)
                {
                    menuItemList.Add(new MenuItem
                    {
                        Title  = "~b~Put off handcuffs",
                        Value1 = "togglecuffed"
                    });
                }
                else
                {
                    if (otherPlayer.Character.HasHandsup)
                    {
                        menuItemList.Add(new MenuItem
                        {
                            Title  = "~b~Put on handcuffs",
                            Value1 = "togglecuffed"
                        });
                    }
                }
            }


            // Vehicle Options
            if (!player.Character.Player.isInVehicle)
            {
                OwnedVehicle ownedVehicle = VehicleService.VehicleService.OwnedVehicleList.FirstOrDefault(x => x.ActiveHandle.position.DistanceTo(player.Character.Player.position) <= 4f);
                if (ownedVehicle != null)
                {
                    if (!player.Character.Player.hasData("impoundtimer"))
                    {
                        menuItemList.Add(new MenuItem
                        {
                            Title  = "~b~Vehicle Impound",
                            Value1 = "vehicleimpound"
                        });
                    }

                    bool CuffedPlayerInVehicle = false;
                    ownedVehicle.ActiveHandle.occupants.ToList().ForEach(occ => {
                        if (occ.hasData("player"))
                        {
                            Player occplr = occ.getData("player");
                            if (occplr.Character.IsCuffed)
                            {
                                CuffedPlayerInVehicle = true;
                            }
                        }
                    });
                    if (CuffedPlayerInVehicle)
                    {
                        menuItemList.Add(new MenuItem
                        {
                            Title  = "~b~Pull outu cuffed player",
                            Value1 = "pulloutcuffedplayer"
                        });
                    }
                }
            }
            return(menuItemList);
        }