Jump to content

[SOLVED]help dxDrawRectangle BUG


Recommended Posts

Posted (edited)
  
local screenW, screenH = guiGetScreenSize() 
  
function window() 
Kicks = isMouseWithinRangeOf(screenW * 0.6676, screenH * 0.1719, screenW * 0.0974, screenH * 0.0495) 
if Kicks then  
dxDrawRectangle(screenW * 0.6676, screenH * 0.1719, screenW * 0.0974, screenH * 0.0495, tocolor(255, 255, 255, 255), false) 
else 
dxDrawRectangle(screenW * 0.6676, screenH * 0.1719, screenW * 0.0974, screenH * 0.0495, tocolor(255, 167, 15, 255), false) 
end 
end 
addEventHandler("onClientRender", root, window) 
  
function click(playerSource) 
kick = isMouseWithinRangeOf(screenW * 0.6676, screenH * 0.1719, screenW * 0.0974, screenH * 0.0495) 
if kick then  
  triggerServerEvent("KicKPlayer", getLocalPlayer()) 
end 
end 
addEventHandler("onClientClick",getRootElement(),click) 
  
function isMouseWithinRangeOf(psx,pssx,psy,pssy) 
  if not isCursorShowing() then 
    return false 
  end 
  local cx,cy = getCursorPosition() 
  cx,cy = cx*screenW,cy*screenH 
  if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then 
    return true,cx,cy 
  else 
    return false 
  end 
end 

Edited by Guest
Posted
dxDrawRectangle is used to draw a rectangle only, you can't make a function when the player clicks on it. Use GUI function instead.

You can capture clicks on dx elements by checking the mouse click position compaired to the dx element's position.

Example;

https://forum.multitheftauto.com/viewto ... 91&t=88456

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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