Waves of melons.

Hey im having some trouble with this code what i want it to do is.

  • Spawn melons in waves
  • Each wave the number of melons increase
  • That about it.

so shouldnt this work?
[lua]function Wave1()
local wtfbbq = ents.Create (“melonhound”)
local melonz = ents.FindByClass(“melonhound”)
wtfbbq:SetPos(Vector(-663.183899, 361.502594, 69.248375))
wtfbbq:SetPos(Vector(283.170044, 2528.408936, 160.031250))
wtfbbq:SetPos(Vector(-1927.218994, 2670.492676, 96.031250))
wtfbbq:SetPos(Vector(-1264.542236, -398.132141, 194.282822))
wtfbbq:Spawn()
if #melonz >= 40 then
timer.Stop(“MelonRaid1”)
else
HUD_PRINTCENTER(“Teh Melonz are coming!”)
timer.Start(“MelonRaid1”)
end
end

function Wave2()
local wtfbbq = ents.Create (“melonhound”)
local melonz = ents.FindByClass(“melonhound”)
wtfbbq:SetPos(Vector(-663.183899, 361.502594, 69.248375))
wtfbbq:SetPos(Vector(283.170044, 2528.408936, 160.031250))
wtfbbq:SetPos(Vector(-1927.218994, 2670.492676, 96.031250))
wtfbbq:SetPos(Vector(-1264.542236, -398.132141, 194.282822))
wtfbbq:Spawn()
if #melonz >= 80 then
timer.Stop(“MelonRaid2”)
else
HUD_PRINTCENTER(“Teh Melonz are coming!”)
timer.Start(“MelonRaid1”)
end
end

timer.Create( “MelonRaid1”, 1, 0, Wave1)
timer.Create( “MelonRaid2”, 1, 0, Wave2)[/lua]

nazi zombies with mellons :smiley:

  • You’re setting the melon pos 4 times for no apparent reason
  • Only spawning one melon
  • HUD_PRINTCENTER is an enumeration, not a function
  • Starting a timer, in the timer is not what you want to do
  • Weird timer logic…

I’ve made some code for you, It was good practice :smiley:

[lua]
Melonwave_current = 1 // Current wave (starting wave)
Melonwave_spawn_melons = 10 // How much to spawn the current/next wave
Melonwave_starting_vector = Vector(169, 16, 68) // Starting vector where the melons spawn
Melonwave_wavebusy = false

function Melonwave()
if Melonwave_wavebusy then return end

// Checks if there isnt already a Melonwave
Melonwave_wavebusy = true

// Print you message xD you can use .. (i thing) to add the wave number
for k,v in pairs(player.GetAll()) do
	v:PrintMessage( HUD_PRINTCENTER, "Tha Suppah Demon Melons Of Superior Doom Are Comming !" )
end

// Change the one to any time you want like 0.5
timer.Create( "my_timer", 1, Melonwave_spawn_melons, CreateMelon)
// Set the next wave
Nextwave()

end

function Nextwave()
// Sets the current wave + 1 and a litthe math to calculate what to add (this is very simple you should use somthing better though)
Melonwave_current = Melonwave_current + 1
Melonwave_melons_add = 10*Melonwave_current
Melonwave_spawn_melons = Melonwave_spawn_melons+Melonwave_melons_add
Melonwave_wavebusy = false

end

function CreateMelon()

Melonwave_use_vector = Melonwave_starting_vector
Melonwave_use_vector.y = Melonwave_use_vector.y + math.random( -50, 50 )
// Adds a bit of randomness to the spawning

// Im using standard mellons you can use ur own
melon=ents.Create("prop_physics")
melon:SetModel("models/props_junk/watermelon01.mdl")
melon:SetPos(Melonwave_use_vector)
melon:Activate()
melon:Spawn()

end
// Start the first/seccond/third etc. wave with the command start_melon_wave.
// You should change this cause now anyone can start the next wave.
concommand.Add(“start_melon_wave”, Melonwave)
[/lua]

Put this in your lua/autorun/server or in your gamemode (The dota game right ?)

Just a suggestion: keep using easy memorable names for variables.

You mean something like:

http://noobontour.no.funpic.de/files/?img=melonade/melonade_01.pnghttp://noobontour.no.funpic.de/files/?img=melonade/me_kanal_a20005.jpg
http://noobontour.no.funpic.de/files/?img=melonade/me_kanal_a20004.jpghttp://noobontour.no.funpic.de/files/?img=melonade/me_kanal_a20000.jpg
http://noobontour.no.funpic.de/files/?img=melonade/me_kanal_a20001.jpghttp://noobontour.no.funpic.de/files/?img=melonade/me_kanal_a20002.jpg

this? -> Melonade

Nvm