vorp_weaponv2 store npcs floating Redm/CFX/LUA

When I load vorp_weaponv2 the store npcs are floating in the air.

This is caused by the spawn height of your character when you connect to the server and the general timing of the store npcs spawning. The faster your system is, the less likely you will see this problem.

How do i fix it?
Look in your “client.lua”, for the function “SpawnNPC”—roughly lines 747 to 760.
It should look like this.

function SpawnNPC(Store)
	local v = Config3.Stores[Store]
	if v.SpawnNPC then
		LoadModel(v.NpcModel)
		local npc = CreatePed(v.NpcModel, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, false, true, true, true)
		Citizen.InvokeNative(0x283978A15512B2FE, npc, true)
		SetEntityCanBeDamaged(npc, false)
		SetEntityInvincible(npc, true)
		Wait(500)
		FreezeEntityPosition(npc, true)
		SetBlockingOfNonTemporaryEvents(npc, true)
		Config3.Stores[Store].NPC = npc
	end
end

The function that freezes the npc is:

FreezeEntityPosition(npc, true)

Solution 1:
Increase the wait before the freeze.

Wait(500)

This is milliseconds. 500 is 1/2 a second. Increase to a higher number like 2000 for a 2-second delay. Save and upload your changes, log out of the game client, restart the server, log back in, and test.

Solution 2:

Remove the freeze. If you remove the freeze the npc can run away when there’s gun fire or threats in the area. They usually do not return to position.
To comment out the freeze do this.

-- FreezeEntityPosition(npc, true)

Save and upload your changes, log out of the game client, restart the server, log back in, and test.

What if I want them to freeze and the time out didn’t fix the issue for me?
Then try Solution 3.

In the “client.lua” find the event “vorp:SelectedCharacter”. It’s roughly likes 108 to 114.
It looks like this:

RegisterNetEvent("vorp:SelectedCharacter")
AddEventHandler("vorp:SelectedCharacter", function(charid)
	TriggerServerEvent("syn_weapons:removeused")
	TriggerEvent("syn_weapons:initalizing")
	Citizen.Wait(1000)
	RemoveAllPedWeapons(PlayerPedId(), true, true)
end)

after this line

RemoveAllPedWeapons(PlayerPedId(), true, true)

add these lines:

Citizen.Wait(2000)
NPCFloatingFix()

Then after the line:

end)

Add this function.

function NPCFloatingFix()
	for key,store_table in pairs (Config3.Stores) do		
		npc = Config3.Stores[key].NPC		
		FreezeEntityPosition(npc, false)
		Wait(2000)
		FreezeEntityPosition(npc, true)
	end 
end 

This code unfreezes each npc that is spawned, waits 2 seconds, so they can fall to the ground at their location, and then refreezes them. The wait gives your character time to load in before working with the npcs. You may need to increase this wait to as high as 10 seconds depending on the speed of your client. If you’re still having issues, increase the wait time and reload.

Save and upload your changes, log out of the game client, restart the server, log back in, and test.

Why do I need to log out and restart the server? Any changes that involve spawning things need to be tested properly with a fresh restart. No matter how things are coded the client decides when and how things are loaded or removed. For the best results, and most accurate testing for a live server and player experience, do a full restart.

By