kuwalda Posted June 17, 2014 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.
Et-win Posted June 17, 2014 Posted June 17, 2014 You are having a function in a function, as far as I know you can't do that.
ixjf Posted June 17, 2014 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.
kuwalda Posted June 17, 2014 Author 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?
#DRAGON!FIRE Posted June 17, 2014 Posted June 17, 2014 try in command .. like this : addCommandHandler ( "getValue" , function ( player ) outputChatBox( "value is"..findRaceWinner( ), player) 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