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;
- public class WalkOnWater : Script
- {
- private bool toggle = false;
- private Ped p = Game.Player.Character;
- private ScriptSettings config;
- private float height;
- private Prop platform2;
- private Keys toggleKey;
- private Vector3 position;
- public WalkOnWater()
- {
- this.Tick += new EventHandler(this.OnTick);
- this.KeyDown += new KeyEventHandler(this.OnKeyDown);
- this.KeyUp += new KeyEventHandler(this.OnKeyUp);
- config = ScriptSettings.Load("scripts\\Walk On Water.ini");
- toggleKey = config.GetValue("Options", "toggleKey", Keys.L);
- this.Interval = 10;
- }
- float GetWaterHeight(Vector3 pos) //function for getting the water height
- {
- OutputArgument outputArgument = new OutputArgument();
- Function.Call<bool>(Hash._0xF6829842C06AE524, (InputArgument)pos.X, (InputArgument)pos.Y, (InputArgument)pos.Z, (InputArgument)outputArgument); //gets the water height
- return outputArgument.GetResult<float>(); //returns the water height as a float value
- }
- private void OnTick(object sender, EventArgs e)
- {
- if (toggle == true && p.IsOnFoot && platform2.Exists()) //checks if the toggle is true, the player is on foot, and is the prop exists
- {
- Prop prop = platform2;
- prop.FreezePosition = true;
- position = new Vector3(this.p.Position.X, this.p.Position.Y, this.p.Position.Z); //Gets the player's position
- float waterHeight = GetWaterHeight(position); //gets the water height (Z coordinate of the top of the water)
- Function.Call(Hash._0x06843DA7060A026B, (InputArgument)prop, (InputArgument)position.X, (InputArgument)position.Y, (InputArgument)waterHeight, (InputArgument)1, (InputArgument)0, (InputArgument)0, (InputArgument)1); //Changes the position of the prop underneath the player
- prop.Rotation = new Vector3(90f, 0.0f, 0.0f); //adjusts the rotation of the prop underneath the player
- prop.IsVisible = false; //Makes the prop invisible
- prop.IsInvincible = true; //Makes the prop unbreakbale
- }
- if (toggle == true)
- {
- if (!p.IsAlive || !p.IsOnFoot || !p.Exists()) //toggles the "toggle" boolean and deletes the prop if the player does not exist, is not on foot, or is not alive.
- {
- toggle = false;
- platform2.Delete(); //deletes the prop underneath the player
- }
- }
- }
- private void OnKeyDown(object sender, KeyEventArgs e)
- {
- }
- private void OnKeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == toggleKey && toggle == true && platform2.Exists()) //checks if the "toggle" boolean has been toggled and that the platform exists.
- {
- toggle = false;
- platform2.Delete(); //deletes the prop underneath the player
- return; //ensures the next if statement does not go through
- }
- if (e.KeyCode == toggleKey && toggle == false && p.IsOnFoot && p.IsInWater) //checks in the player is on foot, is in water, and that the "toggle" boolean is false
- {
- toggle = true;
- platform2 = World.CreateProp((Model)"prop_huge_display_02", this.p.Position, false, false); //creates the prop that makes the player walk on water
- this.p.Position = new Vector3(p.Position.X, p.Position.Y, + GetWaterHeight(p.Position)); //teleports the player just above the water
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement