Jump to content

!!!


MAB

Recommended Posts

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

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 by Guest
Link to comment
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
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
..

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

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