kuwalda Posted June 17, 2014 Share Posted June 17, 2014 If I am storing players name and race time like this in table: blueBerryRallyP[thePlayer] = ((getTickCount () - getElementData( thePlayer, "laiks" )) / 1000) Why does this not work: function endRace(raceToEnd) outputChatBox("Ending:"..raceToEnd..".", root, 0, 255, 255) function findRaceWinner(blueBerryRallyP) if blueBerryRallyP and type(blueBerryRallyP) == 'table' then local time, winner = math.huge for thePlayer, theTime in pairs(blueBerryRallyP) do outputChatBox("INDEX "..thePlayer..", ar VALUE: "..theTime ) if theTime < time then winner, time = thePlayer, theTime end end return winner, time end return false end end It just shows outputChatBox("Ending:"..raceToEnd..".", root, 0, 255, 255) line and thats all. Link to comment
Et-win Posted June 17, 2014 Share Posted June 17, 2014 You are having a function in a function, as far as I know you can't do that. Link to comment
ixjf Posted June 17, 2014 Share Posted June 17, 2014 Yes, you can. The reason that isn't working as expected is that the function inside the function is never called; in fact, another function is useless. Link to comment
#DRAGON!FIRE Posted June 17, 2014 Share Posted June 17, 2014 in line 7 .. u forget visibleTo Argument Link to comment
kuwalda Posted June 17, 2014 Author Share Posted June 17, 2014 Yes, it worked now. Silly question, but how can I use this function to get those returned values? function findRaceWinner(raceToEnd) if blueBerryRallyP and type(blueBerryRallyP) == 'table' then local time, winner = math.huge for thePlayer, theTime in pairs(blueBerryRallyP) do if theTime < time then winner, time = thePlayer, theTime end end return winner, time end return false end Like how can I get or use those return winner, time values? Link to comment
#DRAGON!FIRE Posted June 17, 2014 Share Posted June 17, 2014 try in command .. like this : addCommandHandler ( "getValue" , function ( player ) outputChatBox( "value is"..findRaceWinner( ), player) end ) 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