Jump to content

spawning player


Monty

Recommended Posts

hi i downloaded this login panel... is it possible to spawn the player at the position when he left the game?

the code

server

function passwordHandler(player, oldpassword, newpassword) 
    local account = getPlayerAccount(player) 
    if (account) then 
        if (isGuestAccount(account)) then 
            outputChatBox("You must be logged in to change your password.", player) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, oldpassword) 
        if (password_check ~= false) then 
            if (string.len(newpassword) >= 5) then 
                setAccountPassword(account, newpassword) 
                triggerClientEvent(player, "hidePasswordWindow", getRootElement()) 
            else 
                outputChatBox("Your new password must be at least 5 characters long!", player) 
            end 
        else 
            outputChatBox("Old password invalid.", player) 
        end 
    end 
end 
  
  
  
function loginHandler(player, username, password, thePlayer) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
  
  
setTimer( spawnPlayer, 2000,1,player, 1574.5, -1246,279.5) 
  
fadeCamera ( player, false, 1.0, 0, 0, 0 )  
  
 setTimer ( fadeCamera, 5000, 1, player, true, 0.5 ) 
  
  
  
setElementFrozen(player, false) 
setTimer( setCameraTarget,3200,1,player) 
  
            triggerClientEvent (player, "hideLoginWindow1", getRootElement()) 
        else 
            triggerClientEvent (player, "unknownError", getRootElement()) 
        end 
    else 
        triggerClientEvent (player, "loginWrong", getRootElement()) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
  
        triggerClientEvent(player, "registerTaken", getRootElement()) 
    else 
        account = addAccount(username, password) 
        if (logIn(player, account, password) == true) then 
             
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
  
  
    showPlayerHudComponent ( player, "radar", false )  
  setTimer ( fadeCamera, 50, 1, player,false, 1 ) 
  setTimer ( fadeCamera, 3000, 1, player,true, 3 )  
  
setTimer( spawnPlayer, 2250,1,player, 806.7,-1350,-0.4) 
  
setTimer(setCameraMatrix,1500,1,player, 808,-1351,-0.4,-1000,0,0,0,0) 
--setTimer(setElementPosition,2000,1,player, 806.7,-1350,-0.4) 
     setTimer(setElementRotation,2251,1,player,0,0,220) 
  
    else 
            triggerClientEvent(player, "unknownError", getRootElement()) 
        end 
    end 
end 
  
  
function setCameraOnPlayerJoin()  
     fadeCamera(source, true, 5) 
setTimer ( fadeCamera, 5000, 1, source, true, 0.5 )     
 setCameraMatrix(source, 1000.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
  
  
end 
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) 
  
  
  
function hudChangerOnJoin () 
     
    showPlayerHudComponent ( source, "radar", false )  
showChat( source, false) 
end 
  
addEventHandler ( "onPlayerJoin", getRootElement(), hudChangerOnJoin ) 
  
function hudChangerOnLogin () 
     
    showPlayerHudComponent ( source, "radar", true )  
end 
  
addEventHandler ( "onPlayerLogin", getRootElement(), hudChangerOnLogin ) 
  
  
function logoutHandler()--We define a function name 
    local accountname = getAccountName (getPlayerAccount(source))--we get an account 
    if (isGuestAccount(getPlayerAccount(source)) == true) then 
    cancelEvent()--then cancelEvent 
--triggerClientEvent("logOutOp", getRootElement())--output him to chatbox that logout is not allowed  
end 
end 
addEventHandler("onPlayerLogout",getRootElement(),logoutHandler)--we add a event handler which will handle the funciton 
  
  
  
  
  
  
  
  
  
  
function setCameraRegister(player, thePlayer) 
setTimer(setElementPosition,1000,1,source, 1574.5,-1246,279.5) 
setTimer( setCameraTarget,1200,1, source ) 
setTimer ( fadeCamera, 50, 1, source,false, 1 ) 
  setTimer ( fadeCamera, 3000, 1, source,true, 3 )  
setElementFrozen ( source, false ) 
    showPlayerHudComponent ( source, "radar", true )  
showChat(source, true) 
end 
  
  
  
  
  
  
  
  
  
addEvent("setCameraRegister", true) 
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", root, passwordHandler) 
addEventHandler("submitLogin", root, loginHandler) 
addEventHandler("submitRegister", root, registerHandler) 
addEventHandler("setCameraRegister", root, setCameraRegister) 

client

local localPlayer = getLocalPlayer() 
local playerName = getPlayerName(localPlayer)
local sx,sy = guiGetScreenSize()
 
wnd_window = {}
 
 
 
 
 
local guiSkinShop = guiCreateWindow(0.37*sx,0.80*sy,0.3*sx,0.15*sy,"Choose a skin!",false)
done = guiCreateButton(0.25,0.60,0.50,0.30,"Done",true,guiSkinShop)
left = guiCreateButton(0.07,0.60,0.15,0.30,"<-",true,guiSkinShop)
right = guiCreateButton(0.78,0.60,0.15,0.30,"->",true,guiSkinShop)
guiWindowSetSizable(guiSkinShop,false)
guiSetVisible(guiSkinShop, false)
 
 
 
 
--label
skinLabel = guiCreateLabel(0.05,0.30,0.90,0.17,"Skins can be bought once ingame",true,guiSkinShop)
    guiSetAlpha(skinLabel,1)
    guiLabelSetColor(skinLabel,255,255,255)
       guiCreateStaticImage( 0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop )
           guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop )
    guiLabelSetHorizontalAlign(skinLabel,"center",false)
    guiSetFont(skinLabel,"default-bold-small")
 
 
 
 
 
 
function createLoginWindow(title, logo, content)
 
            local xml = xmlLoadFile( "server.xml" )
            local content = xmlNodeGetValue( xml )
    windowLogin = guiCreateWindow(0.02*sx,0.05*sy,0.8*sx,0.8*sy,"LOG-IN",false)
    guiSetSize(windowLogin, 270, 400, false)
guiWindowSetSizable(windowLogin,false)
    guiCreateMemo(01,170,500,220,content,false,windowLogin)
    guiSetAlpha(windowLogin,1)
    labelUsername = guiCreateLabel(10,52,59,24,"Username:",false,windowLogin)
    guiSetAlpha(labelUsername,1)
    guiLabelSetColor(labelUsername,255,255,255)
    guiLabelSetVerticalAlign(labelUsername,"center")
    guiLabelSetHorizontalAlign(labelUsername,"left",false)
labelPassword = guiCreateLabel(10,86,59,24,"Password:",false,windowLogin)
 
    guiSetAlpha(labelPassword,1)
    guiLabelSetColor(labelPassword,255,255,255)
    guiLabelSetVerticalAlign(labelPassword,"center")
    guiLabelSetHorizontalAlign(labelPassword,"left",false)
    labelInfo = guiCreateLabel(10,26,250,17,"Please login or register.",false,windowLogin)
    guiSetAlpha(labelInfo,1)
    guiLabelSetColor(labelInfo,255,255,255)
    guiLabelSetVerticalAlign(labelInfo,"top")
    guiLabelSetHorizontalAlign(labelInfo,"center",false)
    guiSetFont(labelInfo,"default-bold-small")
    editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin)
    guiSetAlpha(editUsername,1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin)
    guiSetAlpha(editPassword,1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
    buttonLogin = guiCreateButton(10,121,117,21,"Log in",false,windowLogin)
    guiSetAlpha(buttonLogin,1)
    buttonRegister = guiCreateButton(149,121,117,21,"Register",false,windowLogin)
    guiSetAlpha(buttonRegister,1)
newsLabel = guiCreateLabel(0.35,0.372,0.300,0.17,"Server News",true,windowLogin)
    guiSetAlpha(newsLabel,1)
    guiLabelSetColor(newsLabel,255,255,255)
       guiCreateStaticImage( 0.0001, 0.11, 0.99, 0.006, "red.png", true, windowLogin )
       guiCreateStaticImage( 0.0001, 0.06, 0.99, 0.006, "red.png", true, windowLogin )
    guiLabelSetHorizontalAlign(newsLabel,"center",false)
    guiSetFont(newsLabel,"default-bold-small")
 
    guiSetVisible(windowLogin, false)
    showChat(false)
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, showReg, false)
end
 
 
 
 
 
 
 
regMenu = guiCreateWindow(0.357*sx,0.05*sy,0.33*sx,0.3*sy,"Register Menu",false)
guiCreateStaticImage( 0.0001, 0.13, 0.99, 0.010, "red.png", true, regMenu )
guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.010, "red.png", true, regMenu )
guiWindowSetSizable(regMenu,false)
guiSetAlpha(regMenu,1)
 
    regUsername = guiCreateLabel(10,52,59,24,"Username:",false,regMenu)
    guiSetAlpha(regUsername,1)
    guiLabelSetColor(regUsername,255,255,255)
    guiLabelSetVerticalAlign(regUsername,"center")
    guiLabelSetHorizontalAlign(regUsername,"left",false)
    editRegUsername = guiCreateEdit(70,52,181,25,"",false,regMenu)
    guiSetAlpha(editRegUsername,1)
    guiEditSetMaxLength(editRegUsername, 50)
 
regPassword = guiCreateLabel(10,86,59,24,"Password:",false,regMenu)
 
    guiSetAlpha(regPassword,1)
    guiLabelSetColor(regPassword,255,255,255)
    guiLabelSetVerticalAlign(regPassword,"center")
    guiLabelSetHorizontalAlign(regPassword,"left",false)
 
    --editRegPassword = guiCreateEdit(79,86,181,25,"",false,regMenu)
editRegPassword = guiCreateEdit(70,86,181,25,"",false,regMenu)
    guiSetAlpha(editRegPassword,1)
    guiEditSetMasked(editRegPassword, true)
    guiEditSetMaxLength(editRegPassword, 50)
 
        regComPassword = guiCreateLabel(10,122,59,24,"*Email:",false,regMenu)
    guiSetAlpha(regComPassword,1)
    guiLabelSetColor(regComPassword,255,255,255)
    guiLabelSetVerticalAlign(regComPassword,"center")
    guiLabelSetHorizontalAlign(regComPassword,"left",false)
 
        editEmail = guiCreateEdit(70,120,181,25,"",false,regMenu)
--editEmail = guiCreateEdit(60,120,190,25,"",false,regMenu)
    guiSetAlpha(editEmail,1)
    guiEditSetMasked(editEmail, true)
    guiEditSetMaxLength(editEmail, 50)
 
        buttonReg = guiCreateButton(10,150,120,21,"Register",false,regMenu)
    guiSetAlpha(buttonReg,1)
    buttonCan = guiCreateButton(143,150,117,21,"Cancel",false,regMenu)
    guiSetAlpha(buttonCan,1)
 
 
labelRegister = guiCreateLabel(10,26,250,17,"Register with a user and pass here.",false,regMenu)
 
guiSetAlpha(labelRegister,1)
guiLabelSetColor(labelRegister,255,255,255)
guiLabelSetVerticalAlign(labelRegister,"top")
guiLabelSetHorizontalAlign(labelRegister,"center",false)
guiSetFont(labelRegister,"default-bold-small")
 
 
guiSetVisible(regMenu, false)
 
function cancelWindow()
guiSetVisible(regMenu, false)
end
 
 
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("An error has occurred.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
showChat(true)
 
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
 
        else
            guiSetText(labelInfo, "Enter username and password.")
        end
    end
end
 
function showReg(button, state)
guiSetVisible(regMenu, true)
 
 
--if button == "left" and state == "up" then
    --  local username = guiGetText(editUsername)
    --  local password = guiGetText(editPassword)
    --  if username and password then
--showChat(false)
--
--
--          triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
--      else
--          guiSetText(labelInfo, "Enter username and password.")
--      end
    --end
end
 
function clientSubmitRegister(button, state)
if button == "left" and state == "up" then
    local username = guiGetText(editRegUsername)
    local password = guiGetText(editRegPassword)
    if username and password then
showChat(false)
 
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        else
            --  guiSetText(labelRegister, "User/pass in use.")
        end
    end
end
 
 
 
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Enter old and new password.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
guiSetVisible(regMenu, false)
 
setTimer(guiSetVisible, 3100, 1, guiSkinShop, true)
showCursor(true)
end
 
 
function hideLoginWindow1()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
 
 
 
Link to comment
Guest Guest4401
hi i downloaded this login panel... is it possible to spawn the player at the position when he left the game?

the code

What has the login panel to do with what you want?

is it possible to spawn the player at the position when he left the game?
addEventHandler("onPlayerQuit",root, 
    function() 
        local account = getPlayerAccount(source); 
        if account and not isGuestAccount(account) then 
            local x, y, z = getElementPosition(source); 
            setAccountData(account, "xPosWhileQuit", x); 
            setAccountData(account, "yPosWhileQuit", y); 
            setAccountData(account, "zPosWhileQuit", z); 
        end; 
    end 
) 
  
addEventHandler("onPlayerLogin",root, 
    function(_, account) 
        if account and not isGuestAccount(account) then 
            local x = getAccountData(account, "xPosWhileQuit"); 
            local y = getAccountData(account, "yPosWhileQuit"); 
            local z = getAccountData(account, "zPosWhileQuit"); 
            if x and y and z then 
                setElementPosition(source,x,y,z); 
            end; 
        end; 
    end 
) 

Link to comment

server

function passwordHandler(player, oldpassword, newpassword) 
    local account = getPlayerAccount(player) 
    if (account) then 
        if (isGuestAccount(account)) then 
            outputChatBox("You must be logged in to change your password.", player) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, oldpassword) 
        if (password_check ~= false) then 
            if (string.len(newpassword) >= 5) then 
                setAccountPassword(account, newpassword) 
                triggerClientEvent(player, "hidePasswordWindow", getRootElement()) 
            else 
                outputChatBox("Your new password must be at least 5 characters long!", player) 
            end 
        else 
            outputChatBox("Old password invalid.", player) 
        end 
    end 
end 
  
  
  
function loginHandler(player, username, password, thePlayer) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
  
  
setTimer( spawnPlayer, 2000,1,player, 1574.5, -1246,279.5) 
  
fadeCamera ( player, false, 1.0, 0, 0, 0 ) 
  
 setTimer ( fadeCamera, 5000, 1, player, true, 0.5 ) 
  
  
  
setElementFrozen(player, false) 
setTimer( setCameraTarget,3200,1,player) 
  
            triggerClientEvent (player, "hideLoginWindow1", getRootElement()) 
        else 
            triggerClientEvent (player, "unknownError", getRootElement()) 
        end 
    else 
        triggerClientEvent (player, "loginWrong", getRootElement()) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
  
        triggerClientEvent(player, "registerTaken", getRootElement()) 
    else 
        account = addAccount(username, password) 
        if (logIn(player, account, password) == true) then 
            
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
  
  
    showPlayerHudComponent ( player, "radar", false ) 
  setTimer ( fadeCamera, 50, 1, player,false, 1 ) 
  setTimer ( fadeCamera, 3000, 1, player,true, 3 ) 
  
setTimer( spawnPlayer, 2250,1,player, 806.7,-1350,-0.4) 
  
setTimer(setCameraMatrix,1500,1,player, 808,-1351,-0.4,-1000,0,0,0,0) 
--setTimer(setElementPosition,2000,1,player, 806.7,-1350,-0.4) 
     setTimer(setElementRotation,2251,1,player,0,0,220) 
  
    else 
            triggerClientEvent(player, "unknownError", getRootElement()) 
        end 
    end 
end 
  
  
function setCameraOnPlayerJoin() 
     fadeCamera(source, true, 5) 
setTimer ( fadeCamera, 5000, 1, source, true, 0.5 )     
 setCameraMatrix(source, 1000.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
  
  
end 
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) 
  
  
  
function hudChangerOnJoin () 
    
    showPlayerHudComponent ( source, "radar", false ) 
showChat( source, false) 
end 
  
addEventHandler ( "onPlayerJoin", getRootElement(), hudChangerOnJoin ) 
  
function hudChangerOnLogin () 
    
    showPlayerHudComponent ( source, "radar", true ) 
end 
  
addEventHandler ( "onPlayerLogin", getRootElement(), hudChangerOnLogin ) 
  
  
function logoutHandler()--We define a function name 
    local accountname = getAccountName (getPlayerAccount(source))--we get an account 
    if (isGuestAccount(getPlayerAccount(source)) == true) then 
    cancelEvent()--then cancelEvent 
--triggerClientEvent("logOutOp", getRootElement())--output him to chatbox that logout is not allowed 
end 
end 
addEventHandler("onPlayerLogout",getRootElement(),logoutHandler)--we add a event handler which will handle the funciton 
  
  
  
  
  
  
  
  
  
  
function setCameraRegister(player, thePlayer) 
setTimer(setElementPosition,1000,1,source, 1574.5,-1246,279.5) 
setTimer( setCameraTarget,1200,1, source ) 
setTimer ( fadeCamera, 50, 1, source,false, 1 ) 
  setTimer ( fadeCamera, 3000, 1, source,true, 3 ) 
setElementFrozen ( source, false ) 
    showPlayerHudComponent ( source, "radar", true ) 
showChat(source, true) 
end 
  
  
  
  
addEventHandler("onPlayerQuit",root, 
    function() 
        local account = getPlayerAccount(source); 
        if account and not isGuestAccount(account) then 
            local x, y, z = getElementPosition(source); 
            setAccountData(account, "xPosWhileQuit", x); 
            setAccountData(account, "yPosWhileQuit", y); 
            setAccountData(account, "zPosWhileQuit", z); 
        end; 
    end 
) 
  
addEventHandler("onPlayerLogin",root, 
    function(_, account) 
        if account and not isGuestAccount(account) then 
            local x = getAccountData(account, "xPosWhileQuit"); 
            local y = getAccountData(account, "yPosWhileQuit"); 
            local z = getAccountData(account, "zPosWhileQuit"); 
            if x and y and z then 
                setElementPosition(source,x,y,z); 
            end; 
        end; 
    end 
) 
  
  
  
  
  
addEvent("setCameraRegister", true) 
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", root, passwordHandler) 
addEventHandler("submitLogin", root, loginHandler) 
addEventHandler("submitRegister", root, registerHandler) 
addEventHandler("setCameraRegister", root, setCameraRegister) 

client

local localPlayer = getLocalPlayer() 
local playerName = getPlayerName(localPlayer)
local sx,sy = guiGetScreenSize()
 
wnd_window = {}
 
 
 
 
 
local guiSkinShop = guiCreateWindow(0.37*sx,0.80*sy,0.3*sx,0.15*sy,"Choose a skin!",false)
done = guiCreateButton(0.25,0.60,0.50,0.30,"Done",true,guiSkinShop)
left = guiCreateButton(0.07,0.60,0.15,0.30,"<-",true,guiSkinShop)
right = guiCreateButton(0.78,0.60,0.15,0.30,"->",true,guiSkinShop)
guiWindowSetSizable(guiSkinShop,false)
guiSetVisible(guiSkinShop, false)
 
 
 
 
--label
skinLabel = guiCreateLabel(0.05,0.30,0.90,0.17,"Skins can be bought once ingame",true,guiSkinShop)
    guiSetAlpha(skinLabel,1)
    guiLabelSetColor(skinLabel,255,255,255)
       guiCreateStaticImage( 0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop )
           guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop )
    guiLabelSetHorizontalAlign(skinLabel,"center",false)
    guiSetFont(skinLabel,"default-bold-small")
 
 
 
 
 
 
function createLoginWindow(title, logo, content)
 
            local xml = xmlLoadFile( "server.xml" )
            local content = xmlNodeGetValue( xml )
    windowLogin = guiCreateWindow(0.02*sx,0.05*sy,0.8*sx,0.8*sy,"LOG-IN",false)
    guiSetSize(windowLogin, 270, 400, false)
guiWindowSetSizable(windowLogin,false)
    guiCreateMemo(01,170,500,220,content,false,windowLogin)
    guiSetAlpha(windowLogin,1)
    labelUsername = guiCreateLabel(10,52,59,24,"Username:",false,windowLogin)
    guiSetAlpha(labelUsername,1)
    guiLabelSetColor(labelUsername,255,255,255)
    guiLabelSetVerticalAlign(labelUsername,"center")
    guiLabelSetHorizontalAlign(labelUsername,"left",false)
labelPassword = guiCreateLabel(10,86,59,24,"Password:",false,windowLogin)
 
    guiSetAlpha(labelPassword,1)
    guiLabelSetColor(labelPassword,255,255,255)
    guiLabelSetVerticalAlign(labelPassword,"center")
    guiLabelSetHorizontalAlign(labelPassword,"left",false)
    labelInfo = guiCreateLabel(10,26,250,17,"Please login or register.",false,windowLogin)
    guiSetAlpha(labelInfo,1)
    guiLabelSetColor(labelInfo,255,255,255)
    guiLabelSetVerticalAlign(labelInfo,"top")
    guiLabelSetHorizontalAlign(labelInfo,"center",false)
    guiSetFont(labelInfo,"default-bold-small")
    editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin)
    guiSetAlpha(editUsername,1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin)
    guiSetAlpha(editPassword,1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
    buttonLogin = guiCreateButton(10,121,117,21,"Log in",false,windowLogin)
    guiSetAlpha(buttonLogin,1)
    buttonRegister = guiCreateButton(149,121,117,21,"Register",false,windowLogin)
    guiSetAlpha(buttonRegister,1)
newsLabel = guiCreateLabel(0.35,0.372,0.300,0.17,"Server News",true,windowLogin)
    guiSetAlpha(newsLabel,1)
    guiLabelSetColor(newsLabel,255,255,255)
       guiCreateStaticImage( 0.0001, 0.11, 0.99, 0.006, "red.png", true, windowLogin )
       guiCreateStaticImage( 0.0001, 0.06, 0.99, 0.006, "red.png", true, windowLogin )
    guiLabelSetHorizontalAlign(newsLabel,"center",false)
    guiSetFont(newsLabel,"default-bold-small")
 
    guiSetVisible(windowLogin, false)
    showChat(false)
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, showReg, false)
end
 
 
 
 
 
 
 
regMenu = guiCreateWindow(0.357*sx,0.05*sy,0.33*sx,0.3*sy,"Register Menu",false)
guiCreateStaticImage( 0.0001, 0.13, 0.99, 0.010, "red.png", true, regMenu )
guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.010, "red.png", true, regMenu )
guiWindowSetSizable(regMenu,false)
guiSetAlpha(regMenu,1)
 
    regUsername = guiCreateLabel(10,52,59,24,"Username:",false,regMenu)
    guiSetAlpha(regUsername,1)
    guiLabelSetColor(regUsername,255,255,255)
    guiLabelSetVerticalAlign(regUsername,"center")
    guiLabelSetHorizontalAlign(regUsername,"left",false)
    editRegUsername = guiCreateEdit(70,52,181,25,"",false,regMenu)
    guiSetAlpha(editRegUsername,1)
    guiEditSetMaxLength(editRegUsername, 50)
 
regPassword = guiCreateLabel(10,86,59,24,"Password:",false,regMenu)
 
    guiSetAlpha(regPassword,1)
    guiLabelSetColor(regPassword,255,255,255)
    guiLabelSetVerticalAlign(regPassword,"center")
    guiLabelSetHorizontalAlign(regPassword,"left",false)
 
    --editRegPassword = guiCreateEdit(79,86,181,25,"",false,regMenu)
editRegPassword = guiCreateEdit(70,86,181,25,"",false,regMenu)
    guiSetAlpha(editRegPassword,1)
    guiEditSetMasked(editRegPassword, true)
    guiEditSetMaxLength(editRegPassword, 50)
 
        regComPassword = guiCreateLabel(10,122,59,24,"*Email:",false,regMenu)
    guiSetAlpha(regComPassword,1)
    guiLabelSetColor(regComPassword,255,255,255)
    guiLabelSetVerticalAlign(regComPassword,"center")
    guiLabelSetHorizontalAlign(regComPassword,"left",false)
 
        editEmail = guiCreateEdit(70,120,181,25,"",false,regMenu)
--editEmail = guiCreateEdit(60,120,190,25,"",false,regMenu)
    guiSetAlpha(editEmail,1)
    guiEditSetMasked(editEmail, true)
    guiEditSetMaxLength(editEmail, 50)
 
        buttonReg = guiCreateButton(10,150,120,21,"Register",false,regMenu)
    guiSetAlpha(buttonReg,1)
    buttonCan = guiCreateButton(143,150,117,21,"Cancel",false,regMenu)
    guiSetAlpha(buttonCan,1)
 
 
labelRegister = guiCreateLabel(10,26,250,17,"Register with a user and pass here.",false,regMenu)
 
guiSetAlpha(labelRegister,1)
guiLabelSetColor(labelRegister,255,255,255)
guiLabelSetVerticalAlign(labelRegister,"top")
guiLabelSetHorizontalAlign(labelRegister,"center",false)
guiSetFont(labelRegister,"default-bold-small")
 
 
guiSetVisible(regMenu, false)
 
function cancelWindow()
guiSetVisible(regMenu, false)
end
 
 
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("An error has occurred.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
showChat(true)
 
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
 
        else
            guiSetText(labelInfo, "Enter username and password.")
        end
    end
end
 
function showReg(button, state)
guiSetVisible(regMenu, true)
 
 
--if button == "left" and state == "up" then
    --  local username = guiGetText(editUsername)
    --  local password = guiGetText(editPassword)
    --  if username and password then
--showChat(false)
--
--
--          triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
--      else
--          guiSetText(labelInfo, "Enter username and password.")
--      end
    --end
end
 
function clientSubmitRegister(button, state)
if button == "left" and state == "up" then
    local username = guiGetText(editRegUsername)
    local password = guiGetText(editRegPassword)
    if username and password then
showChat(false)
 
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        else
            --  guiSetText(labelRegister, "User/pass in use.")
        end
    end
end
 
 
 
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Enter old and new password.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
guiSetVisible(regMenu, false)
 
setTimer(guiSetVisible, 3100, 1, guiSkinShop, true)
showCursor(true)
end
 
 
function hideLoginWindow1()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    showCursor(false)
 
 
 
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...