Jump to content

Login Bindkey


Corey123

Recommended Posts

Hola quiero saber si se puede hacer que cuando entren al server , no les aparesca el cartel de login sino que tengan que apretar F5 ejemplo , osea entras al server play , freeroam , y si se quieren registrar que apreten F5 y qe cuando ya esten logeados no se pueda utilisar mas el F5 lo quiero hacer con este login

login

https://community.multitheftauto.com/ind ... ils&id=617

y aca les paso los lua

x,y = guiGetScreenSize() 
  
LoginWin = guiCreateWindow(x/2 - 150,y/2 - 110,300,220,"Identify yourself",false) 
  
TabPanel = guiCreateTabPanel(17,30,261,152,false,LoginWin) 
  
TabLogin = guiCreateTab("Login",TabPanel) 
LblUsername = guiCreateLabel(11,27,70,16,"Username",false,TabLogin) 
LoginUsername = guiCreateEdit(76,26,171,21,"",false,TabLogin) 
LblPassword = guiCreateLabel(11,60,70,16,"Password",false,TabLogin) 
LoginPassword = guiCreateEdit(76,58,171,21,"",false,TabLogin) 
guiEditSetMasked(LoginPassword,true) 
  
TabRegister = guiCreateTab("Register",TabPanel) 
LblRegisterUsername = guiCreateLabel(11,27,70,16,"Username",false,TabRegister) 
EditRegisterUsername = guiCreateEdit(76,26,171,21,"",false,TabRegister) 
LblRegisterPassword = guiCreateLabel(11,60,70,16,"Password",false,TabRegister) 
EditRegisterPassword = guiCreateEdit(76,58,171,21,"",false,TabRegister) 
guiEditSetMasked(EditRegisterPassword,true) 
LblRegisterEmail = guiCreateLabel(35,92,35,16,"Email",false,TabRegister) 
EditRegisterEmail = guiCreateEdit(76,90,171,21,"",false,TabRegister) 
  
BtnAction = guiCreateButton(182,188,95,19,"Go",false,LoginWin) 
  
guiSetVisible(LoginWin, false) 
  
local localPlayer = getLocalPlayer() 
  
function receiveVars( allow, email) 
  
    local playername = getPlayerName(localPlayer) 
     
    guiSetText(LoginUsername, "") 
    guiSetText(EditRegisterUsername, "") 
     
    if (email == "false") then 
        guiSetVisible(LblRegisterEmail, false) 
        guiSetVisible(EditRegisterEmail, false) 
    end 
     
    if (allow == "false") then 
        guiDeleteTab(TabRegister, TabPanel) 
    end 
     
    guiSetSelectedTab(TabPanel, TabLogin) 
    guiSetText(LoginUsername, playername) 
    guiSetText(EditRegisterUsername, playername) 
  
    guiSetVisible(LoginWin, true) 
    guiBringToFront(LoginWin) 
     
    guiSetInputEnabled(true) 
    showCursor(true) 
end 
addEvent( "onSendVars", true ) 
addEventHandler( "onSendVars", getRootElement(), receiveVars ) 
  
function windowHandler() 
    triggerServerEvent("onNeedVars", getLocalPlayer()) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler) 
  
function onClickBtn(button, state) 
    if(button == "left" and state == "up") then 
        if(source == BtnAction) then 
            if(guiGetSelectedTab(TabPanel) == TabLogin) then 
                triggerServerEvent("on4XLogin", getRootElement(), localPlayer, guiGetText(LoginUsername), guiGetText(LoginPassword)) 
            else 
                triggerServerEvent("on4XRegister", getRootElement(), localPlayer, guiGetText(EditRegisterUsername), guiGetText(EditRegisterPassword), guiGetText(EditRegisterEmail)) 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIClick", BtnAction, onClickBtn, false) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 

function on4XLogin ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if ( not isGuestAccount ( account ) ) then -- For every player that's logged in.... 
            logOut ( player ) -- Log them out. 
        end 
         
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( player, "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong. 
    end 
end 
addEvent( "on4XLogin", true ) 
addEventHandler( "on4XLogin", getRootElement(), on4XLogin ) 
  
function on4XRegister ( player, user, pass, email ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( player, "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    else 
        account = addAccount ( user, pass ) 
        setAccountData ( account, "email", email) 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( player, "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    end 
end 
addEvent( "on4XRegister", true ) 
addEventHandler( "on4XRegister", getRootElement(), on4XRegister ) 
  
function needVars() 
    local allow_register = get("allow_register") 
    local email_on_register = get("email_on_register") 
    triggerClientEvent(source, "onSendVars", getRootElement(), allow_register, email_on_register) 
end 
addEvent("onNeedVars", true) 
addEventHandler("onNeedVars", getRootElement(), needVars) 

como puedo hacer para que con este login hago lo que quiero ?

Link to comment
  • Recently Browsing   0 members

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