Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Math;
- using GTA.Native;
- using System;
- using System.Windows.Forms;
- using NativeUI;
- using System.Collections.Generic;
- namespace Menu_for_bguard
- {
- public class Menu_for_bguard : Script
- {
- public List<Blip> guardBlipOnce = new List<Blip>();
- public List<Ped> guardSpawnOnce = new List<Ped>();
- bool isTickActive;
- Ped player = Game.Player.Character;
- Ped pedGuard;
- MenuPool modMenuPool;
- UIMenu mainMenu;
- ScriptSettings config;
- Keys OpenMenu;
- public Menu_for_bguard()
- {
- this.Aborted += SingleBlipSpawn;
- this.Aborted += SingleGuardSpawn;
- Tick += onTick;
- KeyDown += onKeyDown;
- modMenuPool = new MenuPool();
- mainMenu = new UIMenu("Guard Menu","Mod by Kieran_S");
- modMenuPool.Add(mainMenu);
- SetupGuardMenu(mainMenu);
- SetupPedMenu(mainMenu);
- modMenuPool.RefreshIndex();
- config = ScriptSettings.Load("scripts//guardmenu.ini");
- OpenMenu = config.GetValue<Keys>("Options", "OpenMenu", OpenMenu);
- }
- public void SetupPedMenu(UIMenu menu)
- {
- var setupPedMenu = modMenuPool.AddSubMenu(menu, "Guard Model Menu");
- for (int i = 0; i < 1; i++) ;
- var MPros01 = new UIMenuItem("MPros01", "");
- setupPedMenu.AddItem(MPros01);
- setupPedMenu.OnItemSelect += (sender, item, index) =>
- {
- if (item == MPros01)
- {
- Function.Call(Hash.CHANGE_PLAYER_PED, player, pedGuard, false, false);
- }
- };
- }
- public void SetupGuardMenu(UIMenu menu)
- {
- var guardSpawnMenu = modMenuPool.AddSubMenu(mainMenu, "Guard Spawn Menu");
- for (int i = 0; i < 1; i++) ;
- var spawnGuardButton = new UIMenuItem("Spawn Guard");
- guardSpawnMenu.AddItem(spawnGuardButton);
- var deleteGuardButton = new UIMenuItem("Delete Guard");
- guardSpawnMenu.AddItem(deleteGuardButton);
- guardSpawnMenu.OnItemSelect += (sender, item, index) =>
- {
- if (item == spawnGuardButton)
- {
- //turns on ontick
- isTickActive = true;
- //spawn guard
- pedGuard = World.CreatePed(PedHash.MPros01, player.Position + (player.ForwardVector * 2.5f));
- guardSpawnOnce.Add(pedGuard);
- pedGuard.Task.LookAt(player);
- //add guns to guard
- pedGuard.Weapons.Give(WeaponHash.AssaultRifle, 9999, false, false);
- pedGuard.Weapons.Give(WeaponHash.PumpShotgun, 9999, false, false);
- pedGuard.Weapons.Give(WeaponHash.Pistol, 9999, false, false);
- //add guard to pedgroup
- player.CurrentPedGroup.Add(pedGuard, false);
- //add blip to guard
- pedGuard.AddBlip();
- pedGuard.CurrentBlip.Sprite = BlipSprite.Standard;
- pedGuard.CurrentBlip.Color = BlipColor.Blue;
- pedGuard.CurrentBlip.Scale = 0.65f;
- pedGuard.CurrentBlip.Name = "Guard";
- pedGuard.CurrentBlip.IsShortRange = true;
- //subtitle
- GTA.UI.Notify("You bodyguard has ~g~arrived");
- }
- if (item == deleteGuardButton)
- {
- pedGuard.Delete();
- }
- };
- }
- private void onTick(object sender, EventArgs e)
- {
- if (modMenuPool != null && modMenuPool.IsAnyMenuOpen() == true)
- { modMenuPool.ProcessMenus(); }
- startOfLoop:
- if (isTickActive)
- {
- //make sure script is not overloaded
- Wait(1000);
- //delete guard if player goes to far and alert player
- if (!player.IsInRangeOf(pedGuard.Position, 500f)) pedGuard.Delete();
- if (!pedGuard.Exists()) UI.Notify("The guard was ~r~deleted");
- if (!pedGuard.Exists()) Wait(5000);
- Function.Call(Hash._REMOVE_NOTIFICATION);
- if (!pedGuard.Exists()) isTickActive = false;
- //
- //loop script to before isTickActive
- goto startOfLoop;
- }
- }
- private void onKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == OpenMenu && !modMenuPool.IsAnyMenuOpen())
- mainMenu.Visible = !mainMenu.Visible;
- }
- public void DisplayHelpTextThisFrame(string text) // thanks to jedijosh
- {
- Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);
- }
- public void SingleBlipSpawn(object sender, EventArgs e) // make guard blip not dupe
- {
- foreach (Blip existingblip in guardBlipOnce)
- {
- if (existingblip.Exists()) existingblip.Remove();
- }
- }
- public void SingleGuardSpawn(object sender, EventArgs e) // make guard not dupe
- {
- foreach (Ped existingguard in guardSpawnOnce)
- {
- if (existingguard.Exists()) existingguard.Delete();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement