Jump to content

Czemu nie działa to na 1.3 [Login Panel]


Recommended Posts

Witam mam pytanie czemu nie działa to na wersji MTA 1.3

Client:

local localPlayer = getLocalPlayer() 
local localPlayerName = getPlayerName(localPlayer) 
local localRootElement = getRootElement() 
local newUser 
local passwordAttempts = 0 
  
function CreateLoginWindow() 
    wdwLogin = guiCreateStaticImage(145,68,488,390,"images/login.png",false) 
    guiWindowSetSizable(wdwLogin,false) 
  
    edtUser = guiCreateEdit(0.25,0.4205,0.5102,0.0846,localPlayerName,true,wdwLogin) 
    guiEditSetReadOnly(edtUser,false) 
    edtPass = guiCreateEdit(0.248,0.5821,0.5123,0.0821,"",true,wdwLogin) 
    guiEditSetMaxLength(edtPass,20) 
    guiEditSetMasked(edtPass,true) 
  
    btnLogin = guiCreateButton(0.5143,0.6872,0.2439,0.0872,"Loguj/Rejestruj",true,wdwLogin) 
  
    guiSetVisible(wdwLogin,false) 
     
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function() 
        CreateLoginWindow() 
        lblDisplayArea = guiCreateLabel(0.100,0.800,0.800,0.100,"",true) 
        guiLabelSetHorizontalAlign(lblDisplayArea,"center",true) 
             
        addEventHandler("onClientGUIClick",btnLogin,clientSubmitLogin,false) --Mouseclick do botăo de login.. 
        addEventHandler("onClientGUIAccepted",edtPass,clientEnterLogin,false) --Ativa o uso do enter... 
  
        triggerServerEvent ("checkValidAct",localPlayer,localPlayerName) --Verifica se os usuarios tem conta no servidor... 
    end 
) 
  
function clientNewUserHandler() --Aviso de que năo existe conta com esse nome de usuário... 
    newUser = true 
    guiSetText(lblDisplayArea,"Nao existe conta para o seu nome de usuário. Crie uma senha ou mude o campo 'Nome de Usuario'.") 
    if(wdwLogin) then 
        guiSetVisible(wdwLogin,true) 
        guiBringToFront(edtPass) --Coloca o cursor na caixa de senha para digitaçăo... 
    end 
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEvent("clientNewUser",true) 
addEventHandler("clientNewUser",localRootElement,clientNewUserHandler) 
  
function clientReturningUserHandler() --Aviso de quando ja existe uma conta com o mesmo nome de usuário... 
    newUser = false 
    guiSetText(lblDisplayArea,"Voce esta usando um nick registrado, digite sua senha.") 
    if(wdwLogin) then 
        guiSetVisible(wdwLogin,true) 
        guiBringToFront(edtPass) --Coloca o cursor na caixa de senha para digitaçăo... 
    end 
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEvent("clientReturningUser",true) 
addEventHandler("clientReturningUser",localRootElement,clientReturningUserHandler) 
  
function clientEnterLogin() 
    if(newUser) then 
        triggerServerEvent("SubmitCreate",localRootElement,guiGetText(edtUser),guiGetText(edtPass)) 
    else 
        triggerServerEvent("SubmitLogin",localRootElement,guiGetText(edtUser),guiGetText(edtPass)) 
    end 
end 
  
function clientSubmitLogin(button) 
    if(button == "left") then 
        if(newUser) then 
            triggerServerEvent("SubmitCreate",localRootElement,guiGetText(edtUser),guiGetText(edtPass)) 
        else 
            triggerServerEvent("SubmitLogin",localRootElement,guiGetText(edtUser),guiGetText(edtPass)) 
        end 
    end 
end 
  
function clientDisplayAreaHandler(theMessage) 
    guiSetText(lblDisplayArea,theMessage) 
end 
addEvent("clientDisplayArea",true) 
addEventHandler("clientDisplayArea",localRootElement,clientDisplayAreaHandler) 
  
function clientWrongPasswordHandler(theMessage) 
    passwordAttempts = passwordAttempts + 1 
    if(passwordAttempts > 3) then 
        guiSetText(lblDisplayArea,"Muitas tentativas de senha incorreta. Por favor, desconecte.") 
        destroyElement(wdwLogin) 
        triggerServerEvent("removePlayer",localPlayer) 
    end 
end 
addEvent("clientWrongPassword",true) 
addEventHandler("clientWrongPassword",localRootElement,clientWrongPasswordHandler) 
  
function clientLoginSuccessHandler() 
    guiSetInputEnabled(false) 
    destroyElement(wdwLogin) 
    destroyElement(lblDisplayArea) 
    wdwLogin = nil 
    newUser = nil 
    lblDisplayArea = nil 
    passwordAttempts = nil 
    localPlayer = nil 
    localPlayerName = nil 
    localRootElement = nil 
    showCursor(false) 
end 
addEvent("clientLoginSuccess",true) 
addEventHandler("clientLoginSuccess",localRootElement,clientLoginSuccessHandler) 

Server:

  
function clientAttemptLogin(username,password) 
    local userAccount = getAccount(username) 
    local tryToLog 
    if (client) then 
        tryToLog = logIn(client,userAccount,password) 
        if (tryToLog) then 
            spawnPlayer(client,spawnX,spawnY,spawnZ) 
            fadeCamera(client,true) 
            outputChatBox(welcomeMessageReturningUser,client) 
            triggerClientEvent(source,"clientLoginSuccess",getRootElement()) 
        else 
            triggerClientEvent(source,"clientDisplayArea",getRootElement(),"Nieprawidłowe hasło, spróbuj ponownie.") 
            triggerClientEvent(source,"clientWrongPassword",getRootElement()) 
        end 
    end 
end 
addEvent("SubmitLogin",true) 
addEventHandler("SubmitLogin",getRootElement(),clientAttemptLogin) 
  
function clientAttemptCreate(username,password) 
    if (password ~= nil and password ~= "") then 
        addAccount(username,password) 
        local userAccount = getAccount(username) 
        local tryToLog 
        if (client and userAccount ~= false and userAccount ~= nil) then 
            tryToLog = logIn(client,userAccount,password) 
            if (tryToLog) then 
                --spawnPlayer(client,spawnX,spawnY,spawnZ) 
                fadeCamera(client,true) 
                outputChatBox(welcomeMessageNewUser,client) 
                triggerClientEvent(source,"clientLoginSuccess",getRootElement()) 
            else 
                triggerClientEvent(source,"clientDisplayArea",getRootElement(),"Nie można zalogować się na nowym koncie, spróbuj ponownie.") 
            end 
        else 
            triggerClientEvent(source,"clientDisplayArea",getRootElement(),"Nie jest możliwe, aby utworzyć nowe konto, spróbuj ponownie.") 
        end 
    else 
        triggerClientEvent(source,"clientDisplayArea",getRootElement(),"Utwórz nowe hasło do konta.") 
    end 
end 
addEvent("SubmitCreate",true) 
addEventHandler("SubmitCreate",getRootElement(),clientAttemptCreate) 
  
function checkValidActHandler(thePlayer) 
    local theAccount = getAccount(thePlayer) 
    if (theAccount) then 
        triggerClientEvent(source,"clientReturningUser",getRootElement()) 
    else 
        triggerClientEvent(source,"clientNewUser",getRootElement()) 
    end 
end 
addEvent("checkValidAct",true) 
addEventHandler("checkValidAct",getRootElement(),checkValidActHandler) 
  
function removePlayerHandler() 
    kickPlayer(source) 
end 
addEvent("removePlayer",true) 
addEventHandler("removePlayer",getRootElement(),removePlayerHandler) 

Link to comment
  • 4 weeks later...

  
    wdwLogin = guiCreateStaticImage(145,68,488,390,"images/login.png",false) 
    guiWindowSetSizable(wdwLogin,false) 
  

Cos w tym skrypcie namieszałeś i sam nie wiesz co. Komunikat błędu mówi jasno, że guiWindowSetSizable oczekuje jako parametru okna, a Ty mu przekazujesz obrazek.

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