I have the NPC spawning, unable to move, or take damage. Now I need to set it up so useing the NPC (push e) opens a derma menu, but I can’t seem to figure out how to do that. Every tutorial that I have found so far regarding NPC shops is i suspect outdated.
This is my code so far in init:
if SERVER then
CarDealer = ents.Create(“npc_citizen”)
CarDealer:SetPos(Vector(-3491, -6450, 380))
CarDealer:SetAngles(Angle(0, -133, 0))
CarDealer.Base = “base_ai” – This entity is based on “base_ai”
CarDealer.Type = “ai” – What type of entity is it, in this case, it’s an AI.
CarDealer.AutomaticFrameAdvance = true – This entity will animate itself.
CarDealer:SetModel( "models/breen.mdl" ) -- Sets the model of the NPC. CarDealer:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things. CarDealer:SetHullSizeNormal( ) CarDealer:SetNPCState( NPC_STATE_SCRIPT ) CarDealer:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions. CarDealer:CapabilitiesRemove(CAP_MOVE_GROUND) CarDealer:CapabilitiesAdd( CAP_ANIMATEDFACE, CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ). CarDealer:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use. CarDealer:DropToFloor()
function ENTITY:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then umsg.Start("ChangeClass", Caller) -- Prepare the usermessage to that same player to open the menu on his side. umsg.End() -- We don't need any content in the usermessage so we're sending it empty now. end
With this code I get this error:
attempt to index global ‘ENTITY’ (a nil value)
If you know what my problem is, please let me know.