local instances = {}
RegisterServerEvent("instance:set")
AddEventHandler("instance:set", function(set)
print('[INSTANCES] Instances now looked like this: ', json.encode(instances))
local src = source
TriggerClientEvent('DoTheBigRefreshYmaps', src)
local instanceSource = 0
if set then
if set == 0 then
for k,v in pairs(instances) do
for k2,v2 in pairs(v) do
if v2 == src then
table.remove(v, k2)
if #v == 0 then
instances[k] = nil
end
end
end
end
end
instanceSource = set
else
instanceSource = math.random(1, 63)
while instances[instanceSource] and #instances[instanceSource] >= 1 do
instanceSource = math.random(1, 63)
Citizen.Wait(1)
end
end
print(instanceSource)
if instanceSource ~= 0 then
if not instances[instanceSource] then
instances[instanceSource] = {}
end
table.insert(instances[instanceSource], src)
end
SetPlayerRoutingBucket(
src --[[ string ]],
instanceSource
)
print('[INSTANCES] Instances now looks like this: ', json.encode(instances))
end)
Namedinstances = {}
RegisterServerEvent("instance:setNamed")
AddEventHandler("instance:setNamed", function(setName)
print('[INSTANCES] Named Instances looked like this: ', json.encode(Namedinstances))
local src = source
local instanceSource = nil
TriggerClientEvent('DoTheBigRefreshYmaps', src)
if setName == 0 then
for k,v in pairs(Namedinstances) do
for k2,v2 in pairs(v.people) do
if v2 == src then
table.remove(v.people, k2)
end
end
if #v.people == 0 then
Namedinstances[k] = nil
end
end
instanceSource = setName
else
for k,v in pairs(Namedinstances) do
if v.name == setName then
instanceSource = k
end
end
if instanceSource == nil then
instanceSource = math.random(1, 63)
while Namedinstances[instanceSource] and #Namedinstances[instanceSource] >= 1 do
instanceSource = math.random(1, 63)
Citizen.Wait(1)
end
end
end
if instanceSource ~= 0 then
if not Namedinstances[instanceSource] then
Namedinstances[instanceSource] = {
name = setName,
people = {}
}
end
table.insert(Namedinstances[instanceSource].people, src)
end
SetPlayerRoutingBucket(
src --[[ string ]],
instanceSource
)
print('[INSTANCES] Named Instances now look like this: ', json.encode(Namedinstances))
end)
This can be used like so.
-- Add someone to any available instance. (use this when you dont need to add others to the same instance)
TriggerServerEvent('instance:set')
-- Then to put them back into the normal instance
TriggerServerEvent('instance:set', 0)
-- Use the follwing when you would like to add multiple people to the same instance.
TriggerServerEvent('instance:setNamed', 'InstanceName') -- InstanceName can be any string, e.g Apartment-26
-- Then to put them back into the normal instance
TriggerServerEvent('instance:setNamed', 0)
Good evening I come very late in the conversation but I have a fundamental question for a beginner like me. Once the person is in the instance we don’t see each other anymore and we don’t have collision with other players in the same place. It’s great but for the use of audio via Mumble as it uses a form of proximity we will hear the people around us and this will cause problem. how can i solve this problem please. I am asking this because I would like to use this instance system to create my interiors but I have this sound problem in my head. Thank you for the help
Hi! I created a PolyZone and 2 events, entering en leaving.
In this zone there is a blip to tune your car. When i enter the zone my car disappears and the blip to start the tuning is gone.
I use SetPlayerRoutingBucket and SetEntityRoutingBucket, but im getting confused now.
Is there someone with experience online that can help me.
Here is my code: Client Side
local src = source
local cplayerid = (GetPlayerPed(src))
local GetEntityRouting = GetEntityRoutingBucket(cplayerid)
SetPlayerRoutingBucket(src, 0)
SetEntityRoutingBucket(GetEntityRouting, 0)
print("[PlayerID:" .. cplayerid .."] Inside:" .. GetEntityRouting)
end)
RegisterNetEvent('qb-customs:exitBucket', function()
local src = source
local cplayerid = (GetPlayerPed(src))
local GetEntityRouting = GetEntityRoutingBucket(cplayerid)
SetPlayerRoutingBucket(src, cplayerid)
SetEntityRoutingBucket(GetEntityRouting, cplayerid)
print("[PlayerID:" .. cplayerid .."] Outside:" .. GetEntityRouting)
end)```
I can also share a little video to show you what happens.
Any thoughts?
I am trying to use this for when I want people to be inside of an interior and not have the sun shining through the ceiling. Has anyone made a mod like this?
I’m using a safezone script where I’m using SetPlayerRoutingBucket and GetEntityRoutingBucket for vehicles, however when a Player drives in and out of the safe zone he changes the size of the vehicle, everything is fine and without problems, what happens is if the vehicle has a driver and a passenger, then the driver stays in the previous dimension and does not change dimensions together, the vehicle and the 2 occupants of the game, can anyone help me with a solution?
Hey! I am having a super hard time trying to get people to see other people in my server. Not sure if these routing buckets got enabled by a script of some sort, but every time there is 1-2 people who can’t see others. How can I just disable this completely? Going to be introducing housing as a primary source of…well housing. Going to do away with apartment entirely since it is causing so many issues. Any help is appreciated! It is driving me crazy haha.