Jump to content

Help when click "PM"


VenomOG

Recommended Posts

So when mouse in position and i click it works but even if its out of position and i click it still open

  local resolutionX = 1366
    local resolutionY = 768
local	absolute,absoluteyy = nil
local msg = {}

function dxDrawRelativeText( text,posX,posY,right,bottom,color,scale,mixed_font,alignX,alignY,clip,wordBreak,postGUI )
    local resolutionX = 1366
    local resolutionY = 768
    local sWidth,sHeight = guiGetScreenSize( )
    return dxDrawX(
        tostring( text ),
        ( posX/resolutionX )*sWidth,
        ( posY/resolutionY )*sHeight,
        ( right/resolutionX )*sWidth,
        ( bottom/resolutionY)*sHeight,
        color,
        ( sWidth/resolutionX )*scale,
        mixed_font,
        alignX,
        alignY,
        clip,
        wordBreak,
        postGUI
	
    )
end
function dxDrawX( text, x, y, w, h, clr, scale, font, alignX, alignY, clip, wordBreak, postGUI )
    if not wh then wh = 1.3 end
	dxDrawText ( text, x, y, w, h, clr, scale, font, alignX, alignY, clip, wordBreak, postGUI, true)
end
function guiCreateRelativeLabel( posX, posY, width, height,text,postGUI )
    local resolutionX = 1366
    local resolutionY = 768
    local sWidth,sHeight = guiGetScreenSize( )
    return guiCreateLabel(
        ( posX/resolutionX )*sWidth,
        ( posY/resolutionY )*sHeight,
        ( width/resolutionX )*sWidth,
        ( height/resolutionY )*sHeight,
        tostring( text ),
        postGUI
    )
end
	
function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
    local sWidth,sHeight = guiGetScreenSize( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx* sWidth ), ( cy* sHeight )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end
function dxDrawRelativeRectangle( posX, posY, width, height,color,postGUI )
    local resolutionX = 1366
    local resolutionY = 768
    local sWidth,sHeight = guiGetScreenSize( )
    return dxDrawRectangle(
        ( posX/resolutionX )*sWidth,
        ( posY/resolutionY )*sHeight,
        ( width/resolutionX )*sWidth,
        ( height/resolutionY )*sHeight,
        color,
        postGUI
    )
end

local x,y = guiGetScreenSize()  -- Get players resolution.
    local sWidth,sHeight = guiGetScreenSize( )
function dxPanel()
dxDrawLine(0.2588, 0.6055, 0.2588,  0.6745, tocolor(6, 127, 3, 253), 1, false)
        dxDrawLine(0.4258, 0.6055, 0.2588, 0.6055, tocolor(6, 127, 3, 253), 1, false)
        dxDrawLine(0.2588,  0.6745, 0.4258,  0.6745, tocolor(6, 127, 3, 253), 1, false)
        dxDrawLine(0.4258,  0.6745, 0.4258, 0.6055, tocolor(6, 127, 3, 253), 1, false)
        dxDrawRectangle(190, 466, 80, 55, tocolor(183, 3, 117, 160), false)
        dxDrawRelativeText("PM", 265, 466, 462, 505, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawRelativeText("Give money", 265, 485, 422, 504, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawRelativeText("Invite", 265, 504, 422, 523, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
end
destroyElement(dxPanel)
addEvent("dx", true)
addEventHandler("dx", root,
function (test)
if panelOpen then
return
end
panelOpen = true
        dxDrawRectangle(150, 150, 80, -300.70, tocolor(183, 3, 117, 160), false)
        dxDrawRelativeText("PM", 265, 486, 522, 485, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawRelativeText("Give money", 265, 485, 422, 504, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawRelativeText("Invite", 265, 504, 422, 523, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
		addEventHandler("onClientRender", root, dxPanel)
end)	
function loadPlayers(wcard, grid)
	guiGridListClear(grid)
	for k, v in ipairs(getElementsByType("player")) do
		if wcard == " " or wcard == "" or string.find(string.lower(getPlayerName(v)), string.lower(wcard)) then
			local r = guiGridListAddRow(grid)
			guiGridListSetItemText(grid, r, 1, getPlayerName(v), false, false)
		end
	end
end
addEventHandler("onClientClick",root,
function(bttn,state)
    if bttn == "left" and state == "down" then
        if GonnaFade then return false end
        local resolutionX = 1366
        local resolutionY = 768
        local sWidth,sHeight = guiGetScreenSize( )
        if isMouseInPosition((265/resolutionX )*sWidth,(466/resolutionY )*sHeight, (462/resolutionX )*sWidth, (505/resolutionY )*sHeight) then
		local send = guiCreateButton(0.42, 0.70, 0.16, 0.04, "Send message", true)
				guiSetProperty(send, "NormalTextColour", "FFAAAAAA")



				guiMemoSetReadOnly(memo, true)
				local search = guiCreateEdit(0.42, 0.27, 0.16, 0.04, "Search...", true)
				local sms = guiCreateEdit(0.42, 0.66, 0.16, 0.04, "Type message here...", true)
				local grid = guiCreateGridList(0.42, 0.31, 0.16, 0.14, true)

				guiGridListAddColumn(grid, "Player name", 0.9)
				loadPlayers("", grid)
				addEventHandler("onClientGUIChanged", search, function ()
					loadPlayers(guiGetText(search), grid)
				end)
				addEventHandler("onClientGUIClick", grid, function ()
					if guiGridListGetSelectedItem(grid) >= 0 then
						local r = guiGridListGetSelectedItem(grid)
						loadSMS(guiGridListGetItemText(grid, r, 1))
						selectedSMS = getPlayerFromName(guiGridListGetItemText(grid, r, 1))
					end
				end)
				addEventHandler("onClientGUIClick", send, function ()
					if guiGridListGetSelectedItem(grid) >= 0 and guiGetText(sms) ~= "" and guiGetText(sms) ~= " " then
						local r = guiGridListGetSelectedItem(grid)
						triggerServerEvent("sendPlayerSMS", localPlayer, guiGridListGetItemText(grid, r, 1), guiGetText(sms))
						guiSetText(sms, "")
						guiSetEnabled(source, false)
						setTimer(guiSetEnabled, 2000, 1, source, true)
                end
				end) end end end)

I want if click any text and if mouse out of position it wont 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...