Hello, I would like to make it so every so often (half an hour for example) around 25 zombies spawn in set locations, and when all of the zombies are dead, it says so in the chat.
I was thinking a good way to do this would be by using ulx.
ULX is an admin mod, not an all-in-one developer solution.
You will have to code this from scratch.
[QUOTE=Robotboy655;48638990]ULX is an admin mod, not an all-in-one developer solution.
You will have to code this from scratch.[/QUOTE]
ok, where is the best place to start? (Thankyou so much with your help with the weapon switching script btw.)
I really don't see why ULX is needed for this. Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Create]timer.Create[/url] to make a timer set to 1800 seconds and spawn the zombies within the function. Create another timer set to something like 1 second and check the number of zombie entities found using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url]. If the number of entities found is 0, then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintMessage]Global.PrintMessage[/url] to send a message to everyone and remove the timer. You could also add an [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM/EntityTakeDamage[/url] hook and check if its health is at or below zero, and then do the same check. This would probably be better performance-wise.
[QUOTE=AK to Spray;48639058]I really don't see why ULX is needed for this. Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Create]timer.Create[/url] to make a timer set to 1800 seconds and spawn the zombies within the function. Create another timer set to something like 1 second and check the number of zombie entities found using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url]. If the number of entities found is 0, then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintMessage]Global.PrintMessage[/url] to send a message to everyone and remove the timer. You could also add an [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM/EntityTakeDamage[/url] hook and check if its health is at or below zero, and then do the same check. This would probably be better performance-wise.[/QUOTE]
For the timer, how many times would I need to repeat it?
I don't know, that's up to you. How many times do you want them to spawn?
[QUOTE=AK to Spray;48639202]I don't know, that's up to you. How many times do you want them to spawn?[/QUOTE]
so is it how many times the function is ran per 30 mins?
[QUOTE=Mattymoo14211;48639228]so is it how many times the function is ran per 30 mins?[/QUOTE]
No, it's how many times the function is repeated.
ok, this is what ive came up with:
[code]
local zombieAmount = 0
hook.Add("Initialize", "Started", function()
timer.Create( "spawn", 10, 1, spawn )
timer.Create( "message", 10, 1, message )
timer.Create( "amount", 1, 0, amount )
end)
function spawn()
local spawn = table.Random( ents.FindByClass( "info_npc_spawnpoint" ) )
local zombie = ents.Create( "npc_zombie" )
zombie:SetPos( spawn:GetPos() )
zombie:Spawn()
end
function amount()
for k,ent in pairs( ents.FindByClass("npc_zombie") )do
zombieAmount = zombieAmount+1
end
if(zombieAmount == 0)then
PrintMessage( HUD_PRINTTALK, "|M00| The Zombie Round Has Ended. All Zombies Have Been Killed!" )
zombieAmount = 0
timer.Stop( "amount" )
end
end
function message()
PrintMessage( HUD_PRINTTALK, "|M00| A Zombie Round Has Begun! Run!" )
end
[/code]
I set it to 10 just to test
Sorry, you need to Log In to post a reply to this thread.