Set%sAsNoLongerNeeded and some Delete%s do not work with latest manifest version

Beef asked me to create new thread “in detail”.

In short, Set(Ped/Vehicle)AsNoLongerNeeded and Delete(Ped/Vehicle) and probably Entity/Object does not work in 44febabe-d386-4d18-afbe-5e627f4af937 but works with manifest version 05cfa83c-a124-4cfa-a768-c24a5811d8f9

I know how to fix this, by not using recommended(broken in some way most of the time) manifest version.

This is everything inportant about that but you wanted me to copy and paste old thread in detail, right? Because everyone are afraid of publicly admiting this or renaming that thread? Okay!

I will even add my comments, because everyone like “details” and copypasta.

Hello. It is time for explain it detailed because in discord i has been ignored.

Sounds familiar. One year later I did the same and was asked to shut up. And few months later people no longer can write in discord without paying for it monthly. They always asked for repro and I always answered “old repro still works”. Now I can’t say it in discord, but it will be useless anyway if no one understood it in last 4 months.

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):

Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(YOUR_ENTITY))

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!

Feb '17

here, for example.

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)

Feb '17

any way to fix it or need to wait for update?

Feb '17

Trying to get NetworkGetNetworkIdFromEntity for spawned car and suspects CreateVehicle - does not return entity id.

Feb '17

Refer to this

a) this is the feature requests forum b) but that’s a thing that could be added as a built-in feature because why the fucking fuck would you write your own population

Feb '17

Any solutions for this trouble?

Feb '17

I meant that population shouldnt be coded, but actually implemented by us?

Feb '17

To add new features, like animals, jobs, missions this natives must work. Or this is all about cuffing eachother…

Feb '17

How can i spawn peds/cars for missions, jobs and etc. without deleting them after completing/failing?

Feb '17

DeleteVehicle?

Feb '17

Ease deleting from server. As no longer needed.

Feb '17

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.

Feb '17

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.

2

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! :snail:

2 Replies

Solution

4

Thank you. I have wait for this answer! Keep it up!

3 MONTHS LATER

Has this been fixed yet ?
Thx

1 YEAR LATER

Jul 26

No. It’s not working again or maybe was never fixed.

Jul 29

Had to implement my own workaround for that.

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

4 MONTHS LATER

Manifest version 44febabe-d386-4d18-afbe-5e627f4af937 (2017-06-07)

  • The natives.lua file natives_universal.lua will be used for client-side Lua. This is a universal natives.lua file, which should be able to be switched to without having to change your scripts. It also represents a more recent (2017-06-05) snapshot of NativeDB.

Manifest version 05cfa83c-a124-4cfa-a768-c24a5811d8f9 (2017-06-04)

  • Scripts will now be registered as a game network script. This is required for networking entities.
  • [CREATE_VEHICLE](file:///N:/AF35D0D2583051B0) and similar functions behave differently when passing true, true as network object flags. See network objects for more information.

For some reason, SetVehicleAsNoLongerNeeded is not working with manifest version 44febabe-d386-4d18-afbe-5e627f4af937 but works with manifest version 05cfa83c-a124-4cfa-a768-c24a5811d8f9 using exactly same code. I think function definitions are same for both manifest, it’s something else that broke it.

SetEntityAsNoLongerNeeded() works perfectly for me. Although I haven’t read al of this because I’m lazy, so that might not be the only issue :slight_smile:

What manifest version you are using?

Please provide reproduction steps instad of saying “feature x does not work on manifest version y”.

that doesn’t mean copying the old topic’s text…

  1. Copy both blocks of code in client script.
  2. Use recommended resource manifest version.
  3. Press E to spawn buzzard and coyote. Coyote will run away, but buzzard will stay there. Whereever you go it will stay where you spawned it.
  4. Swich to “network” manifest, repeat 3, buzzard will despawn when you are far enough from it.

It’s absolutely the same problem, same words, same repro. You want me to explain it in pictures, diagrams, record videos? You should just rename that old thread. There would be no reason to create new one if someone really cared to try the same repro maybe half a year ago.

Please format your topic correctly and coherently.