Hello !
I would like to create a basic property system where you can buy a property and only you can open or close the doors.
The problem is that I can't figure out how to display door information with 3D2D. It is not the rendering that poses a problem but the recovery of information.
Here is what the definition of a property looks like in my sh_properties.lua file :
Properties[11].Attributes = {
["Name"] = "Maison de campagne C",
["Price"] = 1600,
["Image"] = "", // Presentation of the house to the estate agency
["Owner"] = nil,
["Category"] = "House"
}
Properties[11].Doors = { 1734, 1733, 1732 }
I use the MapCreationID for the doors so I can only use it on the server side. So I need to find a trick to send this information to the customer and that's when I can't do it anymore.
I try this when the player connects to the server in my sv_properties.lua file:
function SetupDoors(ply)
for k,v in pairs(Properties) do
for a,b in pairs(v.Doors) do
local door = ents.GetMapCreatedEntity(b)
door:SetNWString("Datas", util.TableToJSON(v))
end
end
net.Start("DrawDoors")
net.Send(ply)
end
hook.Add("PlayerInitialSpawn", "testhook", SetupDoors)
And I do this in my cl_properties.lua file :
net.Receive("DrawDoors", function(
for k,v in pairs(ents.GetAll()) do
if isDoor(v) then
local datas = v:GetNWString("Datas", "none")
if datas != "none" then
datas = util.JSONToTable(datas)
PrintTable(datas)
end
end
end
end)
But strangely enough, not all the doors are there and I doubt that's a good way to go. I've been trying to find solutions for 2 days, but either they don't work at all, or every other time, so I'm starting to get confused.
For information, this is not a DarkRP, I'm trying to make my own handmade gamemode to progress in Lua.
I hope you can help me.
Boris
Sorry, you need to Log In to post a reply to this thread.