Hello. It is time for explain it detailed because in discord i has been ignored.
1) In natives.lua - SetEntityAsNoLongerNeeded (0xB736A491E64A32CF), SetVehicleAsNoLongerNeeded (0x629BFA74418D6239), SetPedAsNoLongerNeeded (0x2595DD4236549CE3) are broken (not usable) many months via classic usage. This natives worked before couple updates, with Invoking like this (for example):
I have been tested it with my gamemodes, blank gamemodes (like map-skater), old gamemodes, where this native worked through invoking before. No results.
Please, tell me! There is a new way to use this natives? Or i don’t know something?
This is stops many works and nice releases for FiveM/pΛ/проектΛ.So please respond!
And yes. 2) no screenshots. 3) It works ~1.5 month ago, till I noticed it.
Thank you in advance.
P.S. Balkan English. Sorry, but i have to post it!
Sometimes, when invoke has been applied - vehicles can not be destroyed with frag grenades, RPG’s and other explosives. And deleting by game ONLY if everyone is leave server.
Citizen.CreateThread(function()
while true do
Wait(0)
if IsControlJustPressed(1, 51) then -- E
local model = GetHashKey("buzzard")
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0, 5.0, 0)
local spawned_c = CreateVehicle(model, coords, 0.0, true, false)
SetModelAsNoLongerNeeded(model)
Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(spawned_c))
end
end
end)
or for ped (animals):
Citizen.CreateThread(function()
while true do
Wait(0)
if IsControlJustPressed(1, 51) then -- E
local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 2.0, 2.0, 0.0)
local amodel = GetHashKey("a_c_coyote", _r)
RequestModel(amodel)
while not HasModelLoaded(amodel) do
Wait(0)
end
local rndanimal = CreatePed(28, amodel, coords, 0.0, false, false)
Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(rndanimal))
SetModelAsNoLongerNeeded(amodel)
end
end
end)
It was usable for few updates ago. Why it is not usable now?
How can i explain to you, how much this native is useful?
It is hard to me, cause i do not know your language well.
I can confirm, the behavior of SetEntityAsNoLongerNeeded changed some updates ago. I don’t know if it fully doesn’t work for me anymore, but the entities didn’t despawn when they would have when the native worked flawlessly (more or less) for me before.
This workaround has indeed been confirmed as causing this type of bug, the next update will have a fix for this and other issues caused by this change in DELETE_[ENTITY/VEHICLE/OBJECT] handling, by patching each instance out separately. Thanks for the report!
local function loop(ent,mypos,positions)
local vehpos=GetEntityCoords(ent)
local dist_to_me=math.abs(vehpos.x-mypos.x)+math.abs(vehpos.y-mypos.y)+math.abs(vehpos.z-mypos.z)
if dist_to_me<400 then return end
for i,playerpos in pairs(positions) do
local dist_to_player=math.abs(vehpos.x-playerpos.x)+math.abs(vehpos.y-playerpos.y)+math.abs(vehpos.z-playerpos.z)
if dist_to_player<dist_to_me then
return
end
end
SetEntityAsMissionEntity(ent,true,true)
DeleteEntity(ent)
end
Citizen.CreateThread(function()
DecorRegister("NoLongerNeeded",2)
while true do
Wait(500)
local mypos
local positions={}
local myped=PlayerPedId()
for i=0,31 do
if NetworkIsPlayerActive(i) then
local ped=GetPlayerPed(i)
if(ped==myped) then
mypos=GetEntityCoords(myped)
else
positions[i]=GetEntityCoords(ped)
end
end
end
for veh in EnumerateVehicles() do
if not IsVehicleDriveable(veh) and GetVehicleEngineHealth(veh)<0
or DecorExistOn(veh,"NoLongerNeeded") and GetPedInVehicleSeat(veh,-1)==0 then
loop(veh,mypos,positions)
end
end
for ped in EnumeratePeds() do
if DecorExistOn(ped,"NoLongerNeeded") then
loop(ped,mypos,positions)
end
end
end
end)
local function NoLongerNeeded(ent)
--print("no longer needed")
if DoesEntityExist(ent) then
DecorSetBool(ent,"NoLongerNeeded",true)
Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(ent),true,true)
end
end