Jump to content

Vehicle Wheelie Script :?


koragg

Recommended Posts

Hello people. So recently i started the single player mod i made years back called GTA Mysterious Mod  (available on piratebay) and noticed one awesome feature that I've put in it. Indeed - the ability for some vehicles to do a wheelie. 

I'm asking here if anybody knows of such resource or has an idea or code or whatever on how to make such a thing for MTA.

Today i installed a cockpit view in my race server and i think a wheelie option for cars like phoenix, buffalo, clover would be awesome. 

Here's a link to the single player cleo mod which does it for GTA SA: https://www.gtaall.com/gta-san-andreas/cleo/60010-car-wheelie.html

Also handling or speed of cars shouldn't change at all while doing a wheelie (aka to be default ones).

 

I don't know if using setElementPosition would work. Also i don't know how to get just the vehicle's front part as an element (not the whole vehicle). But if bikes can do it why not cars too? Method should be the same ... hopefully we can make this. 

Edited by koragg
Link to comment

@nikitafloy I did it but for some reason when I set a timer to restore the handling to the car's default one after one second nothing happens, Here's the code:

function wheelie(player)
	local car = getPedOccupiedVehicle(player)
	if car then
		--Sabre
		if getElementModel(car) == 475 then
			setVehicleHandling(car, "centerOfMass", { 0.0, -0.65, 0.1 })
			setVehicleHandling(car, "tractionLoss", 5.90)
			setVehicleHandling(car, "engineAcceleration", 22.0)
			setVehicleHandling(car, "engineInertia", 1.0)
			setVehicleHandling(car, "suspensionAntiDiveMultiplier", 0.0000000000001)
		end
	end
end

function bindKeyOnJoin()
	bindKey(source, "M", "down", wheelie)
end
addEventHandler("onPlayerJoin", root, bindKeyOnJoin)

function bindKeyOnResStart()
	for i, player in ipairs(getElementsByType('player')) do
		bindKey(player, "M", "down", wheelie)
	end
end
addEventHandler("onResourceStart", resourceRoot, bindKeyOnResStart)

Can you make a timer which restores all changed handling lines to the car's default ones one second after the player has pressed the key? :)

Link to comment
local default_handling = {}

function wheelie(player)
	local car = getPedOccupiedVehicle(player)
	if car then
		--Sabre
		if getElementModel(car) == 475 then
          if default_handling[car] ~= true then
			setVehicleHandling(car, "centerOfMass", { 0.0, -0.65, 0.1 })
			setVehicleHandling(car, "tractionLoss", 5.90)
			setVehicleHandling(car, "engineAcceleration", 22.0)
			setVehicleHandling(car, "engineInertia", 1.0)
			setVehicleHandling(car, "suspensionAntiDiveMultiplier", 0.0000000000001)
        	default_handling[car] = true
          else
        	-- there default handling
        	default_handling[car] = nil
          end
		end
	end
end

function bindKeyOnJoin()
	bindKey(source, "M", "down", wheelie)
end
addEventHandler("onPlayerJoin", root, bindKeyOnJoin)

function bindKeyOnResStart()
	for i, player in ipairs(getElementsByType('player')) do
		bindKey(player, "M", "down", wheelie)
	end
end
addEventHandler("onResourceStart", resourceRoot, bindKeyOnResStart)

if you want timer:

function wheelie(player)
	local car = getPedOccupiedVehicle(player)
	if car then
		--Sabre
		if getElementModel(car) == 475 then
			setVehicleHandling(car, "centerOfMass", { 0.0, -0.65, 0.1 })
			setVehicleHandling(car, "tractionLoss", 5.90)
			setVehicleHandling(car, "engineAcceleration", 22.0)
			setVehicleHandling(car, "engineInertia", 1.0)
			setVehicleHandling(car, "suspensionAntiDiveMultiplier", 0.0000000000001)

		setTimer(function(car)
        	-- there default handling
        end, 1000, 1, car)
		end
	end
end

function bindKeyOnJoin()
	bindKey(source, "M", "down", wheelie)
end
addEventHandler("onPlayerJoin", root, bindKeyOnJoin)

function bindKeyOnResStart()
	for i, player in ipairs(getElementsByType('player')) do
		bindKey(player, "M", "down", wheelie)
	end
end
addEventHandler("onResourceStart", resourceRoot, bindKeyOnResStart)

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...