Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.scoreboard:scoreboardAddColumn ( "Alive time", root, 50 )
- function resetAliveTime( p )
- setElementData( p, "Alive time", "00:00" )
- end
- function getAliveTime( p )
- return getElementData( p, "Alive time" )
- end
- addEventHandler( "onPlayerSpawn", root,
- function( p )
- resetAliveTime( source )
- end
- )
- addEventHandler( "onPlayerWasted", root,
- function( )
- resetAliveTime( source )
- end
- )
- function timers( )
- -- function update timers
- for i, v in ipairs( getElementsByType( "player" ) ) do
- if isPedDead( v ) == false then
- local aliveTime = split( getAliveTime( v ), ":" )
- --outputChatBox( getAliveTime( v )..outputChatBox( tostring( aliveTime ) ) )
- local minutes, seconds = unpack( aliveTime )
- local minutes = tonumber( minutes )
- local seconds = tonumber( seconds ) + 1
- if seconds == 60 then
- minutes = minutes + 1
- seconds = 0
- else
- seconds = seconds + 1
- end
- local string = convertTime( minutes, seconds )
- setElementData( v, "Alive time", string )
- end
- end
- end
- addEventHandler( "onResourceStart", resourceRoot,
- function( )
- for i, v in ipairs( getElementsByType( "player" ) ) do
- if isPedDead( v )== false then
- resetAliveTime( v )
- setTimer( timers, 1000, 0 )
- end
- end
- end
- )
- function convertTime( minutes, seconds )
- if minutes < 10 then
- minutes = "0"..tostring( minutes )
- end
- if seconds < 10 then
- seconds = "0"..tostring( seconds )
- end
- return tostring( minutes )..":"..tostring( seconds )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement