Hello, recently I've started with a 3d2d system for the doors.
And I can't get the owner var.
I've tried multiple things.
Here's the code:
Regards, Stadus
[LUA]
function Door_Test()
local door_classes = {
prop_door = true,
prop_door_rotating = true,
}
local ply = LocalPlayer()
local entity = ply:GetEyeTrace().Entity;
local distance = entity:LocalToWorld( entity:OBBCenter() ):Distance( ply:EyePos() );
if (distance <= 256) then
if entity:IsValid() and door_classes[entity:GetClass()] then
local angles = entity:GetAngles();
local position = entity:GetPos();
local offset = angles:Up() + angles:Forward() * -1.2 + angles:Right() * - 31;
local offset2 = angles:Up() + angles:Forward() * 1.2 + angles:Right() * - 15.5;
angles:RotateAroundAxis(angles:Forward(), 90);
angles:RotateAroundAxis(angles:Right(), 90);
angles:RotateAroundAxis(angles:Up(), 0);
-- if (distance <= 256) then
cam.Start3D2D(position + offset, angles, 0.1);
draw.SimpleText("Door", "TargetID", 80.5, 46, Color(255, 255, 255, 255), 1, 1);
draw.SimpleText("Door", "TargetID", 80.5, 46, Color(255, 255, 255, 255), 1, 1);
cam.End3D2D();
angles:RotateAroundAxis(angles:Forward(), 0);
angles:RotateAroundAxis(angles:Right(), 180);
angles:RotateAroundAxis(angles:Up(), 0);
cam.Start3D2D(position + offset2, angles, 0.1);
draw.SimpleText( self:GetDoorOwner() .. " Door", "TargetID", 80.5, 46, Color(255, 255, 255, 255), 1, 1);
draw.SimpleText("Door", "TargetID", 80.5, 46, Color(255, 255, 255, 255), 1, 1);
cam.End3D2D();
end
end
end
hook.Add("PostDrawOpaqueRenderables", "Door_Test", Door_Test) [/LUA]
You're using self:GetDoorOwner().
self in this case is not defined. Self is for use in defining functions. Change self to entity.
I tried that this is the error I get:
[LUA]
[ERROR] gamemodes/darkrp/gamemode/door_system.lua:34: attempt to concatenate a userdata value
[/LUA]
Ya it's a userdata value containing all the data from the player. So it's not the just name of the player you want to display.
To get the players name from the userdata simply add :GetName() or just :Name() to it.
[lua]
entity:GetDoorOwner():Name()
[/lua]
Sorry, you need to Log In to post a reply to this thread.