Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*This is the STCE's Teleport Utility Initial release source code
- By SteamSIlenceChannel */
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- using NativeUI;
- using GTA.Math;
- public class MainClass : Script
- {
- private MenuPool menuPool_;
- UIMenu mainMenu;
- UIMenuItem showButtonsItem;
- UIMenu playerMenu;
- UIMenu teleportMenu;
- private Player player = Game.Player;
- private Ped playerPed = Game.Player.Character;
- List<dynamic> teleportLocations = new List<dynamic>();
- float currentLocationX;
- float currentLocationY;
- float currentLocationZ;
- public MainClass()
- {
- setup();
- Tick += onTick;
- KeyDown += onKeyDown;
- }
- void setup()
- {
- menuPool_ = new MenuPool();
- mainMenu = new UIMenu("", "Quick teleport with Button combinations");
- mainMenu.SetBannerType("scripts\\texture\\customBanner.png");
- menuPool_.Add(mainMenu);
- playerMenu = menuPool_.AddSubMenu(mainMenu, "Player");
- teleportMenu = menuPool_.AddSubMenu(mainMenu, "Teleport Options");
- setupPlayerFunction();
- }
- void setupPlayerFunction()
- {
- godMode();
- NeverWantedLevel();
- teleportSetup();
- }
- void godMode()
- {
- UIMenuCheckboxItem chkGodMode = new UIMenuCheckboxItem("God Mode", false);
- playerMenu.SetBannerType("scripts\\texture\\customBanner.png");
- playerMenu.AddItem(chkGodMode);
- player.Character.IsInvincible = false;
- player.IsInvincible = false;
- playerMenu.OnItemSelect += (sender, item, index) =>
- {
- if(item == chkGodMode)
- {
- chkGodMode.Checked = !chkGodMode.Checked;
- }
- };
- playerMenu.OnCheckboxChange += (sender, item, index) =>
- {
- if(item == chkGodMode)
- {
- if (chkGodMode.Checked)
- {
- player.IsInvincible = true;
- player.Character.IsInvincible = true;
- }else
- {
- player.IsInvincible = false;
- player.Character.IsInvincible = false;
- }
- }
- };
- }
- bool NeverWantedLevelChecker;
- void NeverWantedLevel()
- {
- UIMenuCheckboxItem chkNeverWanted = new UIMenuCheckboxItem("Never Wanted", false);
- playerMenu.AddItem(chkNeverWanted);
- playerMenu.OnItemSelect += (sender, item, index) =>
- {
- if(item == chkNeverWanted)
- {
- chkNeverWanted.Checked = !chkNeverWanted.Checked;
- }
- };
- playerMenu.OnCheckboxChange += (sender, item, index) =>
- {
- if (item == chkNeverWanted)
- {
- if (chkNeverWanted.Checked)
- {
- NeverWantedLevelChecker = true;
- }
- else
- {
- NeverWantedLevelChecker = false;
- }
- //the function to set never wanted is in OnTick event
- }
- };
- }
- public static bool GetButtonDown()
- {
- bool isCombinationPressed;
- if ((Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 74 }) ) &&
- (Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 44 })))//19 down) 44rb, 15left
- {
- isCombinationPressed = true;
- }
- else
- {
- isCombinationPressed = false;
- }
- return isCombinationPressed;
- }
- bool isTeleportCombinationPressed()
- {
- bool isCombinationPressed;
- if ((Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 18 })) &&
- (Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 22 })&&
- (Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 37 }))))//19 pra baixo)
- {
- isCombinationPressed = true;
- }
- else
- {
- isCombinationPressed = false;
- }
- return isCombinationPressed;
- }
- bool isTeleportCombination2Pressed()
- {
- bool isCombinationPressed;
- if ((Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 18 })) &&
- (Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 45 }) &&
- (Function.Call<bool>(Hash.IS_CONTROL_PRESSED/*6342219533232326959L*/, new InputArgument[] { 2, 37 }))))//19 pra baixo)
- {
- isCombinationPressed = true;
- }
- else
- {
- isCombinationPressed = false;
- }
- return isCombinationPressed;
- }
- private void onTick(object sender, EventArgs e)
- {
- //controller test
- if (GetButtonDown())
- {
- mainMenu.Visible = !mainMenu.Visible;
- }
- //controller test
- if (isTeleportCombinationPressed())
- {
- teleportToWaypoint();
- }
- if (isTeleportCombination2Pressed())
- {
- teleportToChilliad();
- // Game.Player.Character.Position = new Vector3(markerPosition.X, groundHeight, player.Character.Position.Z);
- //Game.Player.Character.Position = markerPosition + (Vector3.WorldDown * 200.5f);
- // Game.Player.Character.Position = new Vector3(451.2820f,5572.9897f, 796.6793f);
- // Game.Player.Character.Position.Normalize();
- }
- if (shouldTeleportWhenDie)
- {
- currentLocationX = player.Character.Position.X;
- currentLocationY = player.Character.Position.Y;
- currentLocationZ = player.Character.Position.Z;
- if (player.Character.IsDead)
- {
- Wait(20000);
- player.Character.Position = new Vector3(currentLocationX, currentLocationY, currentLocationZ);
- }
- }
- if (menuPool_ != null)
- {
- menuPool_.ProcessMenus();
- }
- if(NeverWantedLevelChecker == true)
- {
- player.WantedLevel = 0;
- }
- }
- private void onKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.F3 && !menuPool_.IsAnyMenuOpen())
- {
- mainMenu.Visible = !mainMenu.Visible;
- }
- if(e.Alt & e.KeyCode == Keys.W)
- {
- teleportToWaypoint();
- }
- if (e.Alt & e.KeyCode == Keys.U)
- {
- teleportToChilliad();
- }
- }
- bool shouldTeleportWhenDie;
- private void teleportSetup()
- {
- teleportLocations.Add("Waypoint");
- teleportLocations.Add("Mount Chilliad");
- UIMenuCheckboxItem chkTeleportWhenDie = new UIMenuCheckboxItem("Teleport to last location when you die", false);
- teleportMenu.SetBannerType("scripts\\texture\\customBanner.png");
- teleportMenu.AddItem(chkTeleportWhenDie);
- UIMenuListItem listOfTeleports = new UIMenuListItem("Teleport location: ", teleportLocations, 0);
- teleportMenu.AddItem(listOfTeleports);
- showButtonsItem = new UIMenuItem("Show Buttons");
- teleportMenu.AddItem(showButtonsItem);
- teleportMenu.OnItemSelect += (sender, item, index) =>
- {
- if (item == showButtonsItem)
- {
- showButtonSet();
- }
- };
- teleportMenu.OnItemSelect += (sender, item, index) =>
- {
- if(item == chkTeleportWhenDie)
- {
- chkTeleportWhenDie.Checked = !chkTeleportWhenDie.Checked;
- }
- };
- teleportMenu.OnCheckboxChange += (sender, item, index) =>
- {
- if (item == chkTeleportWhenDie)
- {
- if (chkTeleportWhenDie.Checked)
- {
- shouldTeleportWhenDie = true;
- }else
- {
- shouldTeleportWhenDie = false;
- }
- }
- };
- UIMenuItem btnTeleportNow = new UIMenuItem("Teleport To chosen location Now");
- teleportMenu.AddItem(btnTeleportNow);
- teleportMenu.OnItemSelect += (sender, item, index) =>
- {
- if(item == btnTeleportNow)
- {
- teleportNow(listOfTeleports);
- }
- };
- }
- void teleportNow(UIMenuListItem list)
- {
- var markerPosition = World.GetWaypointPosition();
- var groundHeight = World.GetGroundHeight(markerPosition);
- if (list.Index == 0)
- {
- teleportToWaypoint();
- }
- if (list.Index == 1)
- {
- teleportToChilliad();
- }
- }
- void teleportToWaypoint()
- {
- var markerPosition = World.GetWaypointPosition();
- var groundHeight = World.GetGroundHeight(markerPosition);
- if (!player.Character.IsInVehicle())
- {
- player.Character.Position = markerPosition + (Vector3.WorldDown * 200.5f);
- }else
- {
- Vehicle v = player.Character.CurrentVehicle;
- v.Position = markerPosition + (Vector3.WorldDown * 200.5f);
- }
- Wait(2000);
- }
- void teleportToChilliad()
- {
- if (!player.Character.IsInVehicle())
- {
- player.Character.Position = new Vector3(451.2820f, 5572.9897f, 796.6793f);
- }
- else
- {
- Vehicle v = player.Character.CurrentVehicle;
- v.Position = new Vector3(451.2820f, 5572.9897f, 796.6793f);
- }
- Wait(2000);
- }
- void showButtonSet()
- {
- UI.Notify("If you're using a xbox controller: \n"+
- "\"LB\" + \"X\" + \"A\" => Teleport to Waypoint \n"+
- "\"LB\" + \"B\" + \"A\" => Teleport to Mount Chilliad \n");
- UI.Notify("If you're a Keyboard player: \n" +
- "\"Alt\" + \"W\" => Teleport to Waypoint \n" +
- "\"Alt\" + \"U\" => Teleport to Mount Chilliad \n");
- }
- }
- // Game.Player.Character.Position = new Vector3(markerPosition.X, groundHeight, player.Character.Position.Z);
- //Game.Player.Character.Position = markerPosition + (Vector3.WorldDown * 200.5f);
- // Game.Player.Character.Position = new Vector3(451.2820f,5572.9897f, 796.6793f);
- // Game.Player.Character.Position.Normalize();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement