• NPC Derma/Stand help.
    1 replies, posted
Hello. I have an NPC that I want to use as a dialogue menu for new players to explain my server, here's the code. [CODE]cl.init include('shared.lua') function ENT:Initialize() self.Color = Color( 255, 255, 255, 255 ) end function ENT:Draw() --self:DrawEntityOutline( 1 ) self.Entity:DrawModel() end local function myMenu() local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 100, 100 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Name window" ) Frame:SetVisible( true ) Frame:SetDraggable( true ) Frame:ShowCloseButton( true ) Frame:MakePopup() end usermessage.Hook("ShopNPCUsed",myMenu)[/CODE] [CODE]init local model = "models/player/breen.mdl" local classname = "npc" local ShouldSetOwner = true ------------------------------- 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:AcceptInput( Name, Activator, Caller ) if Name == "Use" and Caller:IsPlayer() then umsg.Start("ShopNPCUsed", Caller) umsg.End() end end ----------- -- Think -- ----------- function ENT:Think() end ----------- -- Touch -- ----------- function ENT:Touch(ent) end -------------------- -- PhysicsCollide -- -------------------- function ENT:PhysicsCollide( data, physobj ) end[/CODE] The NPC Spawns properly with no errors, and the Derma opens up just fine. Only, theres two issues i'm experiencing that I need help with. 1) My NPC stands with his arms out(file:///C:/Program%20Files%20(x86)/Steam/userdata/119055715/760/remote/4000/screenshots/2016-01-17_00001.jpg) and his pupils rolled up his head(file:///C:/Program%20Files%20(x86)/Steam/userdata/119055715/760/remote/4000/screenshots/2016-01-17_00002.jpg) this looks very unnatural, where did I mess up in my code to make it stand like this? 2) The Derma menu opens normally, only problem is it opens 4 copies of the menu when I use "E" once. Why is that? And more importantly, how can I fix that? Thank you to all who reply.
first: Screenshots cant be taken from your pc url. 2nd the fix is setting its use type. also, self.Entity is useless, simply use self.
Sorry, you need to Log In to post a reply to this thread.