Jump to content

Ayuda con login


Julian09123

Recommended Posts

Client.lua :

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
blackLoginScreen = false 
blackScreenTime = 0 
EnableMTAControlsOnLogin = true 
  
  
  
Panel = guiCreateWindow(164,133,461,340,"GH Login Panel",false) 
guiWindowSetMovable(Panel,true) 
guiWindowSetSizable(Panel,false) 
guiSetAlpha(Panel,1) 
Imagen = guiCreateStaticImage(38,30,379,109,"images/!Flip.png",false,Panel) 
btn1 = guiCreateButton(313,289,139,42,"Login / Register",false,Panel) 
guiSetFont(btn1,"default-bold-small") 
labelNickLogin = guiCreateLabel(210,168,109,29,"Nick",false,Panel) 
guiLabelSetVerticalAlign(labelNickLogin,"top") 
guiLabelSetHorizontalAlign(labelNickLogin,"left",false) 
guiSetFont(labelNickLogin,"default-bold-small") 
labelPassLogin = guiCreateLabel(207,229,109,29,"Pass",false,Panel) 
guiLabelSetVerticalAlign(labelPassLogin,"top") 
guiLabelSetHorizontalAlign(labelPassLogin,"left",false) 
guiSetFont(labelPassLogin,"default-bold-small") 
editLogin1 = guiCreateEdit(116,190,213,28,"",false,Panel) 
guiSetAlpha(editLogin1,1) 
editPass2 = guiCreateEdit(115,253,213,28,"",false,Panel) 
guiSetAlpha(editPass2,1) 
labelby = guiCreateLabel(8,317,192,23,"By : Julian",false,Panel) 
guiSetFont(labelby,"default-bold-small") 
label1 = guiCreateLabel(12,137,109,29,"Login/Register",false,Panel) 
  
guiSetVisible ( Panel, false ) 
  
local localPlayer = getLocalPlayer ( ) 
  
function windowHandler( ) 
  
    if blackLoginScreen == true then 
        fadeCamera(false,0,0,0,0) 
    end 
     
    toggleAllControls(EnableMTAControlsOnLogin) 
         
         
    local playername = getPlayerName(localPlayer) 
     
    guiSetText(editLogin1, "") 
  
    guiSetText(editLogin1, playername) 
  
    guiSetVisible (  Panel, true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
    if (source == btn1) then 
        triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(editLogin1), guiGetText(editPass2) ) 
    end 
end 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( Panel, false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
addEventHandler ( "onClientGUIClick", btn1, onClickBtn, false ) 
addEventHandler ( "onClientGUIClick", btn1, onClickBtn2, false ) 

Server.lua :

function onLogin ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Error al loguearse", player, 255, 0, 0 ) 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "", player, 255, 255, 0 ) 
        end 
    end 
end 
addEvent( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 

Link to comment
  • Recently Browsing   0 members

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