[HELP] Creating turbulence!

Hey guys! Just trying to re-design turbulence using natives. Was skimming through, but couldn’t find anything related to moving the players vehicle. (e.g. shuffling it down, up, left, or right).

Essentially I’m looking for any sort of native that will push or shove a player’s vehicle in a particular direction (hopefully not exclusively of course), so that I can use random number generators and vector3 coords to try to re-create turbulence. Hopefully that makes sense. IF anyone has any questions, or has an Idea of natives, I’d love some assistance as I’ve looked into
https://docs.fivem.net/natives, but it’s likely that I can’t think of the word that is being conveyed.

Using the SET_PLANE_TURBULENCE_MULTIPLIER native only sets the plane’s in-game default anus turbulence (which i’m not looking to do…)

during a flight you can test this command:

RegisterCommand('turbulence', function(source, args)
local force=100
Citizen.CreateThread(function()
    while true do
        Wait(300)
		ApplyForceToEntity(GetVehiclePedIsIn(GetPlayerPed(-1), false),3,0.0,0.0,math.random(-force,force)*0.1,0.0,0.0,0.0,0,false,true,true,false,true)
	end
end)
end,false)

it will rock the plane up and down, do edits and maybe you can get something usable

2 Likes

Will do! I’ll try it tonite! cheers!

Works like a fucking charm! Thanks!

My problem was that I was only looking within the vehicles section of the natives (and skimmed through all of them, RIP)

Onne more question. (Help me understand your code. Comparing your section of the code to the native, I understand ALLLMOST everything.
I guess my confusion is within the math.random(-force,force)

I understand that force is a variable, and math.random is a native lua function that allows a random number to be selected, HOWEVER, I don’t understand how that references force.
Directly, I don’t know how (-force,force) applies.
In other languages, this’d be an x,y, but in this case, is it saying, multiply math.random times (positive force OR negative) force?

I know this is most likely a lua thing rather than a fivem native thing, (and I know you’ve helped tremendously already), but if you can help me out, I’ll figure out a way to repay you! :slight_smile:

it is a random number between -100 and 100 (force) negative means push the plane down and positive up, the others are set to 0.0 because it would make the plane shake sideways

GOTCHA! math.random(-force,force)
is the saaame as math.random(-100,100)
is the same as
“give me a random number between -100 and 100!”

Love ya! I knew it was a lua thing (In fact it’s a math.random thing - go figure! :smiley: )

Thanks!