Ok so with help from people on here I made a door script, I then made a little system to get an entity’s MapID (Specifically a door) and I was wondering how to use the gotten MapID (1341) to the client so that the door text below “Door To” changes based on the MapID of the door. Here is the Code I have for my Door:
surface.CreateFont( "OblivionDoorFont", {
font = "Kingthings Petrock", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
extended = false,
size = 30,
weight = 2000,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = true,
} )
local doors = {
["func_door"] = true,
["prop_door_rotating"] = true,
["func_door_rotating"] = true,
["func_movelinear"] = true
}
local doorname1 = "Imperial City"
hook.Add( "HUDPaint", "DoorDisplay", function()
local ent = LocalPlayer():GetEyeTrace().Entity
if (not IsValid(ent) or LocalPlayer():GetPos():Distance(ent:GetPos()) > 150) then return; end
local class = ent:GetClass()
if (doors[class]) then
surface.SetFont( "OblivionDoorFont" )
surface.SetTextColor( 251, 255, 117 )
surface.SetTextPos( (ScrW() / 1.0) - 100, ScrH() / 1.2 - -26 )
surface.DrawText("Door to")
surface.SetTextPos( (ScrW() / 1.1) - 35, ScrH() / 1.1 - 1 )
surface.DrawText(doorname1)
end
end)
And here is how I obtained the MapID of the door serverside:
hook.Add( "PlayerSay", "PlayerSayExample", function( ply, text, team )
if text == "/getid" then
local ent = Entity( 1 ):GetEyeTrace().Entity
if ent:MapCreationID() == 1341 then
print("IT ACTUALLY WORKED")
else print("For Fuck Sake")
end
else print("Wrong Command Idiot, it's /getid you twat")
end
end )
if (SERVER) then
util.AddNetworkString( "my_door_networkstring" );
--function were do you set/get door id--
net.Start( "my_door_networkstring" )
net.WriteWriteEntity( door_ent )
net.WriteWriteUInt( door_id_value, 16 ) -- I guess 16 bits might be overkill but w/e
net.Broadcast()
else
net.Receive( "my_door_networkstring", function(len)
local my_door = net.ReadEntity() -- Get door entity that we will use to set ID
local my_doors_id = net.ReadUInt(16) -- Read door's ID
my_door.door_id = my_doors_id -- Setting that ID to door's entity so we can use it from there.
end)
end
And then in your code
hook.Add( "HUDPaint", "DoorDisplay", function()
local ent = LocalPlayer():GetEyeTrace().Entity
if (not IsValid(ent) or LocalPlayer():GetPos():Distance(ent:GetPos()) > 150) then return; end
local class = ent:GetClass()
if (doors[class] and ent.door_id) then -- check if that door have an ID
surface.SetFont( "OblivionDoorFont" )
surface.SetTextColor( 251, 255, 117 )
surface.SetTextPos( (ScrW() / 1.0) - 100, ScrH() / 1.2 - -26 )
surface.DrawText(ent.door_id) -- Then draw it :)
surface.SetTextPos( (ScrW() / 1.1) - 35, ScrH() / 1.1 - 1 )
surface.DrawText(doorname1)
end
end)
My code might be shit tho. Text me if u tried and had some issues.
But how would the table know that the MapIDs are that of an entity
[editline]1st August 2017[/editline]
Thanks I’ll give it a try, I have never touched networking as of yet
[editline]1st August 2017[/editline]
This does not seem to work or I am not knowledgeable to get it to work, here is what I have in my cl_doordisplay:
net.Receive( "my_door_networkstring", function(len)
local my_door = net.ReadEntity() -- Get door entity that we will use to set ID
local my_doors_id = net.ReadUInt(16) -- Read door's ID
my_door.door_id = my_doors_id -- Setting that ID to door's entity so we can use it from there.
end)
surface.CreateFont( "OblivionDoorFont", {
font = "Kingthings Petrock", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
extended = false,
size = 30,
weight = 2000,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = true,
} )
local doors = {
["func_door"] = true,
["prop_door_rotating"] = true,
["func_door_rotating"] = true,
["func_movelinear"] = true
}
local doorname1 = "Imperial City"
hook.Add( "HUDPaint", "DoorDisplay", function()
local ent = LocalPlayer():GetEyeTrace().Entity
if (not IsValid(ent) or LocalPlayer():GetPos():Distance(ent:GetPos()) > 150) then return; end
local class = ent:GetClass()
if (doors[class] and ent.door_id) then -- check if that door have an ID
surface.SetFont( "OblivionDoorFont" )
surface.SetTextColor( 251, 255, 117 )
surface.SetTextPos( (ScrW() / 1.0) - 100, ScrH() / 1.2 - -26 ) )
surface.DrawText(ent.door_id) -- Then draw it :)
surface.SetTextPos( (ScrW() / 1.1) - 35, ScrH() / 1.1 - 1 ) )
surface.DrawText(doorname1)
end
end
end)
And here is what I have in my sv_doordisplay:
hook.Add( "PlayerSay", "PlayerSayExample", function( ply, text, team )
if text == "/getid" then
local ent = Entity( 1 ):GetEyeTrace().Entity
if ent:MapCreationID() == 1341 then
print("IT ACTUALLY WORKED")
else print("For Fuck Sake")
end
else print("Wrong Command Idiot, it's /getid you twat")
end
end )
if (SERVER) then
util.AddNetworkString( "my_door_networkstring" );
--function were do you set/get door id--
net.Start( "my_door_networkstring" )
net.WriteEntity( door_ent )
net.WriteUInt( 1341, 16 ) -- I guess 16 bits might be overkill but w/e
net.Broadcast()
end
Pick entity id (they are constant as said previously) of that door, set your MapIDs for that door, do the same on client side - u are gucci.
It will looks something like that I guess.
local doors_ids = {
[183] = "func_door",
[195] = "prop_door_rotating",
[685] = "func_door_rotating",
[1337] = "func_movelinear"
}
local ent_index = LocalPlayer():GetEyeTrace().Entity:EntIndex() -- get Entity Index of what we are looking on
if (doors_ids[ent_index) then -- Check if that entity exist in our list
print("cool")
end
this code is usefull (kinda), if u know already which ID of the entity will be (for map entities for example), so u can preset those and that will be much better.
Nah, actually he is fine with just unique entity ID that delive server.
If someone need networking.
At the part of setting this ID, just use the code that was posted before with networkmessages, and add aditional message to players that will connect to the server, with ID’s of the doors.