So I have a Entity that spawns just fine,
[CODE]local model = "models/props_wasteland/controlroom_storagecloset001a.mdl" -- What model should it be?
local classname = "ps_closet" -- This should be the name of the folder containing this file.
local ShouldSetOwner = true -- Set the entity's owner?
-------------------------------
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
-------------------------------
--------------------
-- Spawn Function --
--------------------
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 25
local ent = ents.Create( classname )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
if ShouldSetOwner then
ent.Owner = ply
end
return ent
end
----------------
-- Initialize --
----------------
function ENT:Initialize()
self.Entity:SetModel( model )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
-----------------
-- Take Damage --
-----------------
function ENT:OnTakeDamage( dmginfo )
self.Entity:TakePhysicsDamage( dmginfo )
end
------------
-- On use --
------------
function ENT:Use( activator, caller )
end
-----------
-- Think --
-----------
function ENT:Think()
end
-----------
-- Touch --
-----------
function ENT:Touch(ent)
end
--------------------
-- PhysicsCollide --
--------------------
function ENT:PhysicsCollide( data, physobj )
end[/CODE]
I want to use a Derma menu with it, so when I use my "Use" key, it opens the menu. I have the code
[CODE]local Frame = vgui.Create( "DFrame" )
Frame:SetPos( 5, 5 )
Frame:SetSize( 300, 150 )
Frame:SetTitle( "Name window" )
Frame:SetVisible( true )
Frame:SetDraggable( false )
Frame:ShowCloseButton( true )
Frame:MakePopup()[/CODE]
But everywhere I put it causes script errors. Where do I need it, in order for it to work with my ent? Can I use the init.lua, or do I need a whole different file path to put the Dermas lua in? Please help, thanks!
Look at the Net Library wiki page and use that
[QUOTE=NiandraLades;49353205]Look at the Net Library wiki page and use that[/QUOTE]
Thanks Niandra, you're always first to help me with my dumbass problems. :D
[editline]20th December 2015[/editline]
[QUOTE=NiandraLades;49353205]Look at the Net Library wiki page and use that[/QUOTE]
So I should use net.ReadEntity()? If so, where should I put it? In the Derma itself, or the init.lua?
I think you could use net library to send the player the vgui when he presses button E
[QUOTE=Breadcat105;49353225]Thanks Niandra, you're always first to help me with my dumbass problems. :D
[editline]20th December 2015[/editline]
So I should use net.ReadEntity()? If so, where should I put it? In the Derma itself, or the init.lua?[/QUOTE]
No, basically just send a net message to the Caller then on the client receive the said net message and create a DFrame in there.
Sorry, you need to Log In to post a reply to this thread.