Native "ApplyForceToEntity" is broken

I make a script “Flash” and i have a problem with a native…

Error : http://prntscr.com/fpxdrx

Its not a problem of my script…The problem is appeared has the the last update and its same for carmageddon (Carmageddon Won't Start) mod he use the native ApplyForceToEntity and he does not work since the last update…

Check the function’s arguments in FiveM folder\citizen\scripting\lua\natives_universal.lua, its syntax may have changed.

1 Like

Hmm i have verified and no… And my code is good… ApplyForceToEntity(ped, 1, pos.x,pos.y,pos.z, 0,0,0, 1, false, true, true, true, true) its the native…

the native DOES work, but it seems to randomly crash, not sure if its an issue with the carmageddon script or the native.

1 Like

Its not a issue of the carmageddon script… i dont use the caramgeddon i just make my script and i have a error… And the user of Carmageddon have the same… U have a solution for resolve this ? :frowning:

does the native work at all? because when i’ve tried it worked up to a certain point and then caused the script to fail.

1 Like

I dont know :confused:

There is not another way of making a fast run script if this native doesnot work ??

I am not sure where your problem is, I just tried it and it is still working like a charm

Yes but its not a problem of “me”… Try carmageddon… He’s broken since the update, and its same for my addon “flash” its not a problem of my code… If i remove the native i dont have any error… But if i remove this line my fast run code for Flash does not work dude

I have an other way for the fast run, it’s “SetMoveSpeedMultiplier(ped, 1.49)” but this native is not in FiveM :’(

RegisterNetEvent("FastRun")
AddEventHandler("FastRun", function()
    Citizen.CreateThread(function()
		local pos = GetEntityCoords(ped, true)
		--local pos2 = GetEntityForwardVector(ped)

		SetAnimRate(ped, 5.0, 0, 0)
		SetObjectPhysicsParams(ped,200000000.0, 1, 1000, 1, 0,0, 0, 0, 0, 0, 0)
		SetActivateObjectPhysicsAsSoonAsItIsUnfrozen(ped, true)
		ApplyForceToEntity(ped, 1, pos.x,pos.y,pos.z, 0,0,0, 1, false, true, true, true, true)
		-- SetMoveSpeedMultiplier(ped, 1.49)
	end)
end)

See my code, he’s perfect… Its the native dude

ped is defined higher

This is how I did it and it is working

Citizen.CreateThread(function() --Superman Mode
	while true do
		Wait(1)
		
		local coords = Citizen.InvokeNative(0x0A794A5A57F8DF91, GetPlayerPed(-1), Citizen.ResultAsVector())
		local SupermanZ
		if IsControlPressed(1, 33) then
			SupermanZ = 5.0
		else
			SupermanZ = 0.225
		end
		
		if (supermanmode == true) then
			GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("gadget_parachute"), 1, false, false)
			if IsPedInParachuteFreeFall(GetPlayerPed(-1)) then
				ApplyForceToEntity(GetPlayerPed(-1), 1, coords.x * 2, coords.y * 2, SupermanZ, 0.0, 0.0, 0.0, 1, false, true, true, true, true)
			end
		end
	end
end)

What is SupermanZ ?? (local supermanz = ??)

The Z Force. How strong the force applys to the Z - Vector.

Hmmm ok i will re-try my code …

Did you try using float values instead of int by specifying .0 at the end of you numbers (especialy rotations x, y, z)?

Also, did you specified resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' at the top of your resource so your resource can use natives_universal.lua?

I have try this yes… But i will try with the manifest :wink:

Its good :slight_smile: i dont have any error buuuuut

my code does not work -_-

Citizen.CreateThread(function()
  while true do
   Wait(10)
	local pos = GetEntityCoords(ped, true)
	local ped = GetPlayerPed(-1)
	--local pos2 = GetEntityForwardVector(ped)

	SetAnimRate(ped, 5.0, 0, 0)
	SetObjectPhysicsParams(ped,200000000.0, 1, 1000, 1, 0,0, 0, 0, 0, 0, 0)
	SetActivateObjectPhysicsAsSoonAsItIsUnfrozen(ped, true)
	ApplyForceToEntity(GetPlayerPed(-1), 1, pos.x*1,pos.y*1,pos.z*1, 0,0,0, 1, false, true, true, true, true)
	-- SetMoveSpeedMultiplier(ped, 1.49)
  end
end)

You use ped before assigning it :wink:
(didn’t noticed that earlier)