Jump to content

GUI Bug.


Wes

Recommended Posts

Hy. I made a GUI Login, and everytime I click on the Login button, I get this message

WARNING: loginsystem\s_login.lua:4: Bad Argument @getAccount [Expected String at argument 1, got nil]

WARNING: loginsystem\s_login.lua: 6: Bad Argument @logIn .[Expected account at argument 2, got boolean]

Aand it doesnt matter where I click, it triggers both register and login function, idk why.

This is the code, I hope you can help me.

addEvent("onlogin", true) 
addEventHandler("onlogin", getRootElement(), 
    function (player, user, pass) 
        local account = getAccount(account, pass) 
    if (account ~= true) then 
        if (logIn (player, account, pass) == true) then 
            outputChatBox("Bejelentkeztél" .. account .. "nevű felhasználóba!") 
            triggerClientEvent(player, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Bejelentkezési hiba történt... Kérlek próbáld meg később!") 
            end 
    else 
        outputChatBox("Helytelen felhasználónév / jelszó!") 
    end 
end 
)        
  
addEvent("onregister", true) 
addEventHandler("onregister", getRootElement(), 
    function (player, user, pass) 
        local account = getAccount(user, pass) 
    if (account ~= false) then 
        if (logIn (account, pass) == true) then  
            outputChatBox("Sikeresen regisztráltál a szerverre!") 
            triggerClientEvent(player, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Már be vagy jelentkezve!") 
            end 
    else 
        account = addAccount(user, pass) 
         if (logIn ( player, account, pass ) == true) then 
            outputChatBox ( "Sikeresen regisztráltál!") 
            outputChatBox ( "Regisztráció adatai : [ Felhasználónév ] : #00FF00" .. user .. " #FFFF1A[ Jelszó ] : #00FF00" .. pass) 
            triggerClientEvent(player, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Regisztrációs hiba!") 
        end 
    end 
end 
) 

CLIENT SCRIPT

--[[------------------------------------------------- 
Notes: 
  
> This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. 
    To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. 
--]]------------------------------------------------- 
  
  
GUIEditor = { 
    edit = {}, 
    staticimage = {} 
} 
  
    function mypanel() 
        GUIEditor.staticimage[1] = guiCreateStaticImage(281, 257, 885, 361, "background_1.png", false) 
        GUIEditor.staticimage[2] = guiCreateStaticImage(16, -41, 853, 70, "bar.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[1] = guiCreateEdit(69, 114, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[2] = guiCreateEdit(68, 187, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[3] = guiCreateStaticImage(83, 267, 153, 48, "button_standart.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[4] = guiCreateStaticImage(68, 157, 32, 30, "login_icon.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[3] = guiCreateEdit(646, 114, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[5] = guiCreateStaticImage(655, 267, 158, 43, "button_standart.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[4] = guiCreateEdit(646, 188, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[6] = guiCreateStaticImage(645, 158, 32, 30, "login_icon.png", false, GUIEditor.staticimage[1])     
        showCursor(true) 
        guiSetInputEnabled(true) 
        --addeventhandlers 
        addEventHandler("onClientGUIClick", GUIEditor.staticimage[3], login) 
        addEventHandler("onClientGUIClick", GUIEditor.staticimage[5], register) 
  
         
  
--ha rámegy akkor átváltozik 
addEventHandler ( "onClientMouseEnter", GUIEditor.staticimage[3],  
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[3], "button_mouse.png") 
       playSound("http://www.flashkit.com/imagesvr_ce/flashkit/soundfx/Interfaces/Blips/Blip_1-Surround-7482/Blip_1-Surround-7482_hifi.mp3") 
    end 
    ,false 
) 
  
  
  
addEventHandler ( "onClientMouseEnter", GUIEditor.staticimage[5],  
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[5], "button_mouse.png") 
       playSound("http://www.flashkit.com/imagesvr_ce/flashkit/soundfx/Interfaces/Blips/Blip_1-Surround-7482/Blip_1-Surround-7482_hifi.mp3") 
    end 
    ,false 
) 
  
addEventHandler ( "onClientMouseLeave", GUIEditor.staticimage[5],  
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[5], "button_standart.png") 
    end 
    ,false 
) 
--ha lelép róla visszaváltozik 
addEventHandler ( "onClientMouseLeave", GUIEditor.staticimage[3], 
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[3], "button_standart.png") 
    end 
    ,false 
) 
  
  
    end 
addEventHandler("onClientResourceStart", resourceRoot, mypanel) 
  
function login() 
  
triggerServerEvent("onlogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) 
end 
  
function register() 
triggerServerEvent("onregister", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[3]), guiGetText(GUIEditor.edit[4]) ) 
end 
  
addEvent("hideWindow", true) 
addEventHandler ("hideWindow", getRootElement(),  
function() 
for i,v in ipairs(edit) do ---destroy all mywind 
        if isElement(v) then 
            destroyElement(v) 
        end 
    end 
    showCursor(false) 
end) 
  
         
  
  
addEventHandler("onClientRender", root, 
    function() 
        dxDrawText("MTA RP PROJECT - ÁTNEVEZÉSRE VÁR -", 540, 257, 864, 281, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Bejelentkezés", 356, 303, 563, 346, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Bejelentkezés", 379, 536, 522, 568, tocolor(255, 255, 255, 255), 0.70, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Felhasználónév", 359, 346, 530, 371, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawText("Jelszó", 382, 424, 553, 449, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawText("Regisztráció", 928, 305, 1135, 348, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Felhasználónév", 944, 348, 1115, 373, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawText("Regisztráció", 959, 533, 1108, 561, tocolor(255, 255, 255, 255), 0.70, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Jelszó", 958, 424, 1125, 447, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
) 
  

Link to comment

Messed post, try this:

Server-side

addEvent("onlogin", true) 
addEventHandler("onlogin", getRootElement(), 
    function (user, pass) 
        local account = getAccount(user, pass) 
    if (account ~= true) then 
        if (logIn (source, user, pass) == true) then 
            outputChatBox("Bejelentkeztél" .. user .. "nevű felhasználóba!") 
            triggerClientEvent(source, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Bejelentkezési hiba történt... Kérlek próbáld meg később!") 
            end 
    else 
        outputChatBox("Helytelen felhasználónév / jelszó!") 
    end 
end 
)       
  
addEvent("onregister", true) 
addEventHandler("onregister", getRootElement(), 
    function (user, pass) 
        local account = getAccount(user, pass) 
    if (account ~= false) then 
        if (logIn (source, user, pass) == true) then 
            outputChatBox("Sikeresen regisztráltál a szerverre!") 
            triggerClientEvent(source, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Már be vagy jelentkezve!") 
            end 
    else 
        account = addAccount(user, pass) 
         if (logIn ( source, account, pass ) == true) then 
            outputChatBox ( "Sikeresen regisztráltál!") 
            outputChatBox ( "Regisztráció adatai : [ Felhasználónév ] : #00FF00" .. user .. " #FFFF1A[ Jelszó ] : #00FF00" .. pass) 
            triggerClientEvent(source, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Regisztrációs hiba!") 
        end 
    end 
end 
) 
  
  
) 

Client-side

--[[------------------------------------------------- 
Notes: 
  
> This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. 
    To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. 
--]]------------------------------------------------- 
  
  
GUIEditor = { 
    edit = {}, 
    staticimage = {} 
} 
  
    function mypanel() 
        GUIEditor.staticimage[1] = guiCreateStaticImage(281, 257, 885, 361, "background_1.png", false) 
        GUIEditor.staticimage[2] = guiCreateStaticImage(16, -41, 853, 70, "bar.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[1] = guiCreateEdit(69, 114, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[2] = guiCreateEdit(68, 187, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[3] = guiCreateStaticImage(83, 267, 153, 48, "button_standart.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[4] = guiCreateStaticImage(68, 157, 32, 30, "login_icon.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[3] = guiCreateEdit(646, 114, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[5] = guiCreateStaticImage(655, 267, 158, 43, "button_standart.png", false, GUIEditor.staticimage[1]) 
        GUIEditor.edit[4] = guiCreateEdit(646, 188, 178, 33, "", false, GUIEditor.staticimage[1]) 
        GUIEditor.staticimage[6] = guiCreateStaticImage(645, 158, 32, 30, "login_icon.png", false, GUIEditor.staticimage[1])     
        showCursor(true) 
        guiSetInputEnabled(true) 
        --addeventhandlers 
        addEventHandler("onClientGUIClick", GUIEditor.staticimage[3], login) 
        addEventHandler("onClientGUIClick", GUIEditor.staticimage[5], register) 
  
        
  
--ha rámegy akkor átváltozik 
addEventHandler ( "onClientMouseEnter", GUIEditor.staticimage[3], 
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[3], "button_mouse.png") 
       playSound("http://www.flashkit.com/imagesvr_ce/flashkit/soundfx/Interfaces/Blips/Blip_1-Surround-7482/Blip_1-Surround-7482_hifi.mp3") 
    end 
    ,false 
) 
  
  
  
addEventHandler ( "onClientMouseEnter", GUIEditor.staticimage[5], 
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[5], "button_mouse.png") 
       playSound("http://www.flashkit.com/imagesvr_ce/flashkit/soundfx/Interfaces/Blips/Blip_1-Surround-7482/Blip_1-Surround-7482_hifi.mp3") 
    end 
    ,false 
) 
  
addEventHandler ( "onClientMouseLeave", GUIEditor.staticimage[5], 
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[5], "button_standart.png") 
    end 
    ,false 
) 
--ha lelép róla visszaváltozik 
addEventHandler ( "onClientMouseLeave", GUIEditor.staticimage[3], 
    function () 
       guiStaticImageLoadImage(GUIEditor.staticimage[3], "button_standart.png") 
    end 
    ,false 
) 
  
  
    end 
addEventHandler("onClientResourceStart", resourceRoot, mypanel) 
  
function login(button) 
     if button="left" then 
        triggerServerEvent("onlogin", getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) ) 
     end 
end 
  
function register(button) 
    if button="left" then 
        triggerServerEvent("onregister", getLocalPlayer(), guiGetText(GUIEditor.edit[3]), guiGetText(GUIEditor.edit[4]) ) 
    end 
end 
  
addEvent("hideWindow", true) 
addEventHandler ("hideWindow", getRootElement(), 
function() 
for i,v in ipairs(edit) do ---destroy all mywind 
        if isElement(v) then 
            destroyElement(v) 
        end 
    end 
    showCursor(false) 
end) 
  
        
  
  
addEventHandler("onClientRender", root, 
    function() 
        dxDrawText("MTA RP PROJECT - ÁTNEVEZÉSRE VÁR -", 540, 257, 864, 281, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Bejelentkezés", 356, 303, 563, 346, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Bejelentkezés", 379, 536, 522, 568, tocolor(255, 255, 255, 255), 0.70, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Felhasználónév", 359, 346, 530, 371, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawText("Jelszó", 382, 424, 553, 449, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawText("Regisztráció", 928, 305, 1135, 348, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Felhasználónév", 944, 348, 1115, 373, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawText("Regisztráció", 959, 533, 1108, 561, tocolor(255, 255, 255, 255), 0.70, "pricedown", "left", "top", false, false, true, false, false) 
        dxDrawText("Jelszó", 958, 424, 1125, 447, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
) 
  

Should work fine

Link to comment
addEvent("onlogin", true) 
addEventHandler("onlogin", getRootElement(), 
    function (user, pass) 
        local account = getAccount(user, pass) 
    if account then 
        if (logIn (source, user, pass) == true) then 
            outputChatBox("Bejelentkeztél" .. user .. "nevű felhasználóba!") 
            triggerClientEvent(source, "hideWindow", getRootElement()) 
        else 
            outputChatBox("Bejelentkezési hiba történt... Kérlek próbáld meg később!") 
            end 
    else 
        outputChatBox("Helytelen felhasználónév / jelszó!") 
    end 
end 
) 

Try this, i changed line 5

Link to comment

Because you're not isolating it. You're simply checking if left-mouse button is clicked. You'll need to find a way to make sure that the mouse is being clicked on the staticimage.

I haven't actually done this before myself, but it might be possible to use onClientGUIClick and then make it like;

if(source == staticImageHere) then 

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