Jump to content

dx list


Lachuks

Recommended Posts

Hello there!

Tryed to make stats script but... I don't understand how to make dx list. It shows only 1 language when my character know ~2. Hope you can understand what I mean.

It should look like this

 

13mOILx.png

Code

 

for i = 1, 3 do
  local lang = getElementData(localPlayer, "languages.lang" .. i)
  if lang and lang ~= 0 then
    local skill = getElementData(localPlayer, "languages.lang" .. i .. "skill")
    local langname = exports['language-system']:getLanguageName(lang)
    if langname then
      valoda = "\n	- "..langname.."("..skill.."%)"
    end
  end
end

-- and

dxDrawText("Valodas: "..valoda, screenW * 0.2161, screenH * 0.4981, screenW * 0.4130, screenH * 0.5574, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", true, true, false, false, false)
Edited by Emix
Link to comment
27 minutes ago, msyyn said:

valoda = valoda .. "\n - "..langname.."("..skill.."%)"

You're overwriting the valoda variable each time it loops, so you need to include the previous content of the variable to show all the languages.

Thank you for help but it's not working. :( 

Link to comment
24 minutes ago, Emix said:

Thank you for help but it's not working. :( 

What does the debug console say? Try defining variable valoda before the loop (e.g. local valoda = "")

Make sure that dxDraw doesn't clip the text.

 

EDIT:

local valoda = ""
for i = 1, 3 do
  local lang = getElementData(localPlayer, "languages.lang" .. i)
  if lang and lang ~= 0 then
    local skill = getElementData(localPlayer, "languages.lang" .. i .. "skill")
    local langname = exports['language-system']:getLanguageName(lang)
    if langname then
      valoda = valoda .. "\n	- "..langname.."("..skill.."%)"
    end
  end
end

-- and

dxDrawText("Valodas: "..valoda, screenW * 0.2161, screenH * 0.4981, screenW * 0.4130, screenH * 0.5574, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, true, false, false, false)

 

Edited by msyyn
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...