SantiagoOR123 Posted January 28, 2014 Share Posted January 28, 2014 bueno tengo una duda en el ScoreBoard. Lo que sucede es que quiero editarlo para que me diga las horas que llevo de juego pero soy nuevo y no se como hacerlo lo unico que hecho hasta el momento es: local sizescoreboard = 60 exports.scoreboard:scoreboardAddColumn("Horas", root, sizescoreboard) de hay no se que funciones debo agregar ayuda porfavor. Link to comment
Castillo Posted January 28, 2014 Share Posted January 28, 2014 Eso solo crea una columna en la scoreboard, el script para guardar el tiempo lo tenes que crear vos. Link to comment
SantiagoOR123 Posted January 28, 2014 Author Share Posted January 28, 2014 ._. no entendi bro, tenme paciencia porfa Link to comment
Castillo Posted January 28, 2014 Share Posted January 28, 2014 No habia nada que entender, lo unico que dije es que el codigo que vos pusiste ahi solo es para crear una columna en la scoreboard. Link to comment
SantiagoOR123 Posted January 28, 2014 Author Share Posted January 28, 2014 aaah! Que funciones son para crear ._. Link to comment
MTA Team 0xCiBeR Posted January 28, 2014 MTA Team Share Posted January 28, 2014 Encontré esto navegando por el foro: exports.scoreboard:addScoreboardColumn( 'Play Time' ) local t = { } local uTimers = { } function checkValues( source,arg1,arg2 ) if arg1 > 60 then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 elseif arg2 > 3600 then t[ source ][ 'sec' ] = 0 t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end end function onPlayerLogOut ( _,account ) if ( account ) and not isGuestAccount ( account ) then local sValue = getElementData( source,'Play Time' ) setAccountData ( account, "Play Time", tostring( sValue ) ) end if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = nil t[ source ] = nil end function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Play Time' ) setAccountData ( playeraccount, "Play Time", tostring( sValue ) ) end if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = nil t[ source ] = nil end function subFind( str,mod ) if mod == 'hour' then return str:sub( 1,str:find( ':' ) -1 ) else return str:sub( str:find( ':' ) + 1,str:len( ) ) end end function onPlayerLogin (_, account ) if account then uTimers[ source ] = setTimer( function( player,acc ) local time = getAccountData ( acc, "Play Time" ) if time then if not t[ player ] then t[ player ] = { ["hour"] = tonumber( subFind( time,'hour' ) ), ["min"] = tonumber( subFind( time ) ), ["sec"] = 0 } end else if not t[ player ] then t[ player ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end end t[ player ][ 'sec' ] = tonumber( t[ player ][ 'sec' ] or 0 ) + 1 checkValues ( player, t[ player ][ 'sec' ] or 0, t[ player ][ 'min' ] or 0 ) setElementData ( player, "Play Time", tostring( t[ player ][ 'hour' ] or 0 )..':'..tostring( t[ player ][ 'min' ] or 0 ) ) end, 1000, 0 ,source,account ) end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) addEventHandler( 'onPlayerLogout',root, onPlayerLogOut ) Fíjate si te sirve... Link to comment
Recommended Posts