Jump to content

[HELP] Car Rotation


MatreN

Recommended Posts

  • Moderators
Posted (edited)
5 hours ago, MatreN said:

How do I turn an infernus 360 degrees?

You can also change the rotate (velocity) with this function:

https://wiki.multitheftauto.com/wiki/SetElementAngularVelocity

 

But for exact 360, you will need the setElementRotation function.

It just depends on what you are going to make.

 

Edited by IIYAMA

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
13 hours ago, Tut said:

Why bother, he's asking for help. Nothing to shame him for.

I understand that but cmon... just googling "mta rotation" first result will be the link i gave him. 

K nvm. Im sorry if that was too rude ftom my side

Edited by Emix
  • Like 1
  • Moderators
Posted
11 hours ago, MatreN said:

I'll make a showroom-style system.

A small example/hack to rotate (multiple) vehicles. With very little code.

 

This code is untested

local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount() % duration) / duration * 360 )
end)

 

 

local vehicle1 = createVehicle(--[[ fill in]])
setElementParent(vehicle1, rotationElement)



local vehicle2 = createVehicle(--[[ fill in]])
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(--[[ fill in]])
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, true)

 

  • Like 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount()%20)/30*360) -- Duration Araba Dönüş Hızı
end)

local vehicle1 = createVehicle(2500.1000976563, -1662.5999755859, 13.199999809265)
setElementParent(vehicle1, rotationElement)


local vehicle2 = createVehicle(2499.8999023438, -1673, 13.199999809265)
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(2491.6999511719, -1667.5999755859, 13.10000038147)
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, false)

I don't know if I did it right, but the cars don't turn 360 degrees.

I'am HAPPY ( ͡°◡ ͡°   )

Posted
23 minutes ago, MatreN said:

local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount()%20)/30*360) -- Duration Araba Dönüş Hızı
end)

local vehicle1 = createVehicle(2500.1000976563, -1662.5999755859, 13.199999809265)
setElementParent(vehicle1, rotationElement)


local vehicle2 = createVehicle(2499.8999023438, -1673, 13.199999809265)
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(2491.6999511719, -1667.5999755859, 13.10000038147)
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, false)

I don't know if I did it right, but the cars don't turn 360 degrees.

are you talk about 360 auto ? or only one?

 

 

 
  • Moderators
Posted (edited)
1 hour ago, MatreN said:

local rotationElement = createElement("rotationElement")
local duration = 1000
addEventHandler("onClienRender", root, 
function () 
	setElementRotation(rotationElement, 0,0, (getTickCount()%20)/30*360) -- Duration Araba Dönüş Hızı
end)

local vehicle1 = createVehicle(2500.1000976563, -1662.5999755859, 13.199999809265)
setElementParent(vehicle1, rotationElement)


local vehicle2 = createVehicle(2499.8999023438, -1673, 13.199999809265)
setElementParent(vehicle2, rotationElement)


local vehicle3 = createVehicle(2491.6999511719, -1667.5999755859, 13.10000038147)
setElementParent(vehicle3, rotationElement)


setElementFrozen(rotationElement, false)

I don't know if I did it right, but the cars don't turn 360 degrees.

Clientside?

 

Btw you are missing an argument: (model)

createVehicle ( int model, float x, float y, float z

 

 

 

Edited by IIYAMA

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted
13 hours ago, MatreN said:

(int model) will be replaced with vehicle name?

Is your issue now solved with xFabel his explanation?

 

You can convert names to id's with this function:

https://wiki.multitheftauto.com/wiki/GetVehicleModelFromName

 

local model = getVehicleModelFromName ("bandito")

if model then -- is there an id based on that name?
  
  
end

 

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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...