Jump to content

Painel de login bugado, quero tornalo funcional


Recommended Posts

Para tentar desbugar / arrumar esse painel de login com defeito, não está funcionando corretamente, alguém consegue me ajudar a encontrar e corrigir o erro?

 

 

 

local sX, sY = guiGetScreenSize ()
local x, y = sX / 1366, sY / 768
local fontsize = sX / 1920

local lp = {
            hasAccount = true,
            blur = {
                            shader = dxCreateShader ("img / blur.fx"),
                            screensource = dxCreateScreenSource (sX, sY),
                            --update = true,
            },
            
            login = {
                            showpass = false,
                            savepass = falso,
            },
            
            registrar = {
                            
            },
            
            teoria-se = {
            
            },

}

function init ()
    triggerServerEvent ("server: init", localPlayer)
end

function showLogin (nome de usuário, senha)
    showChat (false)
    setPlayerHudComponentVisible ("all", false)
    showCursor (true)
    
    lp.gridlist = guiCreateGridList ((sX / 2 - (400 * x) / 2) + (430 * x) + ( 12 * x), sY / 2 - (250 * y) / 2 + 12 * y, 226 * x, 226 * y, falso)
    guiGridListAddColumn (lp.gridlist, "Nome", 0,5)
    guiGridListAddColumn (lp.gridlist, " Cargo ", 0,4)
    
    lp.login.button = dxCreateButton (sX / 2 - (150 * x) / 2, (sY / 2 - (380 * y) / 2) + (260 * y), 150 * x, 40 * y, "Entrar", tocolor (0,0,0,255))
    lp.login.username = dxCreateEdit (sX / 2 - (270 * x) / 2, (sY / 2 - (480 * y) / 2) + 105 * y, 270 * x, 30 * y, 1.5 *
    tamanho da fonte, "Nome") --dxSetEditEnabled (lp.login.username, false)
    se nome de usuário e # nome de usuário> 0 então
        dxSetEditText (lp.login.username, username)
    else
        lp.hasAccount = false
    end
    lp.login.password = dxCreateEdit (sX / 2 - (270 * x) / 2, (sY / 2 - (410 * y) / 2) + (105 * y) + (30 * y) + 7 * y, 270 * x, 30 * y, 1.5 *
    tamanho da fonte, "Senha") dxSetEditMask (lp.login.password, true)
    se senha e #password> 0 então
        dxSetEditText (lp.login.password, senha)
        lp.login.savepass = true
    end
    
    lp.register.button = dxCreateButton ((sX / 2 - (400 * x) / 2 - 280 * x) + (250 * x) / 2 - (100 * x) / 2, (sY / 2 - (250 * y) / 2) + (200 * y), 135 * x, 30 * y, "Registrador", tocolor (0,0,0,255 ))
    lp.register.username = dxCreateEdit ((sX / 2 - (400 * x) / 2 - 280 * x) + (250 * x) / 2 - (170 * x) / 2, (sY / 2 - (250 * y) / 2) + (60 * y), 170 * x, 30 * y, 1,5 *
    tamanho da fonte , "Nome") lp.register.password = dxCreateEdit ((sX / 2 - (400 * x) / 2 - 280 * x) + (250 * x) / 2 - (170 * x) / 2, (sY / 2 - (250 * y) / 2) + (100 * y), 170 * x, 30 * y, 1,5 * fontsize, "Senha")
    dxSetEditMask (lp.register.password, true)
    lp.register.repassword = dxCreateEdit ((sX / 2 - (400 * x) / 2 - 280 * x) + (250 * x) / 2 - (170 * x) / 2, (sY / 2 - (250 * y) / 2) + (140 * y), 170 * x, 30 * y, 1,5 *
    tamanho da fonte , "senha novamente") dxSetEditMask (lp.register .repassword, true)
    
    lp.forgotpass.fpass = dxCreateButton (sX / 2 - (200 * x) / 2, (sY / 2 - (410 * y) / 2) + (330 * y), 200 * x, 20 * y, "Esqueceu sua senha?", tocolor (41.130.206.255), 1 * tamanho da fonte)
    lp.forgotpass.pass = dxCreateEdit ((sX / 2 - (230 * x) / 2), sY / 2 + (410 * y) / 2 + 8 * x + 22 * x + 20 * y, 230 * x, 30 * y, 1,5 *
    tamanho da fonte , "Nova senha") lp.forgotpass.button = dxCreateButton ((sX / 2 - (100 * x) / 2), sY / 2 + (410 * y) / 2 + 8 * x + 22 * x + 70 * y, 100 * x, 20 * y, "Resetar senha", tocolor (0,0,0,255), 1 * tamanho da fonte)
    
    setTime (0,0)
    
    addEventHandler ("onClientRender", root, blurRender )
    addEventHandler ("onClientRender", root, drawLogin)
    addEventHandler ("onClientRender", root, drawRegister)
    addEventHandler ("onClientRender", root, drawAdmins)
    
    triggerServerEvent ("server: getOnlineAdmins", localPlayer)
end

addEvent ("client: init: callBack", true)
addEventHandler ("client: init: callBack", root,
function (username, password)
    showLogin (username, password)
end
)

addEvent ("cliente: registrado", verdadeiro)
addEventHandler ("cliente: registrado", raiz,
função (nome de usuário)
    se nome de usuário então
        removeEventHandler ("onClientRender", raiz, blurRender)
        removeEventHandler ("onClientRender", raiz, drawLogin)
        removeEventHandler (" onClientRender ", root, drawRegister)
        removeEventHandler (" onClientRender ", root, drawAdmins)
        removeEventHandler (" onClientRender ", root, drawForgot)
        destroyElement (lp.blur.screensource)
        destroyElement (lp.blur.shader)
        destroyElement (lp.blur.shader)
        destroyElement (lp.blur.shader) (falso)
        showChat (verdadeiro)
    else
        dxSetButtonEnabled (lp.login.button, true)
    end
fim
)

addEvent ("client: Registered", true)
addEventHandler ("client: Registered", root,
function (username)
    if username then
        dxSetEditText (lp.login.username, username)
        lp.hasAccount = true
    else
        dxSetButtonEnabled (lp.register.button , verdadeiro)
    fim
fim
)

addEvent ("client: Forgotpass: callBack", true)
addEventHandler ("client: Forgotpass: callBack", root,
function (username)
    addEventHandler ("onClientRender", root, drawForgot)
end
)

addEvent ("client: getOnlineAdmins: callBack", true)
addEventHandler ("client: getOnlineAdmins: callBack", root,
function (admins)
    outputChatBox (#admins)
    para k, v em ipairs (admins) do
        local row = guiGridListAddRow (lp. gridlist)
        guiGridListSetItemText (lp.gridlist, row, 1, v.name, false, false)
        guiGridListSetItemColor (lp.gridlist, row, 1,0,255,0)
        guiGridListSetItemText (lp.gridlist, row, 2, v.rank, false, false)
        guiGridListSetItemColor (lp.gridlist, row, 2.0,255,0)
    end
end
)

addEvent ("onClientdxButtonClick", true)
addEventHandler ("onClientdxButtonClick", root,
function (plr)
    if plr == localPlayer then
        if source == lp.login.button then
            local username = dxGetEditText (lp.login.username)
            local password = dxGetEditText (lp.login.password)
            if #username> 0 e #password> 0 then
                triggerServerEvent ("server: login", plr, username, password, lp.login.savepass)
                dxSetButtonEnabled (lp.login.button, false)
            else
                exporta ["guimessages"]: outputServer ("* Entre com nome e senha!", 255, 128, 0)
            end
        elseif source == lp.register.botão então
            local username = dxGetEditText (lp.register.username)
            local password = dxGetEditText (lp.register.password)
            local repassword = dxGetEditText (lp.register.repassword)
            if #username> 0 e #password> 0 então
                se password == repassword então
                    triggerServerEvent ("servidor: registrar", plr, nome de usuário, senha)
                    dxSetButtonEnabled (lp.register.button, false)
                end
            else
                extensions ["guimessages"]: outputServer ("* Entre com nome e senha!", 255, 128, 0 )
            end
        elseif source == lp.forgotpass.fpass then
            triggerServerEvent ("servidor:esqueceu-se ", plr)
        elseif source == lp.forgotpass.button then
            local username = dxGetEditText (lp.login.username)
            if #username> 0 then
                local password = dxGetEditText (lp.forgotpass.pass)
                if #password> 0 then
                    triggerServerEvent ("server: changePassword ", plr, nome de usuário, senha, lp.login.savepass)
                    removeEventHandler (" onClientRender ", root, drawForgot)
                else extensions
                    [" guimessages "]: outputServer (" * Coloque a senha! ", 255, 128, 0)
                end
            else
                exporta ["guimessages"]: outputServer ("* Coloque o nome!", 255, 128,0)
            fim
        fim
    fim
fim
)

addEventHandler ("onClientClick", root,
function (bttn, state)
    if bttn == "left" e state == "down" então
        se isMouseInPosition (sX / 2 - (62 * x) / 2, (sY / 2 - ( 410 * y) / 2) + (190 * y), 62 * x, 26 * y) then
            lp.login.showpass = not lp.login.showpass
            dxSetEditMask (lp.login.password, não lp.login.showpass)
        elseif isMouseInPosition (sX / 2 - (62 * x) / 2, (sY / 2 - (410 * y) / 2) + (190 * y) + 31 * y, 62 * x, 26 * y) depois
            lp. login.savepass = not lp.login.savepass
        end    
    end
end
)

function blurRender ()
    if ( lp.blur.shader ) then
        --if lp.blur.update then
            dxUpdateScreenSource(lp.blur.screensource)
            
            dxSetShaderValue(lp.blur.shader, "ScreenSource", lp.blur.screensource);
            dxSetShaderValue(lp.blur.shader, "UVSize", sX, sY);
            dxSetShaderValue(lp.blur.shader, "BlurStrength", 9 );
            
            --lp.blur.update = false
        --end
                    
        dxDrawImage(0, 0, sX, sY, lp.blur.shader)
    end
end

function drawLogin()
    dxDrawText2("Conectar-se",sX/2 - (400*x)/2,0,400*x,160*y,tocolor(255,255,255,255),5*fontsize,"arial","center","bottom")
    dxDrawRectangle(sX/2 - (400*x)/2,sY/2 - (410*y)/2,400*x,410*y,tocolor(255,255,255,20))
    dxDrawEmptyRectangle(sX/2 - (400*x)/2,sY/2 - (410*y)/2,400*x,410*y,tocolor(0,0,0,100),8*x)
    
    --dxDrawRectangle(sX/2 - (270*x)/2,( sY/2 - (410*y)/2 ) + 105*y,270*x,30*y,tocolor(231,231,239,255))
    dxDrawEdit(lp.login.username)
    dxDrawImage(sX/2 - (270*x)/2 - 35*y,( sY/2 - (410*y)/2 ) + 105*y,30*y,30*y,"img/username.png")
    
    --dxDrawRectangle(sX/2 - (270*x)/2,( sY/2 - (410*y)/2 ) + (105*y) + (30*y) + 7*y,270*x,30*y,tocolor(231,231,239,255))
    dxDrawEdit(lp.login.password)
    dxDrawImage(sX/2 - (270*x)/2 - 35*y,( sY/2 - (410*y)/2 ) + (105*y) + (30*y) + 7*y,30*y,30*y,"img/password.png")
    
    dxDrawText2("Mostrar senha",sX/2 - (62*x)/2 - 105*x,( sY/2 - (410*y)/2 ) + (190*y),62*x,26*y,tocolor(255,255,255,255),1.5*fontsize,"arial","left","center")
    dxDrawImage(sX/2 - (62*x)/2,( sY/2 - (410*y)/2 ) + (190*y),62*x,26*y,lp.login.showpass and "img/on.png" or "img/off.png")
    
    dxDrawText2("Salvar senha",sX/2 - (62*x)/2 - 105*x,( sY/2 - (410*y)/2 ) + (190*y) + 31*y,62*x,26*y,tocolor(255,255,255,255),1.5*fontsize,"arial","left","center")
    dxDrawImage(sX/2 - (62*x)/2,( sY/2 - (410*y)/2 ) + (190*y) + 31*y,62*x,26*y,lp.login.savepass and "img/on.png" or "img/off.png")
    
    --dxDrawRectangle(sX/2 - (150*x)/2,( sY/2 - (410*y)/2 ) + (260*y),150*x,30*y,tocolor(0,0,0,255))
    --dxDrawText2("Login",sX/2 - (150*x)/2,( sY/2 - (410*y)/2 ) + (260*y),150*x,30*y,tocolor(255,255,255,255),2,"default-bold","center","center")
    dxDrawButton(lp.login.button)
    
    --dxDrawRectangle(sX/2 - (200*x)/2,( sY/2 - (410*y)/2 ) + (330*y),200*x,20*y,tocolor(41,130,206,255))
    --dxDrawText2("Forgot your password?",sX/2 - (200*x)/2,( sY/2 - (410*y)/2 ) + (330*y),200*x,20*y,tocolor(255,255,255,255),1,"default-bold","center","center")
    dxDrawButton(lp.forgotpass.fpass)
    dxDrawEmptyRectangle(sX/2 - (200*x)/2,( sY/2 - (410*y)/2 ) + (330*y),200*x,20*y,tocolor(0,0,0,255),1)
end

function drawRegister()
    dxDrawRectangle((sX/2 - (400*x)/2) - 30*x,sY/2 - (250*y)/2 + 25*y,22*x,2,tocolor(0,0,0,150))
    dxDrawRectangle((sX/2 - (400*x)/2) - 30*x,sY/2 - (250*y)/2 + 125*y,22*x,2,tocolor(0,0,0,150))
    dxDrawRectangle((sX/2 - (400*x)/2) - 30*x,sY/2 - (250*y)/2 + 225*y,22*x,2,tocolor(0,0,0,150))
    dxDrawText2("Criar conta",(sX/2 - (400*x)/2) - 280*x,0,250*x,250*y,tocolor(255,255,255,255),3*fontsize,"arial","center","bottom")
    dxDrawRectangle((sX/2 - (400*x)/2) - 280*x,sY/2 - (250*y)/2,250*x,250*y,tocolor(255,255,255,20))
    dxDrawEmptyRectangle((sX/2 - (400*x)/2) - 280*x,sY/2 - (250*y)/2,250*x,250*y,tocolor(0,0,0,100),1)
    
    if not lp.hasAccount then
        --dxDrawRectangle((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (170*x)/2,( sY/2 - (250*y)/2 ) + (60*y),170*x,30*y,tocolor(231,231,239,255))
        dxDrawEdit(lp.register.username)
        dxDrawImage(((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (170*x)/2) - 35*y,( sY/2 - (250*y)/2 ) + (60*y),30*y,30*y,"img/username.png")
        
        --dxDrawRectangle((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (170*x)/2,( sY/2 - (250*y)/2 ) + (100*y),170*x,30*y,tocolor(231,231,239,255))
        dxDrawEdit(lp.register.password)
        dxDrawImage(((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (170*x)/2) - 35*y,( sY/2 - (250*y)/2 ) + (100*y),30*y,30*y,"img/password.png")
        
        --dxDrawRectangle((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (170*x)/2,( sY/2 - (250*y)/2 ) + (140*y),170*x,30*y,tocolor(231,231,239,255))
        dxDrawEdit(lp.register.repassword)
        dxDrawImage(((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (170*x)/2) - 35*y,( sY/2 - (250*y)/2 ) + (140*y),30*y,30*y,"img/password.png")
        
        --dxDrawRectangle((sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (100*x)/2,( sY/2 - (250*y)/2 ) + (200*y),100*x,30*y,tocolor(0,0,0,255))
        --dxDrawText2("Register",(sX/2 - (400*x)/2 - 280*x) + (250*x)/2 - (100*x)/2,( sY/2 - (250*y)/2 ) + (200*y),100*x,30*y,tocolor(255,255,255,255),2,"default-bold","center","center")
        dxDrawButton(lp.register.button)
    else
        dxDrawText2("Você só pode se registrar uma vez",(sX/2 - (400*x)/2) - 280*x,sY/2 - (250*y)/2,250*x,250*y,tocolor(255,255,255,255),1.3*fontsize,"default-bold","center","center")
    end
end

function drawAdmins()
    dxDrawRectangle((sX/2 - (400*x)/2) + 405*x,sY/2 - (250*y)/2 + 25*y,25*x,2,tocolor(0,0,0,150))
    dxDrawRectangle((sX/2 - (400*x)/2) + 405*x,sY/2 - (250*y)/2 + 125*y,25*x,2,tocolor(0,0,0,150))
    dxDrawRectangle((sX/2 - (400*x)/2) + 405*x,sY/2 - (250*y)/2 + 225*y,25*x,2,tocolor(0,0,0,150))
    dxDrawText2("Adiministração",(sX/2 - (400*x)/2) + 430*x,0,250*x,250*y,tocolor(255,255,255,255),3*fontsize,"arial","center","bottom")
    dxDrawRectangle((sX/2 - (400*x)/2) + 430*x,sY/2 - (250*y)/2,250*x,250*y,tocolor(255,255,255,20))
    dxDrawEmptyRectangle((sX/2 - (400*x)/2) + 430*x,sY/2 - (250*y)/2,250*x,250*y,tocolor(0,0,0,100),1)
    
    dxDrawRectangle((sX/2 - (400*x)/2) + (430*x) + (10*x),sY/2 - (250*y)/2 + 10*y,230*x,230*y,tocolor(57,52,57,255))
end

function drawForgot()
    dxDrawRectangle((sX/2 - (400*x)/2) + 200*x,sY/2 + (410*y)/2 + 8*x,2,22*x,tocolor(0,0,0,150))
    dxDrawRectangle((sX/2 - (250*x)/2),sY/2 + (410*y)/2  + 8*x + 22*x,250*x,100*y,tocolor(255,255,255,20))
    dxDrawEmptyRectangle((sX/2 - (250*x)/2),sY/2 + (410*y)/2  + 8*x + 22*x,250*x,100*y,tocolor(0,0,0,100),1)
    
    --dxDrawRectangle((sX/2 - (230*x)/2),sY/2 + (410*y)/2  + 8*x + 22*x + 20*y,230*x,30*y)
    dxDrawEdit(lp.forgotpass.pass)
    
    --dxDrawRectangle((sX/2 - (100*x)/2),sY/2 + (410*y)/2  + 8*x + 22*x + 70*y,100*x,20*y)
    dxDrawButton(lp.forgotpass.button)
end

addEventHandler("onClientResourceStart",resourceRoot,
function()
    init()
end
)

 

 

 

 

 

 

 

function dxDrawEmptyRectangle(startX, startY, endX, endY, color, width, postGUI)
    dxDrawRectangle(startX-width,startY-width,endX+width,width,color,postGUI) -- top
    dxDrawRectangle(startX-width,startY+endY,endX+width,width,color,postGUI) -- bottom
    dxDrawRectangle(startX-width,startY,width,endY,color,postGUI) -- left
    dxDrawRectangle(startX+endX,startY-width,width,endY+width+width,color,postGUI) -- right
end

function dxDrawText2(t,x,y,w,h,...)
    return dxDrawText(t,x,y,x+w,y+h,...)
end

function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
 
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

local function getn(table)
    local a7 = 0
    for k,v in pairs(table) do
        a7 = a7+1
    end
    return a7
end


----- ALw7sH dxlib 1.0.0
--- dx button

local button = {
data = {}
}

function dxCreateButton(x,y,w,h,text,color,textSize,postGUI)
    local theButton = createElement("dxButton")
    if getn(button.data) < 1 then
        addEventHandler("onClientClick",root,buttonClick)
    end
    button.data[theButton] = {x=x,y=y,w=w,h=h,text=text,color=color,textSize=textSize,postGUI=postGUI or false,alpha=0,hover=false,enabled=true}
    return theButton
end

function dxDrawButton(Button)
    if isElement(Button) and getElementType(Button) == "dxButton" then
        local d = button.data[Button]
        
        if isMouseInPosition(d.x,d.y,d.w,d.h) and d.enabled then
            button.data[Button].hover = true
        else
            button.data[Button].hover = false
        end
        dxDrawRectangle(d.x,d.y,d.w,d.h,d.color,d.postGUI)
        dxDrawText(d.text,d.x,d.y,d.x+d.w,d.y+d.h,tocolor(255,255,255,255),d.textSize or 2,"default-bold","center","center",true,false,d.postGUI)
    end
end

function dxSetButtonEnabled(Button,bool)
    if isElement(Button) and getElementType(Button) == "dxButton" then
        button.data[Button].enabled = bool
    end
end

function dxDestroyButton(Button)
    if isElement(Button) and getElementType(Button) == "dxButton" then
        button.data[Button] = nil
        destroyElement(button)
    end
end


function buttonClick(bttn,state)
    if bttn == "left" and state == "down" then
        local buttons = getElementsByType("dxButton")
        if #buttons > 0 then
            for i=1,#buttons do
                if button.data[buttons] then
                    local hover = button.data[buttons].hover
                    if hover == true then
                        triggerEvent("onClientdxButtonClick",buttons,localPlayer)
                        button.data[buttons].hover = false
                        break
                    end
                end
            end
        end
    end
end

--- edit

local edit = {
data = {}
}

function dxCreateEdit(x,y,w,h,textSize,defaulttext,icon,maxlength,mask,postGUI)
    local theEdit = createElement("dxEdit")
    if getn(edit.data) < 1 then
        addEventHandler("onClientCharacter", getRootElement(), addCharacterToEdit)
        addEventHandler("onClientKey", root, backspace)
    end
    edit.data[theEdit] = {x=x,y=y,w=w,h=h,textSize=textSize,dt=defaulttext,icon=icon,ml=maxlength,mask=mask or false,postGUI=postGUI or false, text="",hover=false,clicked=false,selectAll=false,enabled=true}
    return theEdit
end

function dxDrawEdit(Edit)
    if isElement(Edit) and getElementType(Edit) == "dxEdit" then
        local d = edit.data[Edit]
        d.text = tostring(d.text)
        local text = (d.clicked and (d.mask and string.rep("*",#d.text) or d.text)) or (string.len(d.text) > 0 and (d.mask and string.rep("*",#d.text) or d.text)) or (d.dt ~= nil and d.dt or d.text)
        
        if getKeyState("mouse1") then
            if isMouseInPosition ( d.x, d.y, d.w, d.h ) and d.enabled then
                if not d.clicked then
                    edit.data[Edit].clicked = true
                    guiSetInputEnabled(true)
                end
            else
                if d.clicked then
                    edit.data[Edit].clicked = false
                    guiSetInputEnabled(false)
                end
            end
        end
        if d.clicked then if not guiGetInputEnabled() then guiSetInputEnabled(true) end end
        
        dxDrawRectangle(d.x,d.y,d.w,d.h,tocolor(231,231,239,255),d.postGUI)
        
        local tX = type(d.icon) == "string" and d.x+d.h+(d.h/3) or d.x+(d.h/3)
        local tXx = d.x+d.h-((d.h/2)*3)
        dxDrawText(text,tX,d.y,(tXx)+d.w,d.y+d.h,tocolor(0,0,0,255),d.textSize or 1,"default-bold","left","center",true,false,d.postGUI)
        if d.selectAll then
            local tW = dxGetTextWidth(text,d.textSize or 1,"default-bold")
            local tH = dxGetFontHeight(d.textSize or 1,"default-bold")
            dxDrawRectangle(tX,d.y+(tH/2),tW,tH,tocolor(63,63,63,100),d.postGUI)
        end
    end
end
guiSetInputEnabled(false)

function dxDestroyEdit(Edit)
    if isElement(Edit) and getElementType(Edit) == "dxEdit" then
        edit.data[Edit] = nil
        destroyElement(Edit)
    end
end

function dxSetEditEnabled(Edit,en)
    if isElement(Edit) and getElementType(Edit) == "dxEdit" then
        edit.data[Edit].enabled = en
    end
end

function dxSetEditMask(Edit,m)
    if isElement(Edit) and getElementType(Edit) == "dxEdit" then
        edit.data[Edit].mask = m
    end
end

function dxSetEditText(Edit,text)
    if isElement(Edit) and getElementType(Edit) == "dxEdit" then
        edit.data[Edit].text = text
    end
end

function dxGetEditText(Edit)
    if isElement(Edit) and getElementType(Edit) == "dxEdit" then
        return edit.data[Edit].text
    end
end

function addCharacterToEdit(character)
    if character == " " then return end
    if string.byte(character) < 32 or string.byte(character) > 127 then return end
    local Edit = getElementsByType("dxEdit")
    for i=1,#Edit do    
        if edit.data[Edit] then
            if edit.data[Edit].clicked == true then
                if edit.data[Edit].selectAll == true then
                    edit.data[Edit].selectAll = false
                    edit.data[Edit].text = ""
                end
                if edit.data[Edit].ml ~= nil then
                    if #edit.data[Edit].text < edit.data[Edit].ml then
                    edit.data[Edit].text = edit.data[Edit].text..character
                    end
                else
                    edit.data[Edit].text = edit.data[Edit].text..character
                end
            end
        end
    end
end

function backspace(key,sm)
    if sm then
        local Edit = getElementsByType("dxEdit")
        for i=1,#Edit do    
            if edit.data[Edit] then
                if edit.data[Edit].clicked == true then
                    if string.len(edit.data[Edit].text) > 0 and key == "backspace" then
                        if edit.data[Edit].selectAll == false then
                            edit.data[Edit].text = string.sub(edit.data[Edit].text,1,string.len(edit.data[Edit].text)-1)
                        else
                            edit.data[Edit].selectAll = false
                            edit.data[Edit].text = ""
                        end
                    elseif getKeyState("lctrl") and key == "a" or getKeyState("rctrl") and key == "a" then
                        edit.data[Edit].selectAll = not edit.data[Edit].selectAll
                    end
                end
            end
        end
    end
end

 

 

 

 

 

 

 

local admins = {
"Admin",
"Moderator",
"Console",
}

local outputChatBox_ = outputChatBox
function outputChatBox(player,text,r,g,b,color)
    return outputChatBox_(text,player or root,r or 255,g or 255,b or 255,color or false)
end

addEvent("server:init",true)
addEventHandler("server:init",root,
function()
    executeSQLQuery("CREATE TABLE IF NOT EXISTS `a7_accounts` (`account_name` TEXT, `account_password` TEXT,`account_serial` TEXT)")
    local account = executeSQLQuery("SELECT * FROM `a7_accounts` WHERE `account_serial`=? LIMIT 1",getPlayerSerial(client))
    local username
    local password
    if #account > 0 then
        username = account[1].account_name
        password = account[1].account_password
    end
    triggerClientEvent(client,"client:init:callBack",client,username,password)
end
)

addEvent("server:getOnlineAdmins",true)
addEventHandler("server:getOnlineAdmins",root,
function()
    local a = {}
    for k,group in ipairs(admins) do
        for k,v in ipairs(aclGroupListObjects(aclGetGroup(group))) do
            if v:find("user.") then
                local player = getAccountPlayer(getAccount(v:gsub("user.",""),nil))
                if player then
                    table.insert(a,{name=getPlayerName(player):gsub("#%x%x%x%x%x%x",""),rank=group})
                end
            end
        end
    end
    triggerClientEvent(client,"client:getOnlineAdmins:callBack",client,a)
end
)

addEvent("server:login",true)
addEventHandler("server:login",root,
function(username,password,savepass)
    local account = getAccount(username,password)
    if account then
        logIn(client,account,password)
        triggerClientEvent(client,"client:loggedIn",client,username)
        local account = executeSQLQuery("SELECT * FROM `a7_accounts` WHERE `account_serial`=? LIMIT 1",getPlayerSerial(client))
        local pass = savepass and password or ""
        if #account > 0 then
            executeSQLQuery("UPDATE `a7_accounts` SET `account_password`=? WHERE `account_serial`=?",pass,getPlayerSerial(client))
        else
            executeSQLQuery("INSERT INTO `a7_accounts` VALUES(?,?,?)",username,pass,getPlayerSerial(client))
        end
        --exports.GameMod:loadacc(client)
    else
        outputChatBox(client, "* A senha ou nome está errada!", 255, 128, 0)
    end
    triggerClientEvent(client,"client:loggedIn",client) 
end
)

addEvent("server:register",true)
addEventHandler("server:register",root,
function(username,password)
    if addAccount(username,password) then
        executeSQLQuery("INSERT INTO `a7_accounts` VALUES(?,?,?)",username,"",getPlayerSerial(client))
        triggerClientEvent(client,"client:Registered",client,username)
    else
        outputChatBox(client, "* Essa conta já existe!", 255, 128, 0)
    end
    triggerClientEvent(client,"client:Registered",client,false)
end
)

addEvent("server:forgotpass",true)
addEventHandler("server:forgotpass",root,
function()
    local account = executeSQLQuery("SELECT * FROM `a7_accounts` WHERE `account_serial`=? LIMIT 1",getPlayerSerial(client))
    if account then
        triggerClientEvent(client,"client:forgotpass:callBack",client)
    end
end
)

addEvent("server:changePassword",true)
addEventHandler("server:changePassword",root,
function(username,password,save)
    local account = getAccount(username)
    if account then
        local account = executeSQLQuery("SELECT * FROM `a7_accounts` WHERE `account_serial`=? AND `account_name`=? LIMIT 1",getPlayerSerial(client),username)
        if #account > 0 then
            setAccountPassword(account,password)
            if save then
                executeSQLQuery("UPDATE `a7_accounts` SET `account_password`=? WHERE `account_serial`=?",password,getPlayerSerial(client))
            end
        else
            outputChatBox(client, "* Essa não é sua conta!", 255, 128, 0)
        end
    else
        outputChatBox(client, "* Conta invalida!", 255, 128, 0)
    end
end
)

 

 

 

 

<meta>
    <!-- FILES -->
    <file src="img/username.png" />
    <file src="img/password.png" />
    
    <file src="img/off.png" />
    <file src="img/on.png" />
    
    <file src="img/blur.fx" />

    <!-- SERVER -->
    <script src="server_main.lua" type="server" />
    
    <!-- CLIENT -->
    <script src="client_util.lua" type="client" />
    <script src="client_main.lua" type="client" />
</meta>

 

 

 

texture ScreenSource;
float BlurStrength;
float2 UVSize;

sampler TextureSampler = sampler_state
{
    Texture = <ScreenSource>;
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;
    AddressU = Wrap;
    AddressV = Wrap;
};

static const float2 poisson[16] = 
{
        float2(-0.326212f, -0.40581f),
        float2(-0.840144f, -0.07358f),
        float2(-0.695914f, 0.457137f),
        float2(-0.203345f, 0.620716f),
        float2(0.96234f, -0.194983f),
        float2(0.473434f, -0.480026f),
        float2(0.519456f, 0.767022f),
        float2(0.185461f, -0.893124f),
        float2(0.507431f, 0.064425f),
        float2(0.89642f, 0.412458f),
        float2(-0.32194f, -0.932615f),
        float2(-0.65432f, -0.87421f),
        float2(-0.456899f, -0.633247f),
        float2(-0.123456f, -0.865433f),
        float2(-0.664332f, -0.25680f),
        float2(-0.791559f, -0.59771f)
};

float4 PixelShaderFunction (float2 TextureCoordinate: TEXCOORD0): COLOR0
{    
    float4 color = tex2D (TextureSampler, TextureCoordinate);
    
    para (int i = 0; i <16; i ++)
    {
        float2 coord = TextureCoordinate.xy + (poisson / UVSize * BlurStrength);
        cor + = tex2D (TextureSampler, coord);
    }

    retorno (cor / 17);
}
 
Técnica BlurShader
{
    Passar pass1
    { PixelShader
        = compilar ps_2_0 PixelShaderFunction ();
    }
}

 

 

 

 

 

 

 

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