Help. Npc Spawn.

Why doesn’t this work?

[lua] function GM.CreateNPC ( Class, Location, Angles, Model )
for k, v in pairs(ents.FindInSphere(Location, 128)) do
if v:GetModel() == Model then
return false;

local NewNPC = ents.Create(Class);

local Bubble = ents.Create('ent_quest_bubble');
Bubble:SetNetworkedEntity('ChaseEntity', NewNPC);
Bubble:SetPos(NewNPC:GetPos() + Vector(0, 0, 64));
return NewNPC, Bubble;


function GM.CreateNPCs ( )

local GAMEMODE.CreateNPC('npc_citizen', Vector(-1518.750000, 300.468750, 48.031250), Angle(0, -180, 0), 'models/humans/group01/male_04.mdl');
local GAMEMODE.CreateNPC('npc_citizen', Vector(-1518.750000, 205.875000, 48.031250), Angle(0, -180, 0), 'models/humans/group01/male_04.mdl');
local GAMEMODE.CreateNPC('npc_citizen', Vector(-2175.687500, 153.218750, 228.312500), Angle(0, 90, 0), 'models/humans/group01/male_04.mdl');
local GAMEMODE.CreateNPC('npc_citizen', Vector(-1518.750000, 110.875000, 48.031250), Angle(0, -180, 0), 'models/humans/group01/male_04.mdl');


RunConsoleCommand(‘ai_disable’, ‘0’);
RunConsoleCommand(‘ai_disabled’, ‘0’);
timer.Simple(10, RunConsoleCommand, ‘ai_disable’, ‘1’)
timer.Simple(10, RunConsoleCommand, ‘ai_disabled’, ‘1’)[/lua]

(User was banned for this post ("Wrong forum" - mahalis))

you have local before all of your function calls from what I can see. Give us errors.

Possibly because you nicked the code from PERP?

Everyone learns somehow

Anyhow, I think you need to hook the function GM.CreateNPCs to InitPostEntity.

Ugh. I don’t understand why I was banned for that. How about next time you reply and tell me where the correct section is? That would most likely keep me from making this mistake again. Just banning me doesn’t solve anything. But anyways. Yes it is from the perp gamemode but all it does is spawn an npc, its not that big of a deal. I will go try hooking GM.CreatNPCs to InitPostEntity.

I now see why I was banned. Don’t know how it got in requests. My bad. Sorry for misunderstanding.

The irony is, mahalis put it in the wrong section. :v:
Why did you put ‘local’ infront of the function calls?

Wait. He put it here? I was wondering how it got here. It was originally in Lua Scriping and that’s what I thought was the right section but I guess its not. Whatever I’m over it. Does the local not need to be there? If I take it out will that solve my problem? I’m noobish at lua.


The Hook didn’t work. No errors or anything.

use print at each part of the code to see what is getting ran and what is not getting ran

Haha, whoops, didn’t notice that. Fixed.

The ban was temporary; it’s how we warn people for breaking the rules. Sorry for the “Requests” confusion—this definitely did belong in Newbie Questions.

Thought it was!


Actually i didn’t see the class, i skimmed threw it.