Jump to content

Login panel


Spice

Recommended Posts

Why it's not working when i enter a valid account name and pw ?

There isn't debugscript output tho

Client

addEventHandler ( "onClientGUIClick", root, 
   function () 
   if (source == logi) then 
 acc = guiGetText (acctype) 
 pw = guiGetText (pwtype) 
            triggerServerEvent ("login", getRootElement(), getLocalPlayer(), acc, pw) 
end 
   end 
   ) 
  
   panel = guiCreateWindow(357, 119, 319, 277, "Login Panel", false) 
        guiWindowSetSizable(panel, false) 
  
        acctype = guiCreateEdit(74, 74, 158, 34, "", false, panel) 
        pwtype = guiCreateEdit(74, 143, 158, 34, "", false, panel) 
        guiEditSetMasked ( pwtype, true ) 
        lab1 = guiCreateLabel(9, 82, 55, 16, "Account :", false, panel) 
        lab2 = guiCreateLabel(10, 151, 64, 16, "Password :", false, panel) 
        logi = guiCreateButton(26, 211, 116, 39, "Login", false, panel) 
        create = guiCreateButton(190, 211, 116, 39, "Create Account", false, panel)     
        guiSetVisible (panel, false) 
         
function ShowWindow1 ( ) 
    guiSetVisible ( panel,true ) 
    showCursor ( true ) 
  
end 
addEvent( "onJoin", true ) 
addEventHandler( "onJoin", localPlayer, ShowWindow1 ) 
         

Server

function ShowWindow1 ( ) 
    triggerClientEvent ( source, "onJoin", source ) 
    setCameraMatrix ( source, -1630.71509, 440.49222, 142.57805, -1540.49854, 600.08282, 69.90792 ) 
end 
addEventHandler("onPlayerJoin",root,ShowWindow1) 
  
addEvent ( "login", true ) 
addEventHandler ("login", root, 
function () 
local account = getAccount (acc, pw) 
        if ( account ~= false ) then  
            logIn ( source, acc, pw ) 
            else 
            outputChatBox ( "Wrong username or password!", thePlayer, 255, 255, 0 )  
end 
end  
) 

Link to comment

Try this

addEvent ( "login", true ) 
addEventHandler ("login", root, 
function (thePlayer, acc, pw) 
local account = getAccount (acc, pw) 
        if ( account ~= false ) then 
            logIn ( thePlayer, acc, pw ) 
            else 
            outputChatBox ( "Wrong username or password!", thePlayer, 255, 255, 0 ) 
end 
end 

Link to comment
Try this
addEvent ( "login", true ) 
addEventHandler ("login", root, 
function (thePlayer, acc, pw) 
local account = getAccount (acc, pw) 
        if ( account ~= false ) then 
            logIn ( thePlayer, acc, pw ) 
            else 
            outputChatBox ( "Wrong username or password!", thePlayer, 255, 255, 0 ) 
end 
end 

Thanks <3

Link to comment
1 more question, how to disable /login command

/login and /register commands are default functions of admin resource. You can search for them there and remove it.

can't find it :/, aslo how to use GUIsetVisible to hide the gui if the player was logged in ?

addEvent ( "login", true ) 
addEventHandler ("login", root, 
function (thePlayer, acc, pw) 
local account = getAccount (acc, pw) 
        if ( account ~= false ) then 
            logIn ( thePlayer, acc, pw ) 
            -- I want to hide the gui now where should i add GUISetVisible ? 
            else 
            outputChatBox ( "Wrong username or password!", thePlayer, 255, 255, 0 ) 
end 
end 

Link to comment

Rather than searching for the login/register commands in the admin resource, you can deny access to them in acl.xml. If you still don't want to do that for whatever reason but don't want to search for the script, then you can do something like this to block the command from being created:

local _addCommandHandler = addCommandHandler 
  
function addCommandHandler ( ... ) 
    local args = { ... } 
     
    if ( args [ 1 ]:lower ( ) == "login" or args [ 1]:lower( ) == "register" ) then 
        return false; 
    end  
     
    return _addCommandHandler ( ... ) 
     
end  

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