Garry's Mod

Garry's Mod

[CTOOLS] NPC Spawner
 This topic has been pinned, so it's probably important
Ѫ  [developer] Jul 7, 2021 @ 5:44am
FAQ
- How do I use this tool?
Press Left Mouse Button to start creating an area where NPCs will be spawned.
Press the button to confirm the area. Now you can change the angle NPCs will be spawned at.
Left click again to confirm the angle.

Now, when your area is completely ready, you can press Right Mouse Button to spawn NPCs.
You can place infinite amount of areas before you do this.
For example, you can made one area of hostile NPCs and another one of friendly NPCs, and then spawn them at once so they appear evenly across the map.

For your convenience, spread and random parameters were bound to the Mouse Wheel.
When creating area, use Up and Down Mouse Wheel to change the spread multiplier. It will increase or decrease the size of the grid.
Or hold the Shift Key to change randomness of NPC spawn instead.


- When I use this tool, my server lags and crashes, help
Garry's Mod runs on 17 years old engine, obviously you don't want to spawn millions of NPCs.
Just try spawning 50 citizen NPCs the normal way and see how low your FPS becomes.
This tool is not for fun, it just makes the gmod experience better.


- NPCs that I'm trying to spawn throw serverside errors or don't work...
Some of the workshop NPC addons are poorly coded. There's no way to make the tool work with them.
NPCs should be actually NPCs or NextBots (i.e. pass npc:IsNPC() or npc:IsNextBot()) check).
SNPCs, VJBase and similar NPCs will work just fine.


- What are spawn flags? How do I use them?
Spawn flags adjust NPC behaviour, they are hardcoded in engine and supposed to be used by developers only. Use them only if you know how they work.
Note that some of these flags are necessary for some NPCs and will be forced anyway.
Some flags will not work for some NPCs.


- What if the area I created partially in the wall? Will it spawn NPCs in that wall?
No, it will ignore places where NPC spawn is impossible.
It's safe to use the tool everywhere, there's no need to avoid twisted corridors.


- Can I dupe or save created areas?
No, there's no data or entities to save or to be duped.
Spawn areas exist only in memory, therefore you can't use this tool with default gmod duplicator, AdvDupe, PermaProp or saves.


- What is Custom Squad and how do I use it?
All NPCs in games powered by Source Engine can be assigned to squads.
Squads allow you to group NPCs for their further cooperation.
Members of squad cover each other, move together, share information, and take turns at attacking their enemies.

In Garry's Mod most NPCs are being assigned to specific squads when spawning by default.
For example most of the combine NPCs will be assigned to squad called "overwatch".
Whereas Nova Prospekt guards and shotgunners will have their own squad - "novaprospekt".

If you don't specify custom squad, all NPCs you spawn with the tool will be assigned to their default squads.
For instance, if you place two groups of the NPCs in different map areas, and warn one of these group, the other one will know about your presence.
You should consider that when creating long battles or events.

For more details visit Official Valve Wiki.
Last edited by Ѫ; Jul 15, 2021 @ 7:52am
< >
Showing 1-9 of 9 comments
Halberd Jul 27, 2021 @ 2:15pm 
on the thumbnail are those reskins of magnusson and kliener or is it just photoshop
TappyOka Jul 31, 2021 @ 12:19pm 
Can someone tell me what this LUA error implicates? The addon works fine, but this message keeps on popping up.

[[CTOOLS] NPC Spawner] lua/weapons/gmod_tool/stools/ctools_npc.lua:887: bad argument #1 to 'pairs' (table expected, got nil)
1. pairs - [C]:-1
2. UpdateData - lua/weapons/gmod_tool/stools/ctools_npc.lua:887
3. func - lua/weapons/gmod_tool/stools/ctools_npc.lua:997
4. FillViaFunction - gamemodes/sandbox/gamemode/spawnmenu/controlpanel.lua:100
5. FillViaTable - gamemodes/sandbox/gamemode/spawnmenu/controlpanel.lua:89
6. ActivateTool - lua/includes/modules/spawnmenu.lua:287
7. Open - gamemodes/sandbox/gamemode/spawnmenu/spawnmenu.lua:118
8. Run - gamemodes/sandbox/gamemode/spawnmenu/spawnmenu.lua:253
9. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:11
10. unknown - lua/includes/modules/concommand.lua:54
Halberd Oct 2, 2021 @ 9:32pm 
Post the errors on the "bugs" discussion idiot
Dr. Unusual Oct 20, 2021 @ 8:17pm 
Originally posted by ACA The Comedy Coomer:
Post the errors on the "bugs" discussion idiot
That was completely uncalled for
selest19 Jan 31, 2022 @ 3:39pm 
any idea how to use custom models there are no yt videos on it and the small thing is no help
geckos in tanks Nov 18, 2022 @ 7:56am 
how to use custom models.

mke sure model is compatable as npc.
1. left click and copy model to clipboard
2. paste in custom model.
3. click of box.
4. if it works the npc should be a custom model if not the npc will spawn as a selected npc.

rinse and reapeat if anything gos wrong.
Elisol28 May 2, 2023 @ 12:21pm 
How can I make them follow me and try to attack me?
noketheking Nov 5, 2023 @ 5:51pm 
is there something im missing nothing happens after i set the area and right click.
noketheking Nov 5, 2023 @ 7:10pm 
Originally posted by noketheking:
is there something im missing nothing happens after i set the area and right click.
holy crap its like making that comment allowed it to work wtf
< >
Showing 1-9 of 9 comments
Per page: 1530 50