Jump to content

problem with DX functions


MAB

Recommended Posts

my problem it that when i click under the button ( text ) it do the function.. i want it to the function when it is clicked only not on it and under it... and the X (close) button .. when i click on its right it works.. it should be on it only not on it and on it is right .. i hope u understood me..

local sx, sy = guiGetScreenSize() 
local x, y = (sx/1280), (sy/768) 
local s = (sx/1280) 
local color = tocolor(255, 255, 255, 255) 
local color2 = tocolor(255, 255, 255, 255) 
local color3 = tocolor(255, 255, 255, 255) 
local color4 = tocolor(255, 255, 255, 255) 
local marker = createMarker(0,0,0) 
  
function draw () 
if isPedInVehicle (localPlayer) then return end 
showCursor(true) 
showChat(false) 
setPlayerHudComponentVisible("all",false) 
dxDrawRectangle(x*280, y*82, x*700, y*60, tocolor(0, 0, 0, 100), false) 
dxDrawText("Torso", x*289, y*92, x*385, y*120, color, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawText("Legs", x*478, y*92, x*556, y*120, color2, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawText("Head", x*662, y*92, x*743, y*120, color3, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawText("Hands", x*852, y*92, x*954, y*120, color4, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawRectangle(x*980, y*81, x*77, y*61, tocolor(255, 0, 0, 100), false) 
dxDrawText("X", x*1007, y*95, x*1030, y*123, tocolor(255, 255, 255, 255), s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
end 
addEventHandler("onClientRender",root,draw) 
  
function dx_click (b, s, x2, y2) 
    if (b == 'left' and s == 'up') then 
    if ( x2 >= x*1007 and x2 <= (x*1007) + (x*730) and y2 > (y*95) and y2 < (y*95) + (y*123) ) then 
       removeEventHandler('onClientClick', root, dx_click) 
       removeEventHandler("onClientRender",root,draw) 
       showCursor(false) 
       showChat(true) 
       setPlayerHudComponentVisible("all",true) 
    end 
    if ( x2 >= x*289 and x2 <= (x*289) + (x*85) and y2 > (y*92) and y2 < (y*92) + (y*120) ) then 
       color = tocolor(255, 255, 0, 255) 
       color2 = tocolor(255, 255, 255, 255) 
       color3 = tocolor(255, 255, 255, 255) 
       color4 = tocolor(255, 255, 255, 255) 
    end 
    if ( x2 >= x*478 and x2 <= (x*478) + (x*256) and y2 > (y*92) and y2 < (y*92) + (y*120) ) then 
       color2 = tocolor(255, 255, 0, 255) 
       color = tocolor(255, 255, 255, 255) 
       color3 = tocolor(255, 255, 255, 255) 
       color4 = tocolor(255, 255, 255, 255) 
    end 
    end 
end 
addEventHandler('onClientClick', root, dx_click) 

Link to comment
it should be on it only not on it and on it is right .. i hope u understood me..

Sorry but I haven't got the slightest clue what you're trying to say :P Also;

showCursor(true) 
showChat(false) 
setPlayerHudComponentVisible("all",false) 

You really only need to do this once, why do you need to run this 30-60 times per second?

Link to comment
local sx, sy = guiGetScreenSize() 
local x, y = (sx/1280), (sy/768) 
local s = (sx/1280) 
local color = tocolor(255, 255, 255, 255) 
local color2 = tocolor(255, 255, 255, 255) 
local color3 = tocolor(255, 255, 255, 255) 
local color4 = tocolor(255, 255, 255, 255) 
local marker = createMarker(0,0,0) 
  
function draw () 
if isPedInVehicle (localPlayer) then return end 
showCursor(true) 
showChat(false) 
setPlayerHudComponentVisible("all",false) 
dxDrawRectangle(x*280, y*82, x*700, y*60, tocolor(0, 0, 0, 100), false) 
dxDrawText("Torso", x*289, y*92, x*385, y*120, color, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawText("Legs", x*478, y*92, x*556, y*120, color2, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawText("Head", x*662, y*92, x*743, y*120, color3, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawText("Hands", x*852, y*92, x*954, y*120, color4, s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
dxDrawRectangle(x*980, y*81, x*77, y*61, tocolor(255, 0, 0, 100), false) 
dxDrawText("X", x*1007, y*95, x*1030, y*123, tocolor(255, 255, 255, 255), s*1.00, "bankgothic", "left", "top", false, false, false, false, false) 
end 
addEventHandler("onClientRender",root,draw) 
  
function dx_click (b, s, x2, y2) 
    if (b == 'left' and s == 'up') then 
    if ( x2 >= x*980 and x2 <= x*980 + x*77 and y2 > y*81 and y2 < y*81 + y*61 ) then 
       removeEventHandler('onClientClick', root, dx_click) 
       removeEventHandler("onClientRender",root,draw) 
       showCursor(false) 
       showChat(true) 
       setPlayerHudComponentVisible("all",true) 
    end 
    if ( x2 >= x*289 and x2 <= (x*289) + (x*85) and y2 > (y*92) and y2 < (y*92) + (y*120) ) then 
       color = tocolor(255, 255, 0, 255) 
       color2 = tocolor(255, 255, 255, 255) 
       color3 = tocolor(255, 255, 255, 255) 
       color4 = tocolor(255, 255, 255, 255) 
    end 
    if ( x2 >= x*478 and x2 <= (x*478) + (x*256) and y2 > (y*92) and y2 < (y*92) + (y*120) ) then 
       color2 = tocolor(255, 255, 0, 255) 
       color = tocolor(255, 255, 255, 255) 
       color3 = tocolor(255, 255, 255, 255) 
       color4 = tocolor(255, 255, 255, 255) 
    end 
    end 
end 
addEventHandler('onClientClick', root, dx_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...