Remove my NPC/Ent) on button click.

Im trying to remove my NPC when a button is pressed, but apparently, it wont work.

Here are my NPC codes.
cl_init:
[lua]
include(‘shared.lua’)

ENT.RenderGroup = RENDERGROUP_BOTH

function ENT:Draw()
self.Entity:DrawModel()
end

function ENT:DrawTranslucent()
self:Draw()
end

function ENT:SetRagdollBones( bIn )
self.m_bRagdollSetup = bIn
end

function weapon_npc()
–The Derma Menu–
end
[/lua]
init.lua
[lua]
AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include(‘shared.lua’)
function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = (tr.HitPos + tr.HitNormal * 16) 

local ent = ents.Create( "my_npc" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent

end

function ENT:Initialize()

self:SetModel( "models/player/gman_high.mdl" ) 

self:SetSolid( SOLID_BBOX ) 
self:SetMoveType( MOVETYPE_STEP ) 
--self:DisallowMoving( true )
local ent2 = ents.Create("npc_indicator")
ent2:SetPos( self:GetPos() + (self:GetUp() * 90) )
ent2:SetParent( self )
ent2:SetAngles( self:GetAngles() )
ent2:Spawn()
ent2:SetCollisionGroup(COLLISION_GROUP_WORLD)
ent2.npc = self
--ent2:DisallowMoving( true )
/*
local ent3 = ents.Create("npc_user")
ent3:SetPos( self:GetPos() + (self:GetUp() * 50) + (self:GetForward() * 15) )
--ent3:SetParent( self )
ent3:SetAngles( self:GetAngles() )
ent3:Spawn()
ent3:SetCollisionGroup(COLLISION_GROUP_WORLD)
ent3.npc = self
*/
local sequence = self:LookupSequence("idle")
self:SetSequence(sequence) 

end

/*
function ENT:Use( activator )
print(“Entity Used”)
datastream.StreamToClients( activator, “OpenCombineRecruiterMenu”, “Combine” );
end
*/
[/lua]

Shared.lua
[lua]
ENT.Base = “base_ai”
ENT.Type = “ai”

ENT.PrintName = “My NPC”
ENT.Author = “Crap-Head”
ENT.Contact = “www.derp.net” //fill in these if you want it to be in the spawn menu
ENT.Purpose = “”
ENT.Instructions = “”

ENT.AutomaticFrameAdvance = true

VoiceListM = {
Sound(“vo/npc/male01/answer30.wav”),
Sound(“vo/npc/male01/hi01.wav”),
Sound(“vo/npc/male01/hi02.wav”),
Sound(“vo/npc/male01/question06.wav”),
Sound(“vo/npc/male01/question29.wav”),
}

function ENT:Use( ply, caller )
self:EmitSound(table.Random(VoiceListM))
ply:SendLua(“weapon_npc()”)
end

function ENT:AcceptInput( input, activator, caller )
if not timerforbox then
timerforbox = true timer.Simple( 1, function() timerforbox = false end )
if input == “Use” && activator:IsPlayer() then
caller:SendLua( “weapon_npc()” )
end
end
end
[/lua]

Soooooo, where are you actually trying to remove the NPC?

Well what the NPC button does it that it activates a horde of zombies. And the zombies attacks the NPC. So i figured the smartes way of “fixing” this problem would be to remove the NPC when the button is pressed.

Put if SERVER infront of this or put it into the init.lua



function ENT:Use( ply, caller )
    self:EmitSound(table.Random(VoiceListM))
    ply:SendLua("weapon_npc()")
end
 
function ENT:AcceptInput( input, activator, caller )
if not timerforbox then
timerforbox = true timer.Simple( 1, function() timerforbox = false end )
if input == "Use" && activator:IsPlayer() then
caller:SendLua( "weapon_npc()" )
end
end
end


I dont think you get it. 1. I already have this in my shared.lua file, why shuld i add it to the init.lua file then?

What i want is that when i press the button in my NPC VGUI, the npc disapears.

Edit:
Solved. Thanks to zzaacckk

snip

He added to me on steam and I helped him there, he probally thought the c’s in my name were a’s.

                                                             (-_-)

Wait what?

As Zack said:

I added him on Steam. Then i went on and modified my post to that. I forgot to add the c after the ).

I also dont see how i was insulting you. Calling you As? What is that even. I dont see how it was even insulting you. Anyways its solved now. Sorry if you missunderstod what i ment.

I believe he thinks you are calling him an asshole, but really you were just stating the fact that zack has like 100000 A’s in his name.

I have two a’s in my name o.O