MAB Posted February 15, 2016 Share Posted February 15, 2016 nothing in debug.. i am sure that the code is right... and not working!!!!!!!!!! note that the localPlayer "loginpanel" data is set to true by another function...this isn't the full code.. it is the code that contains the problem.. when i click on the flag image nothing happens local sx,sy = guiGetScreenSize() local languages = { {name = "English",user = "Username:",pass = "Password:",login = "Login",register = "Register",flag = "images/uk.png"}, {name = "Arabic",user = "اسم المستخدم:",pass = "كلمة السر:",login = "دخول",register = "تسجيل",flag = "images/ksa.png"} } function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing ( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function draw() if getElementData(localPlayer,"loginpanel") == true then for i=1,#languages do if getElementData(localPlayer,"loginlanguage") == languages[i].name then dxDrawImage(sx - 70,10,58,34,languages[i].flag) end end end end addEventHandler("onClientRender",root,draw) function click(b,s) if getElementData(localPlayer,"loginpanel") == true then if b == "left" and s == "up" then if isMouseInPosition(sx - 70,10,58,34) then for i=1,#languages do if getElementData(localPlayer,"loginlanguage") == languages[#languages].name then setElementData(localPlayer,"loginlanguage",languages[1].name) else i = i + 1 setElementData(localPlayer,"loginlanguage",languages[i].name) end end end end end end addEventHandler("onClientClick",root,click) Link to comment
tosfera Posted February 15, 2016 Share Posted February 15, 2016 Where are your debug lines to see where it went wrong? I can at least see 6 mistakes in the function "click", go and write some debug lines in there and find out what's wrong. Link to comment
TAPL Posted February 15, 2016 Share Posted February 15, 2016 May you tell us what you're trying to achieve with this piece of the code? What you're expect to happen when the flag image clicked? Link to comment
MAB Posted February 15, 2016 Author Share Posted February 15, 2016 (edited) the data "loginlanguage" change and "draw" function display the text of the next language and flag.. i didn't even show the full function of "draw" but the problem is that click functions doesn't work... Edited February 15, 2016 by Guest Link to comment
MAB Posted February 15, 2016 Author Share Posted February 15, 2016 Where are your debug lines to see where it went wrong? I can at least see 6 mistakes in the function "click", go and write some debug lines in there and find out what's wrong. tell about the mistakes or don't annoy me Link to comment
TAPL Posted February 15, 2016 Share Posted February 15, 2016 function click(b,s) if getElementData(localPlayer,"loginpanel") == true then if b == "left" and s == "up" then if isMouseInPosition(sx - 70,10,58,34) then for i=1, #languages do if getElementData(localPlayer, "loginlanguage") ~= languages[i].name then setElementData(localPlayer, "loginlanguage", languages[i].name) break end end end end end end addEventHandler("onClientClick", root, click) Link to comment
MAB Posted February 15, 2016 Author Share Posted February 15, 2016 function click(b,s) if getElementData(localPlayer,"loginpanel") == true then if b == "left" and s == "up" then if isMouseInPosition(sx - 70,10,58,34) then for i=1, #languages do if getElementData(localPlayer, "loginlanguage") ~= languages[i].name then setElementData(localPlayer, "loginlanguage", languages[i].name) break end end end end end end addEventHandler("onClientClick", root, click) I am going to add more languages so this code will set them all in the same time which is not good If the player is in the last language then set his language as the first else set it the next.. hard? Link to comment
TAPL Posted February 15, 2016 Share Posted February 15, 2016 .. I am going to add more languages so this code will set them all in the same time which is not good If the player is in the last language then set his language as the first else set it the next.. hard? function click(b,s) if getElementData(localPlayer,"loginpanel") == true then if b == "left" and s == "up" then if isMouseInPosition(sx - 70,10,58,34) then for i=1, #languages do if getElementData(localPlayer, "loginlanguage") == languages[i].name then setElementData(localPlayer, "loginlanguage", languages[i < #languages and i+1 or 1].name) break end end end end end end addEventHandler("onClientClick", root, click) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now