NPC Help

I am making a NPC script just for the knowledge of working with them but I cant even get one in the spawnmenu. Here is what I got, please tell me what I am doing wrong.

SHARED :



ENT.Base = "base_ai" 
ENT.Type = "ai"

ENT.PrintName = "Simple NPC"
ENT.Contact = "N/A"
ENT.Author = "Zero"
ENT.Category = "Zero"
ENT.Spawnable = true



SERVER :




AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()
	self:SetModel("models/Humans/Group01/Female_01.mdl")

	self:SetHullType(HULL_HUMAN)
	self:SetHullSizeNormal()

	self:SetSolid(SOLID_BBOX)
	self:SetMoveType(MOVETYPE_STEP)

	self:CapabilitiesAdd(CAP_ANIMATEDFACE | CAP_TURN_HEAD)

	self:SetMaxYawSpeed(900)
end

function ENT:OnTakeDamage(dmg)
	return false
end

list.Set("NPC", "npc_simplenpc", {
	Name = "simplenpc",
	Class = "npc_simplenpc",
	Category = "Zero"
})



CLIENT :




include("shared.lua")

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

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



You must include an

ENT:SpawnFunction. From the wiki:

I added this to init.lua and still nothing :




function ENT:SpawnFunction(ply, tr, ClassName)
	if (!tr.Hit) then return end

	local SpawnPos = tr.HitPos

	local ent = ents.Create(ClassName)
	ent:SetPos(SpawnPos)
	ent:Spawn()

	return ent
end



[editline]19th August 2017[/editline]

Anyone know whats going on?

Try add


AddCSLuaFile()

to the top of the server code. Keep it blank btw.

It doesn’t work + it shouldnt be necessary since server already adds itself. Here is the code I got right now :

SERVER :




AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile()

include("shared.lua")
 
function ENT:Initialize()
 
	self:SetModel("models/player/barney.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)

    local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
end

function ENT:Use( activator, caller )
    return
end

function ENT:SpawnFunction( ply, tr, ClassName )
	if ( !tr.Hit ) then return end
	local SpawnPos = tr.HitPos + tr.HitNormal * 16

	if ClassName == "npc_supplydealer" then
		local ent = ents.Create( ClassName )
		ent:SetPos( SpawnPos )
		ent:SetBallSize( math.random( 16, 48 ) )
		ent:Spawn()
		ent:Activate()
	end

	return ent
end

list.Set("NPC", "npc_supplydealer", {   
	Name = "SupplyRun Dealer",
    Class = "npc_citizen",
    Category = "Zero's Customs"
} )



CLIENT :




include('shared.lua')

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



SHARED :




ENT.Type = "ai"
ENT.Base = "base_ai"
 
ENT.PrintName		= "Supply Dealer"
ENT.Author			= "ZeroToHero"
ENT.Contact			= "N/A"
ENT.Purpose			= "N/A"
ENT.Instructions	= "Place on map."



I don’t really know what you have it as, but I have my NPC code all in one file in a entities folder (well, a nextbot as an npc because i first wanted a nextbot but I quickly changed my mind after I made it). So I used this page: https://wiki.garrysmod.com/page/NextBot_NPC_Creation to create my npc.