denny199 Posted October 25, 2012 Posted October 25, 2012 Hey there, I was working on a zombie arena in my server but now I've got a problem, I'm looping for creating the zombies. But now I want to chek if all the zombies are dead, so a new round can start . But I can't figure out how I can store them in a table or so on and to chek if they are all dead. Here's my code: local bot = { } function startnextwave(wave) if ( wave == 2 ) then for i = 1, tonumber(wave*2) do bot[ i ] = exports [ "zombies" ]: createZombie(0, 0, 0, 0,140,0,0 ) outputChatBox ( "chatbox outputs are the zombies." ) end end end addEvent("onZombieWasted", true) addEventHandler("onZombieWasted", root, function() if (source == roundone) then zombies = zombies - 1 wave = 1 chekwave(wave,zombies) end if (source == bot) then outputChatBox ( "zombiekill" ) end end) function chekwave(wave,zombies) if (zombies == 0) then wave = wave + 1 setTimer ( startnextwave,5000, 1,wave ) end end the seconds question is: how should I save values in a xml like this: and how to load it? Because I never worked with xml's and I can't figure the wiki out <path>posx="23" posy="355" posz="32432" name="lol" <path/> <path>posx="3423" posy="3355" posz="3232" name="Test" <path/> <path>posx="2433" posy="3545" posz="32" name="Me gusta" <path/> Regards danny.
Castillo Posted October 25, 2012 Posted October 25, 2012 First question: local bots = { } local totalZombies = 0 function startnextwave ( wave ) if ( wave == 2 ) then for i = 1, tonumber ( wave * 2 ) do local bot = exports [ "zombies" ]: createZombie ( 0, 0, 0, 0, 140, 0, 0 ) bots [ bot ] = true totalZombies = ( totalZombies + 1 ) outputChatBox ( "chatbox outputs are the zombies." ) end end end addEvent ( "onZombieWasted", true ) addEventHandler ( "onZombieWasted", root, function ( ) if ( bots [ source ] ) then totalZombies = ( totalZombies - 1 ) wave = 1 chekwave ( wave, totalZombies ) outputChatBox ( "zombiekill" ) bots [ source ] = nil end end ) function chekwave ( wave, zombies ) if ( zombies == 0) then wave = ( wave + 1 ) setTimer ( startnextwave, 5000, 1, wave ) end end Try it, though I'm not sure if 'source' from 'onZombieWasted' is the zombie you killed. Second question: That XML is wrong, should be: "23" posy="355" posz="32432" name="lol" /> "3423" posy="3355" posz="3232" name="Test" /> "2433" posy="3545" posz="32" name="Me gusta" /> Then you can loop them all like this: local pathsFile = xmlLoadFile ( "paths.xml" ) if ( pathsFile ) then for index, path in ipairs ( xmlNodeGetChildren ( pathsFile ) ) do local data = xmlNodeGetAttributes ( path ) outputChatBox ( data.name ) end end
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now