Kenix Posted February 15, 2011 Share Posted February 15, 2011 selectTimer = setTimer(function() zombieturn(getRandomPlayer(source)) end, 20000, 1) c the first 2 times did not wheel and the 3 is already running when running the rules and when not in what could be the problem? that can block it. help please Link to comment
Kenix Posted February 15, 2011 Author Share Posted February 15, 2011 function playerzmtake () local array = {} for i,pl in ipairs(getElementsByType("player")) do array[i]=pl end if #array>0 then local c = math.random(1,#array) end end now I still have the code but it also works = ( help please. Link to comment
DakiLLa Posted February 15, 2011 Share Posted February 15, 2011 I don't know why the first example does not work for you, it should be ok if there is a 'zombieturn' function that should recieve a player element as it's parameter. Btw, there are no any parameters in getRandomPlayer function, so the 'source' you passed there is useless. And what about the second example.. I guess it does not work because your function does return nothing, so that could be a problem, may be you forgot to put 'return c' ? Btw, you can replace it with just one-line function: function getRndPlayer() return getElementsByType( "player" )[math.random( 1, #getElementsByType( "player" ) )]; end; But eh, what actually do you want to do, can you explain it lil bit better... ? Link to comment
Kenix Posted February 15, 2011 Author Share Posted February 15, 2011 I don't know why the first example does not work for you, it should be ok if there is a 'zombieturn' function that should recieve a player element as it's parameter. Btw, there are no any parameters in getRandomPlayer function, so the 'source' you passed there is useless.And what about the second example.. I guess it does not work because your function does return nothing, so that could be a problem, may be you forgot to put 'return c' ? Btw, you can replace it with just one-line function: function getRndPlayer() return getElementsByType( "player" )[math.random( 1, #getElementsByType( "player" ) )]; end; But eh, what actually do you want to do, can you explain it lil bit better... ? I would like to select any player and he did call 'zombieturn' function of just one. at the expense of getRandomPlayer I only used here to see prices ... Link to comment
Kenix Posted February 16, 2011 Author Share Posted February 16, 2011 DakiLLa use your version of it better than others but still at times choose not to single player. Link to comment
Aibo Posted February 16, 2011 Share Posted February 16, 2011 how can it return multiple players when it simply cant? check other parts of your script, maybe you're calling it twice. Link to comment
Kenix Posted February 16, 2011 Author Share Posted February 16, 2011 how can it return multiple players when it simply cant? check other parts of your script, maybe you're calling it twice. Yes you are right, I found the problem on my bad it kills the timer after the completion of maps if isTimer(selectTimer) then killTimer(selectTimer) end Link to comment
Kenix Posted February 16, 2011 Author Share Posted February 16, 2011 how can it return multiple players when it simply cant? check other parts of your script, maybe you're calling it twice. Yes you are right, I found the problem on my bad it kills the timer after the completion of maps if isTimer(selectTimer) then killTimer(selectTimer) end i fixed Thank all very much. Link to comment
Castillo Posted February 16, 2011 Share Posted February 16, 2011 Next time use "EDIT" button, thanks. Link to comment
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