Jump to content

Scripting Log/Reg Panel


Chris!i!

Recommended Posts

-Client

GUIEditor = { 
    tab = {}, 
    tabpanel = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    label = {}, 
    memo = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(321, 107, 626, 612, "GTs Login or Register Panel", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 312, 607, 290, false, GUIEditor.window[1]) 
  
        GUIEditor.tab[1] = guiCreateTab("Updates", GUIEditor.tabpanel[1]) 
  
        GUIEditor.memo[1] = guiCreateMemo(10, 10, 582, 241, "", false, GUIEditor.tab[1]) 
  
  
        GUIEditor.button[1] = guiCreateButton(9, 142, 121, 61, "Login", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(194, 142, 121, 61, "Register", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(11, 30, 96, 34, "UserName : ", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(11, 92, 96, 34, "Password : ", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(125, 30, 161, 38, "", false, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(125, 88, 161, 38, "", false, GUIEditor.window[1])     
    end 
) 
  
  
  
local localPlayer = getLocalPlayer ( ) 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
     
    guiSetText(GUIEditor.edit[1], "") 
    guiSetText(GUIEditor.edit[2], "") 
  
    guiSetText(GUIEditor.edit[1], playername) 
    guiSetText(GUIEditor.edit[2], playername) 
  
    guiSetVisible (  GUIEditor.window[1], true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function login ( button, state ) 
    if (source == GUIEditor.button[1]) then 
        triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) 
    end 
end 
  
function register ( button, state ) 
    if (source == GUIEditor.button[2]) then 
        triggerServerEvent ( "onRegister", getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) 
    end 
end 
  
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], login, false ) 
addEventHandler ( "onClientGUIClick", GUIEditor.button[2], register, false ) 

--Server

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 ( "Login error!", player, 255, 255, 0 ) 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) 
    end 
end 
  
addEvent( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) 
        end 
    end 
end 
  
addEvent( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 

Help me with that login panel i can not login either register and in debugscript 3 there is no errors i fixed them all !

Link to comment
  
function onLogin ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
            logIn ( player, account, pass ) 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) 
        end 
end 
  
addEvent( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account == false ) then 
           account = addAccount ( user, pass ) 
            logIn ( player, account, pass ) 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) 
    end 
end 
  
addEvent( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 
  

Link to comment

Replace your client side with this

GUIEditor = { 
    tab = {}, 
    tabpanel = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    label = {}, 
    memo = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(321, 107, 626, 612, "GTs Login or Register Panel", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 312, 607, 290, false, GUIEditor.window[1]) 
  
        GUIEditor.tab[1] = guiCreateTab("Updates", GUIEditor.tabpanel[1]) 
  
        GUIEditor.memo[1] = guiCreateMemo(10, 10, 582, 241, "", false, GUIEditor.tab[1]) 
  
  
        GUIEditor.button[1] = guiCreateButton(9, 142, 121, 61, "Login", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(194, 142, 121, 61, "Register", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(11, 30, 96, 34, "UserName : ", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(11, 92, 96, 34, "Password : ", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(125, 30, 161, 38, "", false, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(125, 88, 161, 38, "", false, GUIEditor.window[1])     
    end 
) 
  
  
  
local localPlayer = getLocalPlayer ( ) 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    
    guiSetText(GUIEditor.edit[1], "") 
    guiSetText(GUIEditor.edit[2], "") 
  
    guiSetText(GUIEditor.edit[1], playername) 
    guiSetText(GUIEditor.edit[2], playername) 
  
    guiSetVisible (  GUIEditor.window[1], true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
function login ( button, state ) 
    if (source == GUIEditor.button[1]) then 
        triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) 
    end 
end 
 addEventHandler ( "onClientGUIClick", guiRoot, login, false ) 
  
function register ( button, state ) 
    if (source == GUIEditor.button[2]) then 
        triggerServerEvent ( "onRegister", getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) 
    end 
end 
 addEventHandler ( "onClientGUIClick", guiRoot, register, false ) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  

Link to comment

Try now

Client:

GUIEditor = { 
    tab = {}, 
    tabpanel = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    label = {}, 
    memo = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(321, 107, 626, 612, "GTs Login or Register Panel", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 312, 607, 290, false, GUIEditor.window[1]) 
        GUIEditor.tab[1] = guiCreateTab("Updates", GUIEditor.tabpanel[1]) 
        GUIEditor.memo[1] = guiCreateMemo(10, 10, 582, 241, "", false, GUIEditor.tab[1]) 
        GUIEditor.button[1] = guiCreateButton(9, 142, 121, 61, "Login", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(194, 142, 121, 61, "Register", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(11, 30, 96, 34, "UserName : ", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(11, 92, 96, 34, "Password : ", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(125, 30, 161, 38, "", false, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(125, 88, 161, 38, "", false, GUIEditor.window[1])     
    end) 
  
local localPlayer = getLocalPlayer ( ) 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    guiSetText(GUIEditor.edit[1], "") 
    guiSetText(GUIEditor.edit[2], "") 
    guiSetText(GUIEditor.edit[1], playername) 
    guiSetVisible (  GUIEditor.window[1], true ) 
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
function login () 
    if (source == GUIEditor.button[1]) then 
        triggerServerEvent ( "onLogin",getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) 
    end 
end 
 addEventHandler ( "onClientGUIClick", guiRoot, login ) 
  
function register () 
    if (source == GUIEditor.button[2]) then 
        triggerServerEvent ( "onRegister",getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) 
    end 
end 
 addEventHandler ( "onClientGUIClick", guiRoot, register) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  

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