Hello,
I have been new to redm and resource development for a few weeks and I would like to create a trading gameplay with physics items, principle :
- Create box and attach items (where items are commodities into box)
I would like to point out that this gameplay is already done locally and is functional.
But now when I want to manage the replication layer at network level I face some problems.
I need each box to be seen and grabbed by all players on the server.
To test the development i use:
- Client/Player 1 with “%LOCALAPPDATA%\RedM\RedM.exe”
- Client/Player 2 with “%LOCALAPPDATA%\RedM\RedM.exe -cl2”
Now , in my resource i create a chat command like this (client.lua):
TriggerEvent("chat:addSuggestion", "/create_boxes", "Creating some boxes", {})
RegisterCommand('create_boxes', function(source, args, rawCommand)
local smodel = "box_model"
local numObjects = 100
local objModel = GetHashKey(smodel)
local coords = { x = x_value, y = y_value, z = z_value }
local isNetwork = true
local bScriptHostObj = false
local dynamic = false
local p7 = false
local p8 = false
for i = 1, numObjects do
if i > 1 then
coords.z = coords.z + box_height
end
local box = CreateObject( objModel, coords.x, coords.y, coords.z, isNetwork , bScriptHostObj, dynamic, p7, p8)
if box ~= 0 then
Citizen.Trace("\tBox created : "..tostring(box).." "..tostring(i).."/"..tostring(numObjects).."\n")
while not DoesEntityExist(box) do
Citizen.Wait(100)
end
Citizen.Trace("\t\t-EntityExist\n")
-- persistance
SetEntityAsMissionEntity(box, true, false)
-- just to make sure the boxes are networked
if not NetworkGetEntityIsNetworked(box) then
repeat
NetworkRegisterEntityAsNetworked(box)
Citizen.Wait(100)
until NetworkGetEntityIsNetworked(box)
end
Citizen.Trace("\t\t-IsNetworked\n")
else
Citizen.Trace("\tERROR create : "..tostring(box).." "..tostring(i).."/"..tostring(numObjects).."\n")
end
Citizen.Wait(100)
end
end)
After executing the command /create_boxes on client 1 this is what happens :
- On Client 1 : 61 boxes are created , 60 boxes are networked
- On Client 2 : 60 boxes are created , 60 boxes are networked
From GetMaxNumNetworkObjects - RedM Natives @ Unofficial Docs i can read :
Always returns 60
Then, my question
- Can I achieve my game goal or is it impossible due to limitations as I need more than 60 items?
Thank you to those who take the time to read me.