local dev = {}; dev.screen = Vector2(guiGetScreenSize()); dev.scale = math.min(0.8, dev.screen.y / 1080); dev.fonts = {}; dev.statEnabled = false local function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end local function GetFont(name, size, ...) if not dev.fonts[name] then dev.fonts[name] = {}; end if not isElement(dev.fonts[name][size]) then local resource_assets = getResourceFromName('nc_assets') local assets = resource_assets and getResourceState(resource_assets) == 'running' and exports['nc_assets'] if assets and assets:isLoaded() then dev.fonts[name][size] = assets:getFont(name, (size * 0.73) * dev.scale, ...) end if isElement(dev.fonts[name][size]) then addEventHandler('onClientElementDestroy', dev.fonts[name][size], function() for name, tables in pairs(dev.fonts) do for size, fontElement in pairs(tables) do if fontElement == source then dev.fonts[name][size] = nil end end end local count = 0 for i, v in pairs(dev.fonts[name]) do count = count + 1 if count >= 1 then break end end if count < 1 then dev.fonts[name] = nil end collectgarbage() end) end end return (dev.fonts[name][size] or GetFont('robotocondensed-regular', 18)) end addCommandHandler('players', function(_, meters) if (not getElementData(localPlayer, 'player:dev')) then return end local x, y, z = getElementPosition(localPlayer) local players = getElementsWithinRange(x, y, z, tonumber(meters) or 100, 'player') outputChatBox('Tem '..#players.. ' Jogadores a '.. (tonumber(meters) or 100) .. ' metros ao seu redor.', 255, 255, 255) end) addCommandHandler('polygon', function(_, width, height) if (not getElementData(localPlayer, 'player:dev')) then return end if (dev.polygon and isElement(dev.polygon)) then destroyElement(dev.polygon) end local width = tonumber(width) local height = tonumber(height) if (not width or not height) then return false end local x, y, z = getElementPosition(localPlayer) local _, _, direction = getElementRotation(localPlayer) local bottomLeftX = x + math.cos(math.rad(direction)) * width / 2 local bottomLeftY = y + math.sin(math.rad(direction)) * width / 2 local topLeftX = bottomLeftX + math.cos(math.rad(direction + 90)) * height local topLeftY = bottomLeftY + math.sin(math.rad(direction + 90)) * height local topRightX = topLeftX + math.cos(math.rad(direction + 180)) * width local topRightY = topLeftY + math.sin(math.rad(direction + 180)) * width local bottomRightX = topRightX + math.cos(math.rad(direction - 90)) * height local bottomRightY = topRightY + math.sin(math.rad(direction - 90)) * height local centerX = (bottomLeftX + topRightX) / 2 local centerY = (bottomLeftY + topRightY) / 2 local groundZ = getGroundPosition(centerX, centerY, z + 100) outputChatBox('Ground position: ' .. groundZ) outputChatBox(('Polygon positions: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s'):format(centerX, centerY, bottomLeftX, bottomLeftY, topLeftX, topLeftY, topRightX, topRightY, bottomRightX, bottomRightY)) setClipboard(([[ floor = %s, positions = {%s, %s, %s, %s, %s, %s, %s, %s, %s, %s} ]]):format(groundZ, centerX, centerY, bottomLeftX, bottomLeftY, topLeftX, topLeftY, topRightX, topRightY, bottomRightX, bottomRightY)) dev.polygon = createColPolygon(centerX, centerY, bottomLeftX, bottomLeftY, topLeftX, topLeftY, topRightX, topRightY, bottomRightX, bottomRightY) setColPolygonHeight(dev.polygon, groundZ, groundZ + 5) end) addCommandHandler('destroypolygon', function() if (not getElementData(localPlayer, 'player:dev')) then return end if (dev.polygon and isElement(dev.polygon)) then destroyElement(dev.polygon) end dev.polygon = nil end) dev.statusCaptures = { ['VideoCardName'] = 1, ['VideoCardPSVersion'] = 2, ['SettingDebugMode'] = 3, ['TestMode'] = 4, ['VideoCardRAM'] = 5, ['VideoMemoryFreeForMTA'] = 6, ['VideoMemoryUsedByFonts'] = 7, ['VideoMemoryUsedByTextures'] = 8, ['SettingStreamingVideoMemoryForGTA'] = 9, ['usedStreamingMemory'] = 10, ['TotalPhysicalMemory'] = 11, } local function formatValues(Type, value) if Type == 'VideoCardRAM' then return ('%.2f MB'):format(math.round(value)) elseif Type == 'VideoCardName' then return value elseif Type == 'VideoCardPSVersion' then return value elseif Type == 'SettingDebugMode' then return value elseif Type == 'TestMode' then return value elseif Type == 'VideoMemoryFreeForMTA' then return ('%.2f MB'):format(math.round(value)) elseif Type == 'VideoMemoryUsedByFonts' then return ('%.2f MB'):format(math.round(value)) elseif Type == 'VideoMemoryUsedByTextures' then return ('%.2f MB'):format(math.round(value)) elseif Type == 'SettingStreamingVideoMemoryForGTA' then return ('%.2f MB'):format(math.round(value)) elseif Type == 'TotalPhysicalMemory' then return ('%.2f MB'):format(math.round(value)) elseif Type == 'usedStreamingMemory' then return ('%.2f MB'):format(math.round(value)) else return value end end function onRenderInfos() local pmem = dev.pmem or { resident = 0, shared = 0, private = 0, virtual = 0 } if not dev.status then dev.status = dxGetStatus() dev.status.usedStreamingMemory = math.round(engineStreamingGetUsedMemory() / 1024 / 1024) dev.status.SettingStreamingVideoMemoryForGTA = math.round(engineStreamingGetMemorySize() / 1024 / 1024) end if not dev.pmem then dev.pmem = getProcessMemoryStats() end local status = dev.status local scale = dev.scale local currentY = ((dev.screen.y - (400 * scale)) / 2) currentY = currentY + dxGetFontHeight(1, GetFont('robotocondensed-regular', 18)) local status2 = {} for i, v in pairs(status) do if dev.statusCaptures[i] then table.insert(status2, {i, v}) end end table.sort(status2, function(a, b) return dev.statusCaptures[a[1]] < dev.statusCaptures[b[1]] end) for i, v in ipairs(status2) do local FORMATED = ("%s: %s"):format(v[1], formatValues(v[1], v[2])) dxDrawText(FORMATED, (20 * scale) - 1, currentY - 1, 0, 0, tocolor(0, 0, 0), 1, GetFont('robotocondensed-regular', 18), 'left', 'top', false, false, false, true) dxDrawText(FORMATED, (20 * scale), currentY, 0, 0, tocolor(255, 255, 255), 1, GetFont('robotocondensed-regular', 18), 'left', 'top', false, false, false, true) currentY = currentY + dxGetFontHeight(1, GetFont('robotocondensed-regular', 18)) if v[1] == 'VideoCardPSVersion' then currentY = currentY + (20 * scale) end if v[1] == 'TestMode' then currentY = currentY + (20 * scale) end if v[1] == 'VideoMemoryUsedByTextures' then currentY = currentY + (20 * scale) end end currentY = currentY + (20 * scale) for i, v in pairs(pmem) do local FORMATED = ("%s: %.2f MB"):format(i, math.round(v / (1024^2))) dxDrawText(FORMATED, (20 * scale) + 1, currentY + 1, 0, 0, tocolor(0, 0, 0), 1, GetFont('robotocondensed-regular', 18), 'left', 'top', false, false, false, true) dxDrawText(FORMATED, (20 * scale), currentY, 0, 0, tocolor(255, 255, 255), 1, GetFont('robotocondensed-regular', 18), 'left', 'top', false, false, false, true) currentY = currentY + dxGetFontHeight(1, GetFont('robotocondensed-regular', 18)) end end addEventHandler('onClientElementDataChange', localPlayer, function(key, old, new) if key ~= 'player:dev' then return end if new then if not isEventHandlerAdded('onClientRender', root, onRenderInfos) then addEventHandler('onClientRender', root, onRenderInfos) end else if isEventHandlerAdded('onClientRender', root, onRenderInfos) then removeEventHandler('onClientRender', root, onRenderInfos) end end end) setTimer(function() if (not getElementData(localPlayer, 'player:dev') and not dev.statEnabled) then return end dev.status = dxGetStatus() or {} dev.status.SettingStreamingVideoMemoryForGTA = engineStreamingGetMemorySize() / 1024 / 1024 dev.status.usedStreamingMemory = math.round(engineStreamingGetUsedMemory() / 1024 / 1024) dev.pmem = getProcessMemoryStats() end, 2500, 0) addCommandHandler('stat', function() dev.statEnabled = not dev.statEnabled if dev.statEnabled then if not isEventHandlerAdded('onClientRender', root, onRenderInfos) then addEventHandler('onClientRender', root, onRenderInfos) end else if isEventHandlerAdded('onClientRender', root, onRenderInfos) then removeEventHandler('onClientRender', root, onRenderInfos) end end end)