-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
No se, la unica manera seria guardar cada cuenta y su experiencia en una tabla al iniciar y loguearse un jugador, y luego tendrias que hacer un for-loop, pero eso podria laguear al servidor.
-
Ah, ahora entiendo, pero para eso vas a tener que editar el script, para que guarde la experiencia siguiente o algo asi.
-
La verdad es que sigo sin entender. Si player 1 tiene 2500 de exp y player 2 tiene 2000, obvio que player 1 sera rango 1.
-
addCommandHandler ( "ran", function ( ) for index, rank in ipairs ( tabladeRanks ( ) ) do if ( isElement ( rank [ 2 ] ) ) then setElementData ( rank [ 2 ], "Rank", index ) end end end ) function tabladeRanks ( ) local datat = { } for _, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( datat, { tonumber ( getElementData ( player, "Exp" ) or 0 ), player } ) end table.sort ( datat, function ( a, b ) return ( tonumber ( a [ 1 ] ) or 0 ) > ( tonumber ( b [ 1 ] ) or 0 ) end ) return datat end
-
addCommandHandler ( "ran", function ( ) for _, rank in ipairs ( tabladeRanks ( ) ) do outputChatBox ( tonumber ( rank [ 1 ] )..": ".. getPlayerName ( rank [ 2 ] ) ) --setElementData(player, "Rank", i ) end end ) function tabladeRanks ( ) local datat = { } for _, player in ipairs ( getElementsByType ( "player" ) ) do table.insert ( datat, { tonumber ( getElementData ( player, "Exp" ) or 0 ), player } ) end table.sort ( datat, function ( a, b ) return ( tonumber ( a [ 1 ] ) or 0 ) > ( tonumber ( b [ 1 ] ) or 0 ) end ) return datat end Mucho mas facil con table.sort.
-
addCommandHandler ( "ran", function ( ) for _, rank in ipairs ( tabladeRanks ( ) ) do outputChatBox ( tonumber ( rank [ 1 ] )..": ".. getPlayerName ( rank [ 2 ] ) ) --setElementData(player, "Rank", i ) end end ) function tabladeRanks ( ) local datat = { } for k, player in ipairs ( getElementsByType ( "player" ) ) do local top = ( datat [ 1 ] and datat [ 1 ] [ 1 ] or 0 ) local low = ( datat [ #datat ] and datat [ #datat ] [ 1 ] or math.huge ) local pmon = tonumber ( getElementData ( player, "Exp" ) or 0 ) if ( pmon > top ) then table.insert ( datat, { 1, player } ) elseif ( pmon < low ) then table.insert ( datat, { #datat + 1, player } ) end end return datat end
-
Oh, I actually didn't notice you were using bindKey.
-
Cierto, me olvide de algo, copialo nuevamente.
-
Lo copiaste mal seguramente.
-
Es porque getPlayerTeam devuelve un elemento, no un nombre. fileWrite( xml, "\""..getPlayerName(player).."\" team=\"".. getTeamName ( getPlayerTeam(player) ).."\"/> \n")
-
Pusiste 'fileWrite' y 'fileClose' despues de cerrar la funcion, ponelo antes del 'end'.
-
Proba esto: addCommandHandler ( "ran", function ( ) for _, rank in ipairs ( tabladeRanks ( ) ) do outputChatBox ( tonumber ( rank [ 1 ] )..": ".. getPlayerName ( rank [ 2 ] ) ) --setElementData(player, "Rank", i ) end end ) function tabladeRanks ( ) local datat = { } for k, player in ipairs ( getElementsByType ( "player" ) ) do local top = ( datat [ 1 ] and datat [ 1 ] [ 1 ] or 0 ) local low = datat [ #datat ] or math.huge local pmon = tonumber ( getElementData ( player, "Exp" ) or 0 ) if ( pmon > top ) then table.insert ( datat, { 1, player } ) elseif ( pmon < low ) then table.insert ( datat, { #datat + 1, player } ) end end return datat end
-
Ambos son numeros, ese error no deberia aparecer, estas segurisimo de que es en esa linea?
-
Fijate que devuelve "pmon" y "top".
-
No hay de que.
-
addEvent ( "SitForm", true ) addEventHandler ( "SitForm", root, function ( WTF ) if ( WTF == "pc1" ) then outputChatBox ( "pc1", 255, 0, 0 ) elseif ( WTF == "pc2" ) then outputChatBox ( "pc2", 255, 0, 0 ) end end )
-
teamTaxistas = createTeam ( "Taxistas", 255, 255, 0 ) function taxiCommand ( thePlayer, command ) taxiOphaalBlip = createBlipAttachedTo ( thePlayer, 48, 1, 255, 0, 0, 0, 0, 99999.0, getRootElement() ) outputChatBox ("textoasdasd1.", thePlayer, 255, 190, 0, false ) for _, player in ipairs ( getPlayersInTeam ( teamTaxistas ) ) do outputChatBox ("textoasdasd.",player,0,255,0,true) end end addCommandHandler ( "taxi", taxiCommand )
