Jump to content

Whats wrong with it


Skream

Recommended Posts

I'm trying to do a login but when I connect I just get black screen

local screenWidth, screenHeight = guiGetScreenSize()

addEventHandler("onClientResourceStart", localPlayer,
    function()
        loginGUI.background = guiCreateStaticImage(0, 0, 1920, 1200, "background.png", false)
        
        loginGUI.font = guiCreateFont("Roboto-Thin.ttf", 10)
        
        loginGUI.windowLogin = guiCreateStaticImage((screenWidth - 238) / 2, (screenHeight - 184) / 2, 238, 184, "images/login.png", false)
        loginGUI.loginUsername = guiCreateEdit(15, 30, 238, 36, "Usuário ou E-mail", false, loginGUI.windowLogin)
        loginGUI.loginPassword = guiCreateEdit(15, 69, 238, 36, "Senha", false, loginGUI.windowLogin)
        
        guiEditSetMaxLength(loginGUI.loginUsername, 64)
        guiEditSetMaxLength(loginGUI.loginPassword, 32)
        guiEditSetMasked(loginGUI.loginPassword, true)
        guiSetFont(loginGUI.loginUsername, loginGUI.font)
        guiSetFont(loginGUI.loginPassword, loginGUI.font)
        guiLabelSetHorizontalAlign(loginGUI.loginUsername, "right")
        guiLabelSetHorizontalAlign(loginGUI.loginPassword, "right")
        
        loginGUI.windowReg = guiCreateStaticImage((screenWidth - 238) / 2, (screenHeight - 223) / 2, 0, 0, 238, 223, "images/register.png", false)
        loginGUI.regUsername = guiCreateEdit(15, 30, 238, 36, "Usuário", false, loginGUI.windowReg)
        loginGUI.regPassword = guiCreateEdit(15, 69, 238, 36, "Senha", false, loginGUI.windowReg)
        loginGUI.regEmail = guiCreateEdit(15, 108, 238, 36, "E-mail", false, loginGUI.windowReg)
        
        guiEditSetMaxLength(loginGUI.regUsername, 22)
        guiEditSetMaxLength(loginGUI.regPassword, 32)
        guiEditSetMaxLength(loginGUI.regEmail, 64)
        guiEditSetMasked(loginGUI.regPassword, true)
        guiSetFont(loginGUI.regUsername, loginGUI.font)
        guiSetFont(loginGUI.regPassword, loginGUI.font)
        guiSetFont(loginGUI.regEmail, loginGUI.font)
        guiLabelSetHorizontalAlign(loginGUI.regUsername, "right")
        guiLabelSetHorizontalAlign(loginGUI.regPassword, "right")
        guiLabelSetHorizontalAlign(loginGUI.regEmail, "right")
        
        showLogin()
        
        introMusic = playSound("sounds/intro.mp3", true)
        setSoundVolume(soundIntro, 0.7)
        
        triggerEvent("onAccountRegister", hideEverything())
        triggerEvent("onAccountLogin", hideEverything())
    end
)

function showLogin()
    guiSetVisible(loginGUI.background, true)
    guiSetVisible(loginGUI.windowLogin, true)
    guiSetVisible(loginGUI.windowReg, false)

    showChat(false)
    showCursor(true)    
end

 

Edited by Skream
Link to comment

name the resource something else, as well as try using relative values.

This may help you when getting relative values, just take the values that you have already to draw the element and replace the resolution with your own resolution.
example is this, local x1,y1,w1,h1 = relative(200,200,50,50)

local sx,sy = guiGetScreenSize()
local sw,sh = 1360,780-- if u change the values in the relative() funcs, be sure to set this to your res and change the other ones as well.

function relative(x,y,w,h) -- this allows for perfect relative values, mta only sizes them to your res so it would be funky for other resolutions.
    local x,y,w,h = x/sx*sw,y/sy*sh,w/sx*sw,h/sy*sh
    return x,y,w,h
end

Good Luck.

Edited by ShayF
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...