Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sX, sY = guiGetScreenSize()
- --{"element neve", x, y}
- local changeSizeUse = false
- local dxFont = dxCreateFont("font.ttf",17)
- _getCursorPosition = getCursorPosition
- function getCursorPosition()
- cX, cY = _getCursorPosition()
- cX, cY = cX*sX, cY*sY
- return cX, cY
- end
- function dobozbaVan(cx, cy, x, y, w, h)
- if cx > x and cx < x+w and cy > y and cy < y+h then
- return true
- else
- return false
- end
- end
- local counter = 0
- local starttick
- local currenttick
- local showfps = false
- function math.round(number, decimals, method)
- decimals = decimals or 0
- local factor = 10 ^ decimals
- if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
- else return tonumber(("%."..decimals.."f"):format(number)) end
- end
- addEventHandler ("onClientRender",root,
- function()
- if not starttick then
- starttick = getTickCount ()
- end
- counter = counter + 1
- currenttick = getTickCount ()
- if currenttick - starttick >= 1000 then
- setElementData (localPlayer, "FPS", counter)
- counter = 0
- starttick = false
- end
- end
- )
- fpstable = {}
- function averageFPS()
- avgseconds = 10
- for i = 0, avgseconds do
- if i+1 <= avgseconds then
- fpstable[i+1] = fpstable[i]
- end
- fpstable[0] = getElementData (localPlayer, "FPS")
- end
- totalframes = 0
- for k, v in pairs(fpstable) do
- if v ~= false then
- totalframes = totalframes + v
- end
- end
- avgfps = math.round(totalframes / avgseconds, 0)
- setElementData (localPlayer, "avgfps", avgfps)
- end
- setTimer (averageFPS, 1000, 0)
- local stat = dxGetStatus ( )
- local szoveg = "#00A1FFVideókártya: #ffffff" .. stat["VideoCardName"] .."\n#00A1FFRam: #ffffff".. stat["VideoMemoryFreeForMTA"].."/".. stat["VideoCardRAM"]
- local szovegs = stat["VideoCardName"] .."\nVRAM ".. stat["VideoMemoryFreeForMTA"].."/".. stat["VideoCardRAM"]
- local hudElements = {{"showFPS", 10, 180, 310, 100}}
- addEventHandler("onClientRender", getRootElement(), function()
- if showfps then
- for i, k in ipairs(hudElements) do
- local x, y, w, h, m, r, ru = getElementData(localPlayer, k[1] .. "X") or k[2], getElementData(localPlayer, k[1] .. "Y") or k[3], getElementData(localPlayer, k[1] .. "W") or k[4], getElementData(localPlayer, k[1] .. "H") or k[5], getElementData(localPlayer,k[1] .. "Moving") or false, getElementData(localPlayer, k[1] .. "Resize") or false, getElementData(localPlayer, k[1] .. "ResizeUse") or false
- setElementData(localPlayer, k[1] .. "H", nil)]]
- if k[1] == "showFPS" then
- getElementData(localPlayer,"FPS"),x,y,w,h,tocolor(0,0,0,255),1,dxFont,"left","top",true,true,true,true,true)
- local fps = getElementData(localPlayer,"FPS")
- if fps <= 100 then
- fpscolor = "#ffffff"
- elseif fps < 100 and fps <= 30 then
- fpscolor = "#FFA700"
- elseif fps < 30 then
- fpscolor = "#D75656"
- end
- dxDrawText(szoveg .. fpscolor .." \n#00A1FFFPS: #FFFFFF" .. getElementData(localPlayer,"FPS"),x+1,y+1,w,h,tocolor(0,0,0,255),0.62,dxFont,"left","top",true,true,true,true,true)
- if m then
- local cX, cY = getCursorPosition()
- setElementData(localPlayer, k[1] .. "X", cX-defX)
- setElementData(localPlayer, k[1] .. "Y", cY-defY)
- end
- else
- if m then
- local cX, cY = getCursorPosition()
- setElementData(localPlayer, k[1] .. "X", cX-defX)
- setElementData(localPlayer, k[1] .. "Y", cY-defY)
- end
- end
- end
- end
- end)
- addEventHandler("onClientClick", getRootElement(), function(button, state, aX, aY, wX, wY, wZ, element)
- if showfps then
- if button == "left" then
- if state == "down" then
- for i, k in ipairs(hudElements) do
- local x, y, w, h, r = getElementData(localPlayer, k[1] .. "X") or k[2], getElementData(localPlayer, k[1] .. "Y") or k[3], getElementData(localPlayer, k[1] .. "W") or k[4], getElementData(localPlayer, k[1] .. "H") or k[5], getElementData(localPlayer, k[1] .. "Resize") or false
- local cX, cY = getCursorPosition()
- if dobozbaVan(cX, cY, x, y, w, h) then
- setElementData(localPlayer, k[1] .. "Moving", true)
- defX, defY = cX-x, cY-y
- end
- end
- elseif state == "up" then
- for i, k in ipairs(hudElements) do
- local m, r = getElementData(localPlayer,k[1] .. "Moving") or false, getElementData(localPlayer, k[1] .. "Resize") or false
- if m then
- setElementData(localPlayer, k[1].. "Moving", false)
- end
- end
- end
- end
- end
- end)
- function showFPSed()
- if not showfps then
- showfps = true
- else
- showfps = false
- end
- end
- addCommandHandler("showfps",showFPSed)
- addEventHandler("onClientResourceStart", resourceRoot, function()
- local asd = jsonGET("fps_pos",false)
- if asd[1] and asd[2] and asd[3] then
- for v,k in ipairs(hudElements) do
- if k[1] == "showFPS" then
- defX = tonumber(asd[1])
- defY = tonumber(asd[2])
- setElementData(localPlayer,k[1].. "X",defX)
- setElementData(localPlayer,k[1].. "Y",defY)
- setElementData(localPlayer,k[1].. "Moving",false)
- -- showfps = asd[3]
- end
- end
- end
- end)
- function saveInventoryPosition()
- for v,k in ipairs(hudElements) do
- if k[1] == "showFPS" then
- local x,y = getElementData(localPlayer, k[1] .. "X"), getElementData(localPlayer, k[1] .. "Y")
- jsonSAVE("fps_pos", {x, y}, false)
- end
- end
- end
- setTimer(function()
- saveInventoryPosition()
- end,1000,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement