Starting an SNPC: Basic Coding example Fails

I’m trying to learn how to script an snpc, given I’ve failed to find anyone willing or able to apply to the task.

I decided I’d at least get some momentum going by trying the basic, bare-bones code for an snpc provided here:

I pasted the code into the three separate lua files inside a folder I named for the snpc, as directed. The page says that to spawn it, I need only type “ent_create” space, and then the folder name to make it. All I receive in return is the message “attempted to create unknown entity type.” I ensured to put the folder and files in both the username and common gmod folders to be sure, but nothing happens.

I suspect the code is out of date somehow, but I would never know, nor how to fix it. I planned to start with the basic code, and then tweak, modify the code as I go and fan-out from there, but without something that works to start with, I’m truly alone, and the information to do this is all but nonexistent.

And I would start with someone else’s snpc code, but gmod13 addons are all encrypted, and even if I could I don’t want to be accused of stealing someone’s code.

Can anyone help, or at least point me in a suitable direction?

Forget about SNPCs, they are broken and probably won’t be fixed. Also, forget old wiki and its tutorials.


You can try using NextBot for your custom NPCs, but it is unfinished.

There are several working snpcs right now. I don’t think the whole thing is irreparably broken.

All the same, what is NextBox, and how does it make npc’s work?

Doesn’t necessarily have to be broken entirely, could as well be deprecated in a patch because it’s functionality is being torn apart anyhow.

NextBot* it is the new way of creating NPCs, used in L4D and TF2.

Isn’t nextbot in some need of work before it becomes somewhat useable?

It is usable, but it is unfinished, yeah.

Well if I can make any progress with it, I will. I’m just tired of feeling like I have no control over my own destiny when it comes to coding my npc’s. I model them, I texture them, I animate them, I compile them, I make particles for them and then I have to wait for someone ELSE to gather the will to take the final steps.

The “if you want something done, do it yourself” mantra has served me well in the past, so taking the bull by the horns here is all I can think of at this point.

Wait, what happened to SNPCs now?

Are you kidding me?! So you’re telling me all this work I have put on this are going to go for nothing:

Seriously don’t do this -_-

Eh, now I’m confused.

So I put the base_nextbot folder and files in the entities folder, and made a folder inside that folder for my own npcs.

I copied the shared.lua file into the new folder, then copied the mossman npc code and named it sv_nextbot.lua, saved in the new npc’s folder.

I changed the mdl path, swapped out the sequence names and got rid of the extraneous crap that wasn’t applicable.

That didn’t spawn, so I cut and pasted the npc folder from the base_nextbot folder to the entities folder. Now it spawns, but just as an error model that bleeds when shot…

I changed out the information at the bottom of the files too.

Damnit, I need to see an example of the file structure for this…

[editline]27th September 2013[/editline]

Don’t worry, I’m just attacking this from as many angles as possible. I’m not counting anyone out.

tf2_ghost nextbot entity ( somewhere in sandbox or base ) should be enough to understand the basics. I am not sure if using custom animations is for NPCs is possible though. You can play sequences, that correct, but gestures/postures for NPCs?

@vrej, don’t confuse reskins with SNPCs. All I know that Garry was planning to phase out the old way to create SNPCs and replace it with NextBots.