Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2013-08-28, 19:32


Drak







Wiek: 35
Na forum: 5045 dni
Posty: 71
Nick w MP: Drak

Piwa: 3

Respekt: 50

Witam! Pisze w?asny login panel i mam z nim pewnien problem. Ca?y czas wyskakuje mi wiadomo??, ?e musze wpisa? login, cho? jest on wpisany.

Oto kod:
Client:
function createWindow()
    login = {}
    local x, y = guiGetScreenSize()
    if x == 640 and y == 480 then
        login["window"] = guiCreateStaticImage(20, 40, 600, 400, "img/window.png", false)
    end 
    if x == 720 and y == 480 then
        login["window"] = guiCreateStaticImage(60, 40, 600, 400, "img/window.png", false)
    end
    if x == 720 and y == 576 then
        login["window"] = guiCreateStaticImage(60, 88, 600, 400, "img/window.png", false)
    end
    if x == 800 and y == 600 then
        login["window"] = guiCreateStaticImage(100, 100, 600, 400, "img/window.png", false)
    end
    if x == 1024 and y == 768 then
        login["window"] = guiCreateStaticImage(212, 184.5, 600, 400, "img/window.png", false)
    end
    if x == 1152 and y == 864 then
        login["window"] = guiCreateStaticImage(276, 232, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 720 then
        login["window"] = guiCreateStaticImage(340, 170, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 768 then
        login["window"] = guiCreateStaticImage(340, 184, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 800 then
        login["window"] = guiCreateStaticImage(340, 200, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 960 then
        login["window"] = guiCreateStaticImage(340, 280, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 1024 then
        login["window"] = guiCreateStaticImage(340, 312, 600, 400, "img/window.png", false)
    end
    if x == 1440 and y == 900 then
        login["window"] = guiCreateStaticImage(420, 250, 600, 400, "img/window.png", false)
    end
    login["lbl_1"] = guiCreateLabel(0, 0, 600, 55, "Login Panel", false, login["window"])
    guiLabelSetColor(login["lbl_1"], 0, 0, 0)
    guiLabelSetHorizontalAlign(login["lbl_1"], "center")
    guiSetFont(login["lbl_1"], "sa-header")
    login["tab_panel"] = guiCreateTabPanel(5, 60, 590, 335, false, login["window"])
    guiSetAlpha (login["tab_panel"], 0.6)
    login["tab_1"] = guiCreateTab("Logowanie", login["tab_panel"])
    login["lbl_2"] = guiCreateLabel(165, 100, 35, 25, "Login:", false, login["tab_1"])
    login["lbl_3"] = guiCreateLabel(165, 130, 35, 25, "Has?o:", false, login["tab_1"])
    guiLabelSetHorizontalAlign(login["lbl_2"], "left")
    guiLabelSetHorizontalAlign(login["lbl_3"], "left")
    guiLabelSetColor(login["lbl_2"], 0, 0, 0)
    guiLabelSetColor(login["lbl_3"], 0, 0, 0)
    login["edit_1"] = guiCreateEdit(200, 100, 100, 25, "", false, login["tab_1"])
    login["edit_2"] = guiCreateEdit(200, 130, 100, 25, "", false, login["tab_1"])
    guiEditSetMasked (login["edit_2"], true)
    login["btn_1"] = guiCreateButton(190, 200, 125, 75, "Zaloguj", false, login["tab_1"])
    guiSetFont(login["btn_1"], "sa-header")
    login["logo_1"] = guiCreateStaticImage(325, 7.5, 260, 295, "img/logo.png", false, login["tab_1"])
    login["tab_2"] = guiCreateTab("Rejestracja", login["tab_panel"])
    login["tab_3"] = guiCreateTab("Regulamin", login["tab_panel"])
    showCursor(true)
    
    addEventHandler("onClientGUIClick", getRootElement(), btnClicks)
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), createWindow)

function btnClicks()
    if source == login["btn_1"] then
        username = guiGetText(login["edit_1"])
        password = guiGetText(login["edit_2"])
        triggerServerEvent("onRequestLogin", getLocalPlayer(), username, password)
    end
end

function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(login["window"], false)
    showCursor(false)
end
addEvent("hideLoginWindow", true)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)


Server:
function OnRequestLogin(username, password)
    if not username == "" then
        if not password == "" then
            local acc = getAccount(username, password)
            if acc ~= false then
                logIn(source, acc, password)
                triggerClientEvent(source, "hideLoginWindow", getRootElement())
                outputChatBox("["..getResourceName(getThisResource()).."] #ffffffZalogowa?e? si? pomy?lnie.", source, 255, 0, 0, true)
            else
                outputChatBox("["..getResourceName(getThisResource()).."] #ffffffZ?y login lub/i has?o.", source, 255, 0, 0, true)
            end
        else
            outputChatBox("["..getResourceName(getThisResource()).."] #ffffffPodaj sowje has?o.", source, 255, 0, 0, true)
        end
    else
        outputChatBox("["..getResourceName(getThisResource()).."] #ffffffPodaj sw?j login.", source, 255, 0, 0, true)
    end
end
addEvent("onRequestLogin", true)
addEventHandler("onRequestLogin", getRootElement(), OnRequestLogin)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2013-08-28, 20:21


vipSEBOvip

A poor begginer






Wiek: 27
Na forum: 5319 dni
Posty: 597
Nick w MP: xSebaPL

Piwa: 77

Respekt: 140
Respekt: 140

To chyba si? robi?o tak:
if username =~ false then

Ale nie jestem pewny

PS
Nie ?atwiej by?o by zamieni? to
local x, y = guiGetScreenSize()
    if x == 640 and y == 480 then
        login["window"] = guiCreateStaticImage(20, 40, 600, 400, "img/window.png", false)
    end 
    if x == 720 and y == 480 then
        login["window"] = guiCreateStaticImage(60, 40, 600, 400, "img/window.png", false)
    end
    if x == 720 and y == 576 then
        login["window"] = guiCreateStaticImage(60, 88, 600, 400, "img/window.png", false)
    end
    if x == 800 and y == 600 then
        login["window"] = guiCreateStaticImage(100, 100, 600, 400, "img/window.png", false)
    end
    if x == 1024 and y == 768 then
        login["window"] = guiCreateStaticImage(212, 184.5, 600, 400, "img/window.png", false)
    end
    if x == 1152 and y == 864 then
        login["window"] = guiCreateStaticImage(276, 232, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 720 then
        login["window"] = guiCreateStaticImage(340, 170, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 768 then
        login["window"] = guiCreateStaticImage(340, 184, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 800 then
        login["window"] = guiCreateStaticImage(340, 200, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 960 then
        login["window"] = guiCreateStaticImage(340, 280, 600, 400, "img/window.png", false)
    end
    if x == 1280 and y == 1024 then
        login["window"] = guiCreateStaticImage(340, 312, 600, 400, "img/window.png", false)
    end
    if x == 1440 and y == 900 then
        login["window"] = guiCreateStaticImage(420, 250, 600, 400, "img/window.png", false)
    end

na to?:

local x, y = guiGetScreenSize()
login["window"] = guiCreateStaticImage(x*340/1280, y*170/720, x*600/1280, y*400/720, "img/window.png", false)


Postaw piwo autorowi tego posta
 

 
Tagi: login :: panel
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Login panel Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku