Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Brief Example on how to "Teleport Forward" in GTA5
- * using ScriptHookVDotNet
- *
- * By SteamSilenceChannel
- */
- //Some Usings are not needed
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- using NativeUI;
- using GTA.Math;
- public class MainClass : Script
- {
- public MainClass()
- {
- Tick += onTick;
- }
- #region On Tick
- private void onTick(object sender, EventArgs e)
- {
- //if the buttons are pressed, run the method
- if (teleportForwardPressed())
- {
- teleportForward(); //method
- }
- }
- #endregion
- #region Teleport Forward Region
- bool teleportForwardPressed()
- {
- if (Game.IsControlPressed(2, GTA.Control.Cover) &&
- Game.IsControlPressed(2, GTA.Control.Detonate))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #region Teleport Forward
- void teleportForward()
- {
- var playerPosi = player.Character.Position;
- var groundHeight = World.GetGroundHeight(playerPosi);
- if (!player.Character.IsInVehicle())
- {
- /*Now we are saving ForwardVector + Player Position in a var
- so we can subtract Z and the Ped won't keep going up */
- var forwardPos = playerPed.Position + playerPed.ForwardVector;
- Vector3 newForward = new Vector3(forwardPos.X, forwardPos.Y, forwardPos.Z - 1f);
- playerPed.Position = newForward;
- }
- else
- {
- //The vehicle doesn't need that Z get subtracted
- Vehicle v = player.Character.CurrentVehicle;
- v.Position += v.ForwardVector * 4.5f;
- }
- Wait(13);
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement