Jump to content

Problema ao pegar position no mapa


Recommended Posts

Galera, estou fazendo um painel onde ao clicar no local vai marcar o mapa, forem nunca mexi com caculo envolvendo mapa.

OBS: estou usando DGS framework, funções similar a o gui do mta.

https://prnt.sc/rk608u

local screenx, screeny = guiGetScreenSize()
local sx, sy = (screenx/1920), (screeny/1080)
loadstring(exports.dgs:dgsImportFunction())()
local blip = nil
local blip2 = nil
local width = 700
local height = 700
GangMarcar = dgsCreateWindow((screenx - sx*720)/2, (screeny - sy*810)/2, sx*720, sy*810, "MARQUE UM DESTINO PARA SUA GANG", false, tocolor(0, 0, 0, 255), sy*50, nil, tocolor(0, 255, 255, 150), nil, tocolor(0, 0, 0, 150), sy*5, true)
dgsWindowSetMovable(GangMarcar, false)
dgsWindowSetSizable(GangMarcar, false)
dgsSetVisible(GangMarcar, false)

GangMarcarMap = dgsCreateImage(sx*10, sy*10, width, width, "Images/radar.jpg", false, GangMarcar, tocolor(255,255,255,255))
GangMarcarLabel0 = dgsCreateLabel(sx*10, sy*10, sx*480, sy*20, "BOTÃO DIREITO DO MOUSE PRA TIRAR", false, GangCriar, tocolor(255, 255, 0, 255), sy*1.5, sy*1.5, sy*1.5, sy*1.5, tocolor(0, 0, 0, 255), "right", "center")
GangMarcarSair = dgsCreateButton(sx*610, sy*720, sx*100, sy*30, "SAIR", false, GangMarcar, tocolor(0, 0, 0, 255), sy*1.5, sy*1.5, nil, nil, nil, tocolor(255, 77, 77, 150), tocolor(255, 0, 0, 150), tocolor(255, 61, 153, 150))

addEventHandler("onDgsMouseClick", getRootElement(), function(button, state, absoluteX, absoluteY)
    if (button == "left" and state == "down") then
        if (source == GangMarcarMap) then
            local x = absoluteX*6000 - 3000
	        local y = 3000 - absoluteY*6000
            if not (blip) then
                createBlip(x, y, 0, 41)
                setElementPosition(localPlayer, x, y, 0)
            end
        elseif (source == GangMarcarSair) then
            dgsSetVisible(GangMarcar, false)
            dgsSetEnabled(Gang, true)
        end
    elseif (button == "right" and state == "down") then
        if (blip) then
            destroyElement(blip)
        end
    end
end)

 

Edited by OrbTanT
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...