This resource provides a unique world/dimensions that can be assigned to players, peds, objects or vehicles in FiveM. This does nothing by itself, it is a tool for developers seeking to place players in separate worlds, for whatever reason they deem necessary. If you have no idea what that means then you probably shouldn’t be reading this further down.
How to Use
Features:
Allows you to assign any entity to a virtual world between 0 and 2,147,483,647.
Entities assigned to world 0 will be visible normally to all players. Making world 0 the default world in the game.
Entities in different worlds cannot physically interact with each other aside from explosions which can move vehicles(but not damage them).
NPC and NPC vehicle spawning is disabled in > 0 worlds. Wanted levels are also disabled.
Functions:
SetEntityVirtualWorld(entity, worldid) --Assigns a virtual world to an entity, be it a ped, vehicle, object or player.
GetEntityVirtualWorld(entity) --Returns an entity's virtual world as an integer.
Great release! Not sure what it does, and the link is dead, and there are no screenshots, and there are no videos or anything, and. Wait. What about the release is great again?
This is similar to the implementations that others have written, but this is the first public one, thanks.
However, I am skeptical whether this works in it’s current form. Reason being: you are sending entity handles/ids over the net, but these handles will be different across clients. Are you sure this works with multiple clients? Perhaps you need to use EntityToNet and NetToEntity to get the proper handles?
By itself this resource does nothing. This is more of a tool for developers to use by triggering certain events. If a person doesn’t know how to use this then they shouldn’t, it’s very simple.
This is similar to the implementations that others have written, but this is the first public one, thanks.
However, I am skeptical whether this works in it’s current form. Reason being: you are sending entity handles/ids over the net, but these handles will be different across clients. Are you sure this works with multiple clients? Perhaps you need to use EntityToNet and NetToEntity to get the proper handles?
Good point, I ought to further debug this and make proper changes if necessary.
Citizen.CreateThread(function()
while true do
while myworld ~= 0 do
SetPedDensityMultiplierThisFrame(0)
SetScenarioPedDensityMultiplierThisFrame(0, 0)
SetParkedVehicleDensityMultiplierThisFrame(0)
SetRandomVehicleDensityMultiplierThisFrame(0)
SetSomeVehicleDensityMultiplierThisFrame(0)
SetVehicleDensityMultiplierThisFrame(0)
ClearPlayerWantedLevel(PlayerId())
Citizen.Wait(0)
end
Citizen.Wait(1000)
end
end)
This was out of personal preference, I’m using this on a server I’m working on for a player race mini-game and I’d rather not have NPCs or NPC vehicles during the race.
By the way I pushed a little update that fixed entities not disappearing after switching between virtual worlds.