Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GTAIV MegaJump Script
- -- by Simon. Based off Alexander Blade's example scripts.
- -- Global Variables
- PLAYER_ID, PLAYER_CHAR = 0, PLAYER_INDEX
- function SetCharVelocity(char, velocity_x, velocity_y, velocity_z)
- -- Wrapper for: SET_CHAR_VELOCITY=4, False
- PushInt(char)
- PushFloat(velocity_x)
- PushFloat(velocity_y)
- PushFloat(velocity_z)
- CallNative("SET_CHAR_VELOCITY")
- end
- function GetCharVelocity(char, velocity_x, velocity_y, velocity_z)
- -- Wrapper for: GET_CHAR_VELOCITY=4, False
- PushInt(char)
- PushVarPtr()
- PushVarPtr()
- PushVarPtr()
- velocity_x = GetFloatParam(1)
- velocity_y = GetFloatParam(2)
- velocity_z = GetFloatParam(3)
- CallNative("GET_CHAR_VELOCITY")
- end
- function GetCharHeading(char, z_angle)
- -- Wrapper for: GET_CHAR_HEADING=2, False
- PushInt(char)
- PushVarPtr()
- z_angle = GetFloatParam(1)
- end
- --
- function InitScript()
- -- blah-blah-blah
- Wait(10000)
- end
- function WaitForPlayerPoolCreation()
- while (IsPlayerPoolCreated() == 0) do
- Wait(2000)
- end
- end
- function WaitForValidPlayer()
- PLAYER_CHAR = 0
- repeat
- CallNative("GET_PLAYER_ID")
- PLAYER_ID = GetIntResult()
- if (PLAYER_ID >= 0) then
- PushInt(PLAYER_ID)
- CallNative("CONVERT_INT_TO_PLAYERINDEX")
- PLAYER_INDEX = GetIntResult()
- PushInt(PLAYER_INDEX)
- PushVarPtr()
- CallNative("GET_PLAYER_CHAR")
- PLAYER_CHAR = GetIntParam(1)
- if (PLAYER_CHAR <= 0) then
- Wait(1000)
- end
- end
- until (PLAYER_CHAR > 0)
- end
- function main()
- InitScript()
- while true do
- WaitForPlayerPoolCreation()
- WaitForValidPlayer()
- if (IsKeyPressed(9) == 1) then
- if (IsKeyPressed(16) == 1) then -- shift (default: sprint)
- local velocity_x, velocity_y, velocity_z
- PushInt(PLAYER_INDEX)
- PushInt(1)
- CallNative("SET_PLAYER_INVINCIBLE")
- PushInt(PLAYER_CHAR)
- PushVarPtr()
- PushVarPtr()
- PushVarPtr()
- CallNative("GET_CHAR_VELOCITY")
- velocity_x = (GetFloatParam(1) * 3.0)
- velocity_y = (GetFloatParam(2) * 3.0)
- velocity_z = GetFloatParam(3)
- if ( velocity_z > -1.5 and velocity_z < 1.5 ) then -- just gonna assume a player is falling/jumping if z velocity is not between -1.5 and 1.5
- SetCharVelocity(PLAYER_CHAR, velocity_x, velocity_y, velocity_z)
- end
- end
- if (IsKeyPressed(32) == 1) then -- space (default: jump)
- local velocity_x, velocity_y, velocity_z
- PushInt(PLAYER_INDEX)
- PushInt(1)
- CallNative("SET_PLAYER_INVINCIBLE")
- PushInt(PLAYER_CHAR)
- PushVarPtr()
- PushVarPtr()
- PushVarPtr()
- CallNative("GET_CHAR_VELOCITY")
- velocity_x = (GetFloatParam(1) * 20.0)
- velocity_y = (GetFloatParam(2) * 20.0)
- velocity_z = GetFloatParam(3)
- if ( velocity_z > -1.5 and velocity_z < 1.5 ) then -- just gonna assume a player is falling/jumping if z velocity is not between -1.5 and 1.5
- SetCharVelocity(PLAYER_CHAR, velocity_x, velocity_y, 20.0)
- end
- end
- end
- Wait(50)
- end
- end
- -- start
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement