Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- // Afk System
- function Timer()
- sec = sec + 1
- setElementData(getLocalPlayer(),"Timer",sec)
- end
- function secondsToTimeDesc( seconds )
- if seconds then
- local results = {}
- local sec = ( seconds %60 )
- local min = math.floor ( ( seconds % 3600 ) /60 )
- local hou = math.floor ( ( seconds % 86400 ) /3600 )
- local day = math.floor ( seconds /86400 )
- if day > 0 and day < 10 then table.insert( results, day .. ( day == 1 and " day" or " days" ) )
- elseif day > 0 then table.insert( results, day .. ( day == 1 and "" or "" ) ) end
- if hou >= 0 and hou < 10 then table.insert( results, "0"..hou .. ( hou == 1 and "" or "" ) )
- elseif hou > 0 then table.insert( results, hou .. ( hou == 1 and "" or "" ) ) end
- if min >= 0 and min < 10 then table.insert( results, "0"..min .. ( min == 1 and "" or "" ) )
- elseif min > 0 then table.insert( results, min .. ( hou == 1 and "" or "" ) ) end
- if sec >= 0 and sec < 10 then table.insert( results, "0"..sec .. ( sec == 1 and "" or "" ) )
- elseif sec > 0 then table.insert( results, sec .. ( sec == 1 and "" or "" ) ) end
- return string.reverse ( table.concat ( results, " : " ):reverse():gsub(" : ", " : ", 1 ) )
- end
- return ""
- end
- addEventHandler( "onClientRestore", getRootElement(),
- function ()
- setElementData (getLocalPlayer(),"p:afk",false)
- sec = 0
- if isTimer (StartTimer) then
- killTimer(StartTimer)
- end
- end
- )
- addEventHandler( "onClientMinimize", getRootElement(),
- function ()
- setElementData (getLocalPlayer(),"p:afk",true)
- if getElementData (getLocalPlayer(),"p:afk") then
- StartTimer = setTimer(Timer,1000,0)
- end
- end
- )
- addEventHandler( "onClientResourceStart", getResourceRootElement(),
- function ()
- if getElementData (getLocalPlayer(),"p:afk") then
- StartTimer = setTimer(Timer,1000,0)
- else
- sec = 0
- if isTimer (StartTimer) then
- killTimer(StartTimer)
- end
- end
- end
- )
- function dxDrawCircle( posX, posY, radius, width, angleAmount, startAngle, stopAngle, color, postGUI )
- if ( type( posX ) ~= "number" ) or ( type( posY ) ~= "number" ) then
- return false
- end
- local function clamp( val, lower, upper )
- if ( lower > upper ) then lower, upper = upper, lower end
- return math.max( lower, math.min( upper, val ) )
- end
- radius = type( radius ) == "number" and radius or 50
- width = type( width ) == "number" and width or 5
- angleAmount = type( angleAmount ) == "number" and angleAmount or 1
- startAngle = clamp( type( startAngle ) == "number" and startAngle or 0, 0, 360 )
- stopAngle = clamp( type( stopAngle ) == "number" and stopAngle or 360, 0, 360 )
- color = color or tocolor( 255, 255, 255, 200 )
- postGUI = type( postGUI ) == "boolean" and postGUI or false
- if ( stopAngle < startAngle ) then
- local tempAngle = stopAngle
- stopAngle = startAngle
- startAngle = tempAngle
- end
- for i = startAngle, stopAngle, angleAmount do
- local startX = math.cos( math.rad( i ) ) * ( radius - width )
- local startY = math.sin( math.rad( i ) ) * ( radius - width )
- local endX = math.cos( math.rad( i ) ) * ( radius + width )
- local endY = math.sin( math.rad( i ) ) * ( radius + width )
- dxDrawLine( startX + posX, startY + posY, endX + posX, endY + posY, color, width, postGUI )
- end
- return true
- end
Add Comment
Please, Sign In to add comment