Jump to content

Character input in table


Recommended Posts

Hi all,

I'm working on a DX login system for my server but i have no idea how to insert more character in my table.
Can somebody explain me how i can do this?

Now it only inserts het key i press, but how can i insert character1, character2, character3 etc?

 


local usernameTable = {}
local passwordTable = {}

local usernameText = "Username!"

local font = dxCreateFont('assets/font.otf', 18, false, 'default')
local sx, sy = guiGetScreenSize()

function loginGUI()
    dxDrawRectangle (sx*(0/1024), sy*(0/768), sx*(1024/1024), sy*(768/768), tocolor(0, 173, 239, 255)) -- Blue background screen
    dxDrawRectangle (sx*(362/1024), sy*(400/768), sx*(300/1024), sy*(25/768), tocolor(255, 255, 255, 255)) -- Username input
    dxDrawText (usernameText, sx*(368/1024), sy*(402/768), sx*(300/1024), sy*(18/768), tocolor ( 0, 0, 0, 255 ), 1, 1, font)
--    dxDrawRectangle (sx*(362/1024), sy*(440/768), sx*(300/1024), sy*(25/768), tocolor(255, 255, 255, 255)) -- Username input
--    dxDrawRectangle (sx*(0/1024), sy*(0/768), sx*(1024/1024), sy*(768/768), tocolor(0, 173, 239, 255)) -- register button
--    dxDrawRectangle (sx*(0/1024), sy*(0/768), sx*(1024/1024), sy*(768/768), tocolor(0, 173, 239, 255)) -- Login button
end

function onJoinHandler()
    setPlayerHudComponentVisible ("all", false)
    showChat (false)
    showCursor (true)
    addEventHandler ("onClientRender", root, loginGUI)
end
addEventHandler ("onClientResourceStart", getRootElement(), onJoinHandler)

function addLabelOnClick (button, state, x, y)
    if (button == "left") and (state == "up") then
        if (x > sx*(362/1024)) and (x < sx*(662/1024)) and (y > sy*(400/768) and (y < sy*(425/768))) then
            toggleAllControls (false)
            usernameText = ""
            addEventHandler("onClientCharacter", getRootElement(), outputUsername)
        end
    end
end
addEventHandler ("onClientClick", root, addLabelOnClick)

function outputUsername(character)
    usernameTable[]= character
    outputDebugString ("Stored!")
    usernameText = usernameTable[]
end

 

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...