'Make Persistent' doesn't keep things there forever.

Here’s the deal, on my server I have an area on the map where people spawn their cars, i’ve placed red markers on the ground to signify that area as where the cars spawn, and I used the C menu to make them persistent, it works good, they’ve stayed there throughout numerous server restarts, but the NPC stays for only a few restarts but then disappears after a while and an admin has to spawn him in again, it can get quite frustrating. How would I get it to stay there 100% of the time?

Image shows what I have set up.

anyone know how to fix this? In need of urgent help :stuck_out_tongue:

The in-built persistence tool is shockingly shit, you’d be better off coding a spawning script that runs on map load or something.

Here’s some code to spawn an entity/npc.

--Can get these from typing getpos in the in-game console
--Go to the exact spot where you want the NPC to spawn, and type getpos in console
--It should come out something like this, these numbers will NOT be the same as yours, just an example: setpos 1800.205811 -366.727844 538.742249;setang 15.276489 -171.738510 0.000000
--Breaking those numbers down it should be like this:
--npcposi = Vector(1800, -367, 538)
--npcang = Vector(15.276489, -171.738510, 0)
npcposi = Vector(x, y, z)
npcang = Vector(x, y, z)

entNpcShop = "npc_shop" -- The NPC's/Entities file.

function SpawnNpc()
	local shop = ents.Create(entNpcShop)
		shop:SetPos( npcposi )
		shop:SetAngles( npcang )
hook.Add("InitPostEntity", "SpawnNpc", SpawnNpc)

//Make it so the spawned npc isn't killable
hook.Add("EntityTakeDamage", "PReventNPCfromdying", function( target, dmginfo )
	if target:IsNPC() and target:GetClass() == entNpcShop then

Where would I place that? Create an addon folder or insert it into existing code?

The problem with the persistence is that it sometimes spawns the NPCs underground.

You need to make a file with any name ex: somename.lua and paste that code into somename.lua and then drag that lua file into garrysmod/lua/autorun/server. So it spawns it right on startup.

It wont do that due to this -

I meant GMods “Make Persistent” option, not your code.

If your trying to make your NPC Car Dealer from Rocketmania permanent just write

D3DCarDealer_Save in console. This will save all Car Dealer’s :smiley:

Thanks, this works, the only problem is that I accidentally spawned 2. Do you know if there’s a command to remove them? or where the info is kept?

I’ve checked the 3DCarDealer_MapSaver.lua file, but I can’t find anything.

[editline]28th January 2014[/editline]

Nevermind, I found it :slight_smile: