--=========================================--
--| Mod:		RagdollButton.lua         |--
--| Version:	1.0				          |--
--| Author:		ZeRo			          |--
--| Team:		ZModW			          |--
--=========================================--

parkour_SpaceKey = 32

local parkourscript1 = {}

local PkeySwitch1=false

function parkourscript1.unload()
end

function parkourscript1.init()
	local playerParkour1 = PLAYER.PLAYER_ID()
	local ParkourPed1 = PLAYER.PLAYER_PED_ID()
	PLAYER._SET_MOVE_SPEED_MULTIPLIER(ParkourPed1, 1.55);
end

function parkourscript1.tick()
	local playerParkour1 = PLAYER.PLAYER_ID()
	local ParkourPed1 = PLAYER.PLAYER_PED_ID()
	
	if(get_key_pressed(parkour_SpaceKey))then
		PkeySwitch1 = true
		wait(50)
		for b = 1, 40 do
			ENTITY.APPLY_FORCE_TO_ENTITY(ParkourPed1, 1, 0,0,85,0,0,0, false, false, true, false, false, false);
			ENTITY.SET_ENTITY_INVINCIBLE(ParkourPed1, true);
		end
		wait(420)
		PLAYER.GIVE_PLAYER_RAGDOLL_CONTROL(playerParkour1, true);
		PED.SET_PED_RAGDOLL_ON_COLLISION(ParkourPed1, true);
		PED.SET_PED_RAGDOLL_FORCE_FALL(ParkourPed1)
		GAMEPLAY.SET_GRAVITY_LEVEL(95);
		for b = 1, 15 do
			wait(100)
		end
		PED.SET_PED_RAGDOLL_ON_COLLISION(ParkourPed1, false);
	elseif PkeySwitch1 then
		PkeySwitch1=false
		PED.SET_PED_RAGDOLL_ON_COLLISION(ParkourPed1, false);
		ENTITY.SET_ENTITY_INVINCIBLE(ParkourPed1, false);
	end
end

return parkourscript1