NPC.SetSchedule Help

I’m here to try and get some help for this autospawning zombie script that I had help with from a very generous coder. Now, when they do spawn, if the first one what spawns doesn’t move, they all just pile up, and I can’t have that happening. I’ve been trying for a couple of hours and I don’t know where to put in the scheduling part of this. Here’s the code for reference.

[lua]local ZombieSpawnPoints = {

{ pos = Vector( -10744.872070, 8951.499023, 136.031250 ) },
{ pos = Vector( -10671.409180, 9722.273438, 136.031250 ) },
{ pos = Vector( -9019.874023, 8754.477539, 128.031250 ) },
{ pos = Vector( -10525.385742, -11364.360352, 136.031250 ) },
{ pos = Vector( -9344.120117, -10792.025391, 127.828804 ) },
{ pos = Vector( -8668.760742, -10292.094727, 135.006775 ) },
{ pos = Vector( -7363.602539, -7339.875977, 128.031250 ) },
{ pos = Vector( -4705.851074, -7847.590820, 262.033264 ) },
{ pos = Vector( -6496.672852, -3888.437744, 148.592010 ) },
{ pos = Vector( -5438.900391, -1099.490356, 128.027985 ) },
{ pos = Vector( -4808.946289, -10256.173828, 135.031250 ) },
{ pos = Vector( -6024.448242, -12261.543945, 128.031250 ) },
{ pos = Vector( -10629.346680, -8324.891602, 170.011566 ) },
{ pos = Vector( -4697.293945, -6.734045, 128.031250 ) },
{ pos = Vector( -5287.481445, 5395.063965, 128.031250 ) },
{ pos = Vector( -4601.694824, 5752.813477, 128.031250 ) },
{ pos = Vector( -7367.076172, 9825.666992, 206.936783 ) },
{ pos = Vector( -8983.132813, 11101.219727, 240.258240 ) },
{ pos = Vector( -4042.954590, 11567.081055, 258.047913 ) },
{ pos = Vector( -5252.113281, 11872.506836, 250.031250 ) },
{ pos = Vector( -4957.943359, 13282.789063, 249.031250 ) },
{ pos = Vector( -3940.979004, 14401.643555, 248.550797 ) },
{ pos = Vector( 359.749634, 13805.194336, 122.031250 ) },
{ pos = Vector( -674.387878, 12225.866211, 122.031250 ) },
{ pos = Vector( 847.220947, 10375.753906, 122.018135 ) },
{ pos = Vector( 2020.200928, 12784.795898, 122.031273 ) },
{ pos = Vector( 5498.430664, 13920.290039, 122.031349 ) },
{ pos = Vector( 5223.707520, 10597.159180, 122.031250 ) },
{ pos = Vector( 4265.402832, 10473.123047, 122.031250 ) },
{ pos = Vector( 7325.107422, 14362.240234, 185.261200 ) },
{ pos = Vector( 10931.510742, 14041.108398, 122.031250 ) },
{ pos = Vector( 10881.585938, 12195.123047, 125.113838 ) },
{ pos = Vector( 12383.601563, 11797.403320, 122.586052 ) },
{ pos = Vector( 11624.010742, 5024.910156, 131.365875 ) },
{ pos = Vector( 9419.469727, 634.370483, 128.031357 ) },
{ pos = Vector( 8868.433594, 4303.809570, 64.031250 ) },
{ pos = Vector( 7847.248535, 4626.837402, 64.031250 ) },
{ pos = Vector( 7866.190918, 3310.748535, 64.031250 ) },
{ pos = Vector( 7407.499023, -441.250977, 128.031281 ) },
{ pos = Vector( 7335.855469, -2644.238281, 128.031250 ) },
{ pos = Vector( 7022.260742, -5025.056152, 128.031250 ) },
{ pos = Vector( 5556.009766, -4861.709961, 128.031250 ) },
{ pos = Vector( 4722.947754, -4986.496582, 128.031250 ) },
{ pos = Vector( 3543.002197, -6059.511719, 128.031250 ) },
{ pos = Vector( 3558.877686, -7774.449707, 127.873993 ) },
{ pos = Vector( 7179.776367, -8012.080078, 109.283813 ) },
{ pos = Vector( 1802.303345, -6851.392090, 128.031250 ) },
{ pos = Vector( 512.110107, -5961.122559, 128.031250 ) },
{ pos = Vector( 107.772507, -7814.345703, 136.877090 ) },
{ pos = Vector( -902.306030, -6846.757813, 129.899963 ) },
{ pos = Vector( -1267.881104, -5061.627930, 128.031250 ) },
{ pos = Vector( -448.651672, -1127.587769, 128.391983 ) },
{ pos = Vector( -244.592392, 157.994919, 128.027252 ) },
{ pos = Vector( -297.427307, 3914.629639, 136.031250 ) },
{ pos = Vector( -3296.932129, 8297.083008, 136.031250 ) },
{ pos = Vector( -1963.483154, 4323.812988, 128.031250 ) },
{ pos = Vector( -13.486003, 8539.492188, 131.125885 ) },
{ pos = Vector( 4888.431641, 8316.515625, 128.062988 ) },
{ pos = Vector( 4389.923340, 5462.475586, 132.031250 ) },
{ pos = Vector( 855.787170, 5241.153320, 132.031250 ) },
{ pos = Vector( 2742.306396, 3644.110596, 132.031250 ) },

}

local numZombies = 0
local maxZombies = 10000

function ZombieSpawns()

 timer.Create( "Respawner", 20, 99999999999, function()

    if ( numZombies < maxZombies ) then

        for k, v in pairs( ZombieSpawnPoints ) do

                local zombie = ents.Create( "npc_zombie" )
                zombie:SetPos( v.pos )
                zombie:Spawn()
                zombie:Activate()

                numZombies = numZombies + 1

        end

    end

end )

end

function NPC:SetLastPosition( vector )
NPC:SetSchedule( SCHED_MOVE_AWAY )
end
hook.Add( “InitPostEntity”, “StartZombieSpawning”, ZombieSpawns )
[/lua]

I wanted to have this schedule set in it, [lua]NPC:SetSchedule( SCHED_MOVE_AWAY )[/lua]

I need the NPC moving from where it spawns that way it doesn’t cause them to all spawn inside themselves.

Why not make it so zombies don’t collide with other zombies using the ShouldCollide hook?

You can use it below zombie:Activate() so like this:
[lua]
local zombie = ents.Create( “npc_zombie” )
zombie:SetPos( v.pos )
zombie:Spawn()
zombie:Activate()

zombie:SetLastPosition( v.pos )
zombie:SetSchedule( SCHED_MOVE_AWAY )
[/lua]
But I’d go with what Chessnut said.

[editline]21st May 2014[/editline]

[lua]
hook.Add( “ShouldCollide”, “ZombieNoCollide”, function( ent1, ent2 )

if ( ent1:GetClass() == "npc_zombie" and ent2:GetClass() == "npc_zombie" ) then

    return false

end

end )
[/lua]

[editline]21st May 2014[/editline]

Also if you want to use ShouldCollide I recommend adding the following code below zombie:SetPos( v.pos ):
[lua]
zombie:SetCustomCollisionCheck( true )
[/lua]

Thank you both so much for your help on this! This will really help speedup the project I’m working on.