Advertisement
TheManatee

Teleport Forward Source Code- ScriptHookVDotNet SteamSilence

May 9th, 2017
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. /*
  2. * Brief Example on how to "Teleport Forward" in GTA5
  3. * using ScriptHookVDotNet
  4. *
  5. * By SteamSilenceChannel                
  6.  
  7. */
  8.  
  9.  
  10. //Some Usings are not needed
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Windows.Forms;
  14. using GTA;
  15. using GTA.Native;
  16. using NativeUI;
  17. using GTA.Math;
  18.  
  19. public class MainClass : Script
  20. {
  21.    
  22.     public MainClass()
  23.     {
  24.         Tick += onTick;
  25.     }
  26.  
  27.     #region On Tick
  28.     private void onTick(object sender, EventArgs e)
  29.     {
  30.         //if the buttons are pressed, run the method
  31.         if (teleportForwardPressed())
  32.         {
  33.             teleportForward(); //method
  34.         }
  35.     }
  36.     #endregion
  37.  
  38.    #region Teleport Forward Region
  39.  
  40.     bool teleportForwardPressed()
  41.     {
  42.         if (Game.IsControlPressed(2, GTA.Control.Cover) &&
  43.             Game.IsControlPressed(2, GTA.Control.Detonate))
  44.         {
  45.             return true;
  46.         }
  47.         else
  48.         {
  49.             return false;
  50.         }
  51.     }
  52.    
  53.     #endregion
  54.  
  55.    
  56.       #region Teleport Forward
  57.     void teleportForward()
  58.     {
  59.         var playerPosi = player.Character.Position;
  60.         var groundHeight = World.GetGroundHeight(playerPosi);
  61.  
  62.         if (!player.Character.IsInVehicle())
  63.         {
  64.             /*Now we are saving ForwardVector + Player Position in a var
  65.             so we can subtract Z and the Ped won't keep going up      */
  66.             var forwardPos = playerPed.Position + playerPed.ForwardVector;
  67.             Vector3 newForward = new Vector3(forwardPos.X, forwardPos.Y, forwardPos.Z - 1f);
  68.             playerPed.Position = newForward;
  69.         }
  70.         else
  71.         {
  72.             //The vehicle doesn't need that Z get subtracted
  73.             Vehicle v = player.Character.CurrentVehicle;
  74.             v.Position += v.ForwardVector * 4.5f;
  75.         }
  76.  
  77.         Wait(13);
  78.     }
  79.  
  80.     #endregion
  81.    
  82.    
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement