I while ago there was a thread there a guy asked how you made a npc like in perp there you press USE and it will popup a derma menu. Well ive been looking for that thread and searched for it but i cant find it. Can someone please give me a link or help me with this.

I think that is what you are looking for.

eh no it was anouther, there a guy posted the code.

If I understand correctly what you want,
hook.Add( “PlayerUse”, “FindNPC”, function( ply )
local AimE = ply:GetEyeTraceNoCursor().Entity
local trace = ply:GetEyeTrace()

if AimE:IsNPC() and trace.HitPos:Distance(ply:GetShootPos()) <= 75 then – Is the AimEntity is an npc and the distance is under 75
if Aime:GetClass()==“npc_gman” then – If the npc is GMan
– Do shiiiit

smilar but im talking about a scripted npc not a normal npc

Oh sorry, Missed that :gbsmith:

make a scripted npc and replace the npc_gman with it…

Why are you speaking swedish to him? Speak English, Doesent matter if your both are swedish, People might have to look at old posts later on to find some answears.

well the thing i wounder is how to remove the ai.

[lua]self.Entity:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD )[/lua]That will make this entity only able to have an animated face, and be able to turn his head, not be able to physcially move or anything.
The code stated above would go in init.lua under a function
[lua] function ENT:Initialize( )[/lua]

There are however ( some more I know ):


Thank you, That will come very handy. :haw:

Pretty simple, to remove the AI. Just… remove it.

Yeah but he wants to know how, but it would be bad without AI, so i just gave him a bit of code to make it so the entity has an animated face and can turn it’s head, but not be able to move around or kill people.

thank you

No probs :smiley:

ok i got a problem now…
I dont know why it wont work since im basicly using the exacly same script for ENT:Use like in my ATM entity…
Please help
NOTE: i know that job_police dont work, but even if it doesnt exist you should get a text in the console “command job_police doesnt exist” something like that

It’s not Ent:Use, It’s AcceptInPut.


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 
	    	    -- Do shit 

The timer is made by Sintwins.

It is to prevent it being opened more than once every second.

Dont ask.

so i would be

function ENT:AcceptInput( name, activator, caller, data )
    if (name == "use") then -- Or should it be USE?
        if ( caller:IsPlayer() ) then
            print( caller:Nick() )
            print( caller:GetClass() )


nvm fixed it