Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(SERVER)
- then
- local _Spawns = {};
- concommand.Add("zombie_addspawn", function(ply, cmd, args, argstr)
- if(!ply:IsAdmin())
- then
- return;
- end
- if(#args == 0)
- then
- ply:ChatPrint("usage: zombie_addspawn <identifier> <maxzombies>");
- return;
- end
- if(#args != 2)
- then
- ply:ChatPrint("failed");
- return;
- end
- _Spawns[args[1]] = {
- ["pos"] = ply:GetPos(),
- ["maxzombies"] = tonumber(args[2]);
- };
- end);
- concommand.Add("zombie_removespawn", function(ply, cmd, args, argstr)
- if(!ply:IsAdmin())
- then
- return;
- end
- if(#args == 0)
- then
- ply:ChatPrint("usage: zombie_removespawn <identifier>");
- return;
- end
- if(#args != 1)
- then
- ply:ChatPrint("failed");
- return;
- end
- if(_Spawns[args[1]] == nil)
- then
- ply:ChatPrint("no such spawner");
- return;
- end
- _Spawns[args[1]] = nil;
- ply:ChatPrint("successfully removed");
- end);
- concommand.Add("zombie_gotospawn", function(ply, cmd, args, argstr)
- if(!ply:IsAdmin())
- then
- return;
- end
- if(#args == 0)
- then
- ply:ChatPrint("usage: zombie_gotospawn <identifier>");
- return;
- end
- if(!_Spawns[args[1]])
- then
- return;
- end
- ply:SetPos(_Spawns[args[1]]["pos"]);
- end);
- concommand.Add("zombie_listspawns", function(ply, cmd, args, argstr)
- if(!ply:IsAdmin())
- then
- return;
- end
- for k,v in next, _Spawns do
- ply:ChatPrint(string.format("%s = %d (%f, %f, %f)", k, v["maxzombies"], v["pos"].x, v["pos"].y, v["pos"].z));
- end
- end);
- hook.Add("Think", "zombiem3n", function()
- for k,v in next, _Spawns do
- if(v["zombies"] == nil)
- then
- v["zombies"] = {};
- end
- if(v["curzombies"] == nil)
- then
- v["curzombies"] = 0;
- end
- if(v["curzombies"] > 0)
- then
- local idx = 1;
- while(true)
- do
- if(idx > v["curzombies"])
- then
- break;
- end
- if(v["zombies"][idx] == nil)
- then
- print(idx);
- break;
- end
- if(!v["zombies"][idx]:IsValid())
- then
- table.remove(v["zombies"], idx);
- v["curzombies"] = v["curzombies"] - 1;
- else
- idx = idx + 1;
- end
- end
- end
- while(v["curzombies"] < v["maxzombies"])
- do
- local newzombie = ents.Create("npc_zombie");
- newzombie:SetPos(v["pos"] + Vector(math.random(-200, 200), math.random(-200, 200), 0));
- newzombie:Spawn();
- v["zombies"][v["curzombies"] + 1] = newzombie;
- v["curzombies"] = v["curzombies"] + 1;
- print(v["curzombies"]);
- end
- end
- end);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement