Jump to content

Search the Community

Showing results for tags 'linear graphics'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 1 result

  1. Buenos días, ayer estaba aburrido por la noche así que decidí hacer un pequeño stream en mi canal creando un sistema bastante simple de gráficos en mta, Voy a dejar el video y el codigo en si por si les es de utilidad en el vídeo pueden ver todos los errores que eh tenido y como he ido resolviéndolos supongo que para algunos puede ser util aprender como es el proceso de debugear scripts. Video: Código: local graphics = {} local offset = 10 function getTheMaxValue(array) local cuarrentValue = 0 for i = 1, #array do local data = array[i] if data > cuarrentValue then cuarrentValue = data end end return cuarrentValue end function calculateYByMaxValue(value, maxValue) if value and maxValue then local percentaje = value * 100 / maxValue return percentaje end return false end function renderGraphics() dxDrawText(inspect ( graphics ), 10, 200, 200, 700) for i = 1, #graphics do local data = graphics[i] dxDrawRectangle(data.x, data.y, data.w, data.h, tocolor(255, 255, 255)) local x, y, w, h = data.x + 10, data.y + 10, data.w - 20, data.h - 20 local distance = math.floor(w/#data.data) for i = 1, #data.data do local posY = calculateYByMaxValue(data.data[i], data.maxValue) / 100 * h - 10 dxDrawRectangle(x + distance * i - 5, (y + h) - posY - offset, 5, 5, tocolor(150, 150, 150)) local posY2 = calculateYByMaxValue(data.data[i - 1] or 2, data.maxValue) / 100 * h - 10 dxDrawLine(x + distance * (i - 1) - 2, (y + h) - posY2 + 2 - offset, x + distance * i - 2, (y + h) - posY + 2 - offset, tocolor(150, 150, 150), 2 ) dxDrawText(data.data[i], x + distance * i - 5 - 50, y + h - 8, 100 + (x + distance * i - 5 - 50), y + h + 8, tocolor(150, 150, 150), 1, "default-bold", "center", "center") end end end function createGraphic(x, y, w, h, values) if x and y and w and h then local array = {} table.sort(values, function(a,b) return a<b end) array.x = x array.y = y array.w = w array.h = h array.data = values array.maxValue = getTheMaxValue(values) table.insert(graphics, array) if #graphics == 1 then outputDebugString("[Graphics] Activando renderizado.") addEventHandler("onClientRender", root, renderGraphics) end outputDebugString("[Graphics] Nuevo grafico creando.") else outputDebugString("[Graphics] Faltan argumentos") end end createGraphic(500, 200, 500, 500, {100, 101, 200, 210, 500, 1000, 201, 250, 305, 350, 460}) Si tenéis alguna sugerencia en que podría hacer en mi siguiente stream si es que algún día lo hago bueno, dejarlo en los comentarios del vídeo o aquí mismo. Pueden hacer lo que quieran con el código.
×
×
  • Create New...