Jump to content

Help With Login Script


Timic

Recommended Posts

Posted (edited)

Hey,

I made a login script but i had on a problem but i dont know what's the problem

And here's my code:

Client-Side:

  
LoginWin = guiCreateWindow(532,337,359,234,"LoGiN SySTeM v1.0",false) 
GUIEditor_Label[1] = guiCreateLabel(26,64,61,18,"Username:",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[1],255,139,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
GUIEditor_Label[2] = guiCreateLabel(52,181,5,5,"",false,GUIEditor_Label[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) 
GUIEditor_Label[3] = guiCreateLabel(26,108,61,18,"Password:",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[3],255,139,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false) 
usernameEditLogin = guiCreateEdit(92,59,228,31,"",false,LoginWin) 
passwordEditLogin = guiCreateEdit(92,103,228,31,"",false,LoginWin) 
logbtn = guiCreateButton(22,171,138,22,"Log In",false,LoginWin) 
regbtn = guiCreateButton(197,171,138,22,"Register",false,LoginWin) 
guestbtn = guiCreateButton(22,199,313,23,"Guest",false,LoginWin) 
GUIEditor_Label[4] = guiCreateLabel(127,28,107,16,"Log in or Register.",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[4],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false) 
guiSetFont(GUIEditor_Label[4],"default-bold-small") 
  
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(usernameEditLogin, playername) 
    guiSetText(usernameEditPassword, 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 == logbtn) then 
                triggerServerEvent("onLogin", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", logbtn, onClickBtn, false) 
  
function onClickBtn1(button, state) 
    if(button == "left" and state == "up") then 
        if(source == regbtn) then 
                triggerServerEvent("onRegister", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", regbtn, onClickBtn, false) 
  
function onClickBtn2(button, state) 
    if(button == "left" and state == "up") then 
        if(source == guestbtn) then 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", guestbtn, onClickBtn, false) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 

Server-Side:

function onLogin ( 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( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( 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( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 
  
  
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) 

EDITS:

I dont know what's wrong again!:

mta-screen2010-10-2822-0.png

Edited by Guest

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

ehmm.. How i can get reply?

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

your window is called LoginWin and not GUIEditor_Window[1]

Example

GUIEditor_Label[1] = guiCreateLabel(26,64,61,18,"Username:",false,GUIEditor_Window[1])

needs to be

GUIEditor_Label[1] = guiCreateLabel(26,64,61,18,"Username:",false,LoginWin)

this should work

LoginWin = guiCreateWindow(532,337,359,234,"LoGiN SySTeM v1.0",false) 
GUIEditor_Label[1] = guiCreateLabel(26,64,61,18,"Username:",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[1],255,139,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
GUIEditor_Label[2] = guiCreateLabel(52,181,5,5,"",false,GUIEditor_Label[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) 
GUIEditor_Label[3] = guiCreateLabel(26,108,61,18,"Password:",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[3],255,139,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false) 
usernameEditLogin = guiCreateEdit(92,59,228,31,"",false,LoginWin) 
passwordEditLogin = guiCreateEdit(92,103,228,31,"",false,LoginWin) 
logbtn = guiCreateButton(22,171,138,22,"Log In",false,LoginWin) 
regbtn = guiCreateButton(197,171,138,22,"Register",false,LoginWin) 
guestbtn = guiCreateButton(22,199,313,23,"Guest",false,LoginWin) 
GUIEditor_Label[4] = guiCreateLabel(127,28,107,16,"Log in or Register.",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[4],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false) 
guiSetFont(GUIEditor_Label[4],"default-bold-small") 
  
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(usernameEditLogin, playername) 
    guiSetText(usernameEditPassword, 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 == logbtn) then 
                triggerServerEvent("onLogin", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", logbtn, onClickBtn, false) 
  
function onClickBtn1(button, state) 
    if(button == "left" and state == "up") then 
        if(source == regbtn) then 
                triggerServerEvent("onRegister", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", regbtn, onClickBtn, false) 
  
function onClickBtn2(button, state) 
    if(button == "left" and state == "up") then 
        if(source == guestbtn) then 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", guestbtn, onClickBtn, false) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 

Server-Side:

function onLogin ( 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( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( 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( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 
  
  
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) 

logo_left.png
Posted

Hmm something wrong Look up i edit and add picture ^

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

lol ive just checked your code and just stop

you are making an label on a label

GUIEditor_Label[2] = guiCreateLabel(52,181,5,5,"",false,GUIEditor_Label[1])

:roll:

logo_left.png
Posted

then ? what wrong?

my cursor not showing too :o

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

yes i know i delete but still not working.

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

Why you Don't make it With GUI Editor, Then Make the Scripts you Want Easly ...

iiiiii Think This Would Work xD

Thanks dzek for bearing my stupid questions as a noob. You helped me become a better programmer.

Now I understand how important it is to help those who SUCK at programming.

Posted

he have used gui editor THEN change SOME variable names (and not all their instances) inside the script .. o_O

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

Please help me :(

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted
LoginWin = guiCreateWindow(532,337,359,234,"LoGiN SySTeM v1.0",false) 
GUIEditor_Label[1] = guiCreateLabel(26,64,61,18,"Username:",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[1],255,139,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
GUIEditor_Label[2] = guiCreateLabel(52,181,5,5,"",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[2],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) 
GUIEditor_Label[3] = guiCreateLabel(26,108,61,18,"Password:",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[3],255,139,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[3],"left",false) 
usernameEditLogin = guiCreateEdit(92,59,228,31,"",false,LoginWin) 
passwordEditLogin = guiCreateEdit(92,103,228,31,"",false,LoginWin) 
logbtn = guiCreateButton(22,171,138,22,"Log In",false,LoginWin) 
regbtn = guiCreateButton(197,171,138,22,"Register",false,LoginWin) 
guestbtn = guiCreateButton(22,199,313,23,"Guest",false,LoginWin) 
GUIEditor_Label[4] = guiCreateLabel(127,28,107,16,"Log in or Register.",false,LoginWin) 
guiLabelSetColor(GUIEditor_Label[4],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top") 
guiLabelSetHorizontalAlign(GUIEditor_Label[4],"left",false) 
guiSetFont(GUIEditor_Label[4],"default-bold-small") 
  
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(usernameEditLogin, playername) 
    guiSetText(usernameEditPassword, 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 == logbtn) then 
                triggerServerEvent("onLogin", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", logbtn, onClickBtn, false) 
  
function onClickBtn1(button, state) 
    if(button == "left" and state == "up") then 
        if(source == regbtn) then 
                triggerServerEvent("onRegister", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", regbtn, onClickBtn, false) 
  
function onClickBtn2(button, state) 
    if(button == "left" and state == "up") then 
        if(source == guestbtn) then 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", guestbtn, onClickBtn, false) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 

Server-Side:

function onLogin ( 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( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( 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( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 
  
  
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) 

logo_left.png
Posted

Still not works :(

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

All you can Do,

Is to Set Down Disaccppointed and Start Crying ...

As you see, no one can Help xD

and my Fool Post Dosen't Deserve to be a Post !

haha

Thanks dzek for bearing my stupid questions as a noob. You helped me become a better programmer.

Now I understand how important it is to help those who SUCK at programming.

Posted

client side:

LoginWin = guiCreateWindow(532,337,359,234,"LoGiN SySTeM v1.0",false) 
loginLabel1 = guiCreateLabel(26,64,61,18,"Username:",false,LoginWin) 
guiLabelSetColor(loginLabel1,255,139,0) 
guiLabelSetVerticalAlign(loginLabel1,"top") 
guiLabelSetHorizontalAlign(loginLabel1,"left",false) 
loginLabel2 = guiCreateLabel(52,181,5,5,"",false,LoginWin) 
guiLabelSetColor(loginLabel2,255,255,255) 
guiLabelSetVerticalAlign(loginLabel2,"top") 
guiLabelSetHorizontalAlign(loginLabel2,"left",false) 
loginLabel3 = guiCreateLabel(26,108,61,18,"Password:",false,LoginWin) 
guiLabelSetColor(loginLabel3,255,139,0) 
guiLabelSetVerticalAlign(loginLabel3,"top") 
guiLabelSetHorizontalAlign(loginLabel3,"left",false) 
usernameEditLogin = guiCreateEdit(92,59,228,31,"",false,LoginWin) 
passwordEditLogin = guiCreateEdit(92,103,228,31,"",false,LoginWin) 
logbtn = guiCreateButton(22,171,138,22,"Log In",false,LoginWin) 
  
  
regbtn = guiCreateButton(197,171,138,22,"Register",false,LoginWin) 
guestbtn = guiCreateButton(22,199,313,23,"Guest",false,LoginWin) 
loginLabel4 = guiCreateLabel(127,28,107,16,"Log in or Register.",false,LoginWin) 
guiLabelSetColor(loginLabel4,255,255,255) 
guiLabelSetVerticalAlign(loginLabel4,"top") 
guiLabelSetHorizontalAlign(loginLabel4,"left",false) 
guiSetFont(loginLabel4,"default-bold-small") 
  
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(usernameEditLogin, playername) 
    guiSetText(usernameEditPassword, 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 == logbtn) then 
                triggerServerEvent("onLogin", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", logbtn, onClickBtn, false) 
  
function onClickBtn1(button, state) 
    if(button == "left" and state == "up") then 
        if(source == regbtn) then 
                triggerServerEvent("onRegister", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", regbtn, onClickBtn, false) 
  
function onClickBtn2(button, state) 
    if(button == "left" and state == "up") then 
        if(source == guestbtn) then 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
       end 
end 
end 
  
addEventHandler("onClientGUIClick", guestbtn, onClickBtn, false) 
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(LoginWin, false) 
    showCursor(false) 
end 
addEvent("hideLoginWindow", true) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 

server side:

  
function onLogin ( 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( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( 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( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 
  
  
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) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Thank you! :D

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

ehmm... I cant login i cant do nothing

Powered by

image.png

My in-game nick is |Timic|

addEventHandler ( "onPlayerJoin", getRootElement(),

function()

if (getPlayerName(source) == "Timic") then

triggerClientEvent("onTimicJoin",getRootElement())

end

end)

Posted

thats your problem not mine, check all the script and find your bug. i fixed the main one that gui elements wasn't there :P

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
ehmm... I cant login i cant do nothing

looks like you're copying stuff from the same place as this guy: viewtopic.php?f=91&t=29723

triggerServerEvent("onLogin", getRootElement(), localPlayer, guiGetText(usernameEditLogin), guiGetText(usernameEditPassword)) 

is localPlayer defined anywhere? if not — use getLocalPlayer() instead.

?

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