ENT:Function not working on client


ErrorNoHalt(“DEBUG POINT 1”);

ENT.Type = “ai”;
ENT.Base = “base_ai”;
ENT.AutomaticFrameAdvance = true;

function ENT:SetAutomaticFrameAdvance( bUsingAnim )
self.AutomaticFrameAdvance = bUsingAnim;

function ENT:SetID( str )
self.NPCID = str;
self:SetNWString(“NPCID”, str );

function ENT:GetID() – attempt to call method ‘GetID’ (a nil value)
if SERVER then
return self.NPCID;
return self:GetNWString(“NPCID”);

There you go, my shared.lua code. For that debug point does print in my console in yellow and blue(client and server) yet when I run this client side:
[lua]for k, v in pairs(ents.FindByClass(“npc_*”))do

It gives me this error: attempt to call method ‘GetID’ (a nil value)

I don’t get it.

ents.FindByClass(“npc_*”) calls GetID on every NPC in the map, not just your SNPCs.

GetID function doesn’t exist in the default NPCs, thus giving the error.

Wait, did Garry add clientside support for SNPCs, at last? Because scripted NPCs used not to have a clientside part, anything in cl_init would not be executed at all.

Alright first of all there are no other NPC’s and it DOES work server side so it’s not this.

Hmm, this could be it, though why would SNPC’s not have a client side part?

if v.GetID then print(v:GetID()) end

Or the above problem.

Because it’s Garry.
Answers pretty much everything. Try defining ENT:Initialize clientside so it prints a message to the console, then spawn your SNPC. If Garry didn’t change anything since he added scripted NPCs, then nothing should appear in the console.

Nothing appeared, I guess I’ll have to use the Networked variables then.