andresmak Posted December 8, 2013 Posted December 8, 2013 Tengo un problema al sumar un dinero pero ese dinero es de todas las cuantas de los jugadores del servidor y que se un solo resultado. Yo creo que se debe utilizar con table.sort pero no estoy seguro si es haci para sumarlo local tableList = {} for i, v in ipairs(getAccounts()) do table.insert(tableList,{cash = getAccountData(v, "cash")}) table.sort(tableList, function(a,b) return (tonumber(a.cash) or 0) + (tonumber(b.cash) or 0) end) end si es haci o es de otra forma, alguien me podria ayudar si es tan amable? Gracias!
Castillo Posted December 8, 2013 Posted December 8, 2013 local accounts = getAccounts ( ) table.sort ( accounts, function (a, b ) return ( tonumber ( getAccountData ( a, "cash" ) ) or 0 ) + ( tonumber ( getAccountData ( b, "cash" ) ) or 0 ) end ) Creo que eso deberia funcionar. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
andresmak Posted December 9, 2013 Author Posted December 9, 2013 si funciono "GRACIAS" pero la que yo había puesto también funcionaba?
Castillo Posted December 9, 2013 Posted December 9, 2013 Puede que lo hiciera, pero mi codigo es mucho mas eficiente. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted December 9, 2013 Posted December 9, 2013 De nada. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts