How can I make an snpc that can have a menu open on it? I tried this but it doesnt work:
cl_init:
[lua]
include(‘shared.lua’)
ENT.RenderGroup = RENDERGROUP_BOTH
/---------------------------------------------------------
Name: Draw
Desc: Draw it!
---------------------------------------------------------/
function ENT:Draw()
self.Entity:DrawModel()
end
/---------------------------------------------------------
Name: DrawTranslucent
Desc: Draw translucent
---------------------------------------------------------/
function my_message_hook( um )
local DermaPanel = vgui.Create( “DFrame” ) – Creates the frame itself
DermaPanel:SetPos( 50,50 ) – Position on the players screen
DermaPanel:SetSize( 500, 400 ) – Size of the frame
DermaPanel:SetTitle( “Testing Derma Stuff” ) – Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( false ) – Draggable by mouse?
DermaPanel:ShowCloseButton( true ) – Show the close button?
DermaPanel:MakePopup( true )
Msg( "The message has been received!" )
end
usermessage.Hook(“my_message”, my_message_hook)
function ENT:DrawTranslucent()
self:Draw()
end
[/lua]
Init:
[lua]
function ENT:Initialize()
self:SetModel( "models/Police.mdl" )
self:SetHullType( HULL_HUMAN );
self:SetHullSizeNormal();
self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )
self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_OPEN_DOORS | CAP_ANIMATEDFACE | CAP_TURN_HEAD | CAP_USE_SHOT_REGULATOR | CAP_AIM_GUN )
self:SetMaxYawSpeed( 5000 )
self:SetUseType(SIMPLE_USE)
//don't touch stuff above here
self:SetHealth(99999)
//self:Give( "weapon_ak47" ) //Can be given sweps.
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:Use(activator,caller)
Print(“Hey”)
umsg.Start(“my_message”, activator)
umsg.End(“my_message”)
end
function ENT:OnTakeDamage(dmg)
self:SetHealth(self:Health() - dmg:GetDamage())
if self:Health() <= 0 then //run on death
self:SetSchedule( SCHED_FALL_TO_GROUND ) //because it’s given a new schedule, the old one will end.
end
end
[/lua]
Shared:
[lua]
ENT.Base = “base_ai”
ENT.Type = “ai”
ENT.PrintName = “”
ENT.Author = “”
ENT.Contact = “” //fill in these if you want it to be in the spawn menu
ENT.Purpose = “”
ENT.Instructions = “”
ENT.AutomaticFrameAdvance = true
/---------------------------------------------------------
Name: OnRemove
Desc: Called just before entity is deleted
---------------------------------------------------------/
function ENT:OnRemove()
end
/---------------------------------------------------------
Name: PhysicsCollide
Desc: Called when physics collides. The table contains
data on the collision
---------------------------------------------------------/
function ENT:PhysicsCollide( data, physobj )
end
/---------------------------------------------------------
Name: PhysicsUpdate
Desc: Called to update the physics … or something.
---------------------------------------------------------/
function ENT:PhysicsUpdate( physobj )
end
/---------------------------------------------------------
Name: SetAutomaticFrameAdvance
Desc: If you’re not using animation you should turn this
off - it will save lots of bandwidth.
---------------------------------------------------------/
function ENT:SetAutomaticFrameAdvance( bUsingAnim )
self.AutomaticFrameAdvance = bUsingAnim
end
[/lua]
I don’t know whats wrong, or why the menu wont open…
I tried touching the ent and that worked, but using the ent doesn’t work.