Example #1
0
        // When you press a key down or hold it.
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Z && !_menuPool.IsAnyMenuOpen())
            {                                                     // our menu on/off switch
                _menuPool = new MenuPool();                       // MenuPool
                var mainMenu = new UIMenu("~g~Buy", "~b~anubit"); // Main menu name, you can customize name, label and colors by editing "~<letter>~"
                _menuPool.Add(mainMenu);                          // Adds the main menu

                Menu1(mainMenu);
                Menu2(mainMenu);
                Menu3(mainMenu);
                _menuPool.RefreshIndex();             // Refreshes the Index

                mainMenu.Visible = !mainMenu.Visible; // Makes the main menu visibiel upon having the hotkey above pressed
            }
            if (e.KeyCode == Keys.NumPad9)
            {
                Function.Call(Hash.SET_PED_ALTERNATE_WALK_ANIM, playerPed, "amb@world_human_power_walker@female@base", "base", 1, 1);   //"amb@world_human_power_walker@female@base", "base" default
            }

            if (e.KeyCode == Keys.NumPad8)
            {
                Vehicle  pveh = playerPed.CurrentVehicle;
                Entity[] ent  = World.GetNearbyEntities(playerPed.Position, 10);          //player.GetTargetedEntity();
                //UI.ShowSubtitle(ent[0].GetType().Name);
                float currentDis = 9999;
                bool  j          = false;
                Ped   ped        = playerPed;

                for (int i = 0; i < ent.Length; i++)
                {
                    if (ent[i].GetType().Name == "Ped" && ent[i] != playerPed)
                    {
                        float newdis = World.GetDistance(playerPed.Position, ent[i].Position);
                        if (newdis < currentDis)
                        {
                            currentDis = newdis;
                            ped        = (Ped)ent[i];
                            j          = true;
                            UI.ShowSubtitle("found one");
                        }
                    }
                }

                if (j)
                {
                    ped.AlwaysKeepTask = true;

                    Function.Call(Hash.TASK_VEHICLE_TEMP_ACTION, ped, ped.CurrentVehicle, 114, 10000);
                    var seq = new TaskSequence();
                    seq.AddTask.CruiseWithVehicle(ped.CurrentVehicle, 20, 786603);
                    seq.AddTask.ParkVehicle(ped.CurrentVehicle, ped.Position + ped.ForwardVector * 100, ped.Heading, 100);
                    //seq.AddTask.WanderAround();
                    //ped.Task.CruiseWithVehicle(ped.CurrentVehicle, 30);
                    //ped.Task.ParkVehicle(ped.CurrentVehicle, ped.Position + ped.ForwardVector * 100, ped.Heading, 100);

                    seq.Close();
                    //ped.AlwaysKeepTask = true;
                    ped.Task.PerformSequence(seq);

                    // ped.Task.WanderAround();
                }
            }

            if (e.KeyCode == Keys.E)
            {
                //Ped ped = World.GetClosestPed(playerPed.Position, 10);
                Ped[] peds = World.GetNearbyPeds(playerPed, 10);
                int   i    = 0;

                while (peds[i] == playerPed)
                {
                    i++;
                }


                if (playerPed.IsInVehicle())
                {
                    peds[0].Task.EnterVehicle(playerPed.CurrentVehicle, VehicleSeat.ExtraSeat2, 5000, 2.0f, 16);
                    UI.ShowSubtitle("enter veh");
                }
            }

            if (e.KeyCode == Keys.C)
            {
                playerPed.ClearBloodDamage();
            }

            if (e.KeyCode == Keys.N)
            {
                if (playerPed.Weapons.Current.Hash != WeaponHash.Unarmed)
                {
                    playerPed.Weapons.Remove(playerPed.Weapons.Current);
                    playerPed.Money += ran.Next(5000);
                }
            }
        }