Jump to content

Fazer aparece o painel quando passar no marker!


Recommended Posts

Opa, sou novo na programação do MTA e estou com dificuldades de fazer um script.

Criei um painel com o guieditor e queria que ele abrisse quando eu passasse no marker, e descobrir que a função do marker fica no server e de abrir o painel no client, 

pesquisei para entende como ligo um ao outro e descobrir o addEvent, porém não conseguir fazer até agora, fiz de varias maneiras mais estou muito confuso e já fiquei perdido e sem ideias, se alguém poder me ajudar ficarei muito agradecido !!

agradeço !! o Primeiro é o lado do Client e o outro é do lado do Serve.


addEvent("painelTrafico", true )
local visible = false 
local screenW, screenH = guiGetScreenSize()
    function painel()
        dxDrawLine((screenW * 0.2632) - 1, (screenH * 0.3021) - 1, (screenW * 0.2632) - 1, screenH * 0.7526, tocolor(45, 191, 25, 254), 1, false)
        dxDrawLine(screenW * 0.7801, (screenH * 0.3021) - 1, (screenW * 0.2632) - 1, (screenH * 0.3021) - 1, tocolor(45, 191, 25, 254), 1, false)
        dxDrawLine((screenW * 0.2632) - 1, screenH * 0.7526, screenW * 0.7801, screenH * 0.7526, tocolor(45, 191, 25, 254), 1, false)
        dxDrawLine(screenW * 0.7801, screenH * 0.7526, screenW * 0.7801, (screenH * 0.3021) - 1, tocolor(45, 191, 25, 254), 1, false)
        dxDrawRectangle(screenW * 0.2632, screenH * 0.3021, screenW * 0.5169, screenH * 0.4505, tocolor(35, 75, 33, 244), false)
        dxDrawText("Trabalho Ilegal -BVC", screenW * 0.2559, screenH * 0.3021, screenW * 0.7750, screenH * 0.3607, tocolor(96, 248, 88, 254), 1.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Ganho: R$ 580", screenW * 0.4169, screenH * 0.4688, screenW * 0.6110, screenH * 0.5625, tocolor(16, 189, 7, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
        dxDrawLine((screenW * 0.4176) - 1, (screenH * 0.5977) - 1, (screenW * 0.4176) - 1, screenH * 0.6641, tocolor(16, 189, 7, 254), 1, false)
        dxDrawLine(screenW * 0.6125, (screenH * 0.5977) - 1, (screenW * 0.4176) - 1, (screenH * 0.5977) - 1, tocolor(16, 189, 7, 254), 1, false)
        dxDrawLine((screenW * 0.4176) - 1, screenH * 0.6641, screenW * 0.6125, screenH * 0.6641, tocolor(16, 189, 7, 254), 1, false)
        dxDrawLine(screenW * 0.6125, screenH * 0.6641, screenW * 0.6125, (screenH * 0.5977) - 1, tocolor(16, 189, 7, 254), 1, false)
        dxDrawRectangle(screenW * 0.4176, screenH * 0.5977, screenW * 0.1949, screenH * 0.0664, tocolor(107, 0, 0, 254), false)
        dxDrawText("Pegar Trabalho ", screenW * 0.4169, screenH * 0.5951, screenW * 0.6125, screenH * 0.6641, tocolor(207, 141, 36, 199), 1.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Carga de Maconha", screenW * 0.4206, screenH * 0.3867, screenW * 0.6110, screenH * 0.4557, tocolor(107, 0, 0, 254), 2.00, "diploma", "center", "center", false, false, false, false, false)
   
    end
	function abrirPainel()
	if visible == true then
	addEventHandler("onClientRender", getRootElement(), painel)
		end
	end

addEventHandler("painelTrafico" root, painel, abrirPainel)

aqui

local mrk = createMarker (2493.9443359375,-952.806640625,81.248107910156, "cylinder", 2, 211, 102 ,13)


	function trafico()
		outputChatBox("teste!!")
		visible = true 
		triggerClientEvent("painelTrafico", root)
	
	end
	addEventHandler("onMarkerHit", mrk, trafico)

Obrigado!!

Link to comment

Algumas funções tem o lado client e o lado server, o MarkerHit é um exemplo.

Para usar como client:
addEventHandler("onClientMarkerHit", marker, função)

No server-side:
addEventHandler("onMarkerHit", marker, função)

Arrumei seu código, você pode colar isso aqui em seu client script e deve funcionar:
 

local visible = false
local mrk = createMarker (2493.9443359375,-952.806640625,81.248107910156, "cylinder", 2, 211, 102 ,13)
local screenW, screenH = guiGetScreenSize()
function painel()
    dxDrawLine((screenW * 0.2632) - 1, (screenH * 0.3021) - 1, (screenW * 0.2632) - 1, screenH * 0.7526, tocolor(45, 191, 25, 254), 1, false)
    dxDrawLine(screenW * 0.7801, (screenH * 0.3021) - 1, (screenW * 0.2632) - 1, (screenH * 0.3021) - 1, tocolor(45, 191, 25, 254), 1, false)
    dxDrawLine((screenW * 0.2632) - 1, screenH * 0.7526, screenW * 0.7801, screenH * 0.7526, tocolor(45, 191, 25, 254), 1, false)
    dxDrawLine(screenW * 0.7801, screenH * 0.7526, screenW * 0.7801, (screenH * 0.3021) - 1, tocolor(45, 191, 25, 254), 1, false)
    dxDrawRectangle(screenW * 0.2632, screenH * 0.3021, screenW * 0.5169, screenH * 0.4505, tocolor(35, 75, 33, 244), false)
    dxDrawText("Trabalho Ilegal -BVC", screenW * 0.2559, screenH * 0.3021, screenW * 0.7750, screenH * 0.3607, tocolor(96, 248, 88, 254), 1.00, "pricedown", "center", "center", false, false, false, false, false)
    dxDrawText("Ganho: R$ 580", screenW * 0.4169, screenH * 0.4688, screenW * 0.6110, screenH * 0.5625, tocolor(16, 189, 7, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawLine((screenW * 0.4176) - 1, (screenH * 0.5977) - 1, (screenW * 0.4176) - 1, screenH * 0.6641, tocolor(16, 189, 7, 254), 1, false)
    dxDrawLine(screenW * 0.6125, (screenH * 0.5977) - 1, (screenW * 0.4176) - 1, (screenH * 0.5977) - 1, tocolor(16, 189, 7, 254), 1, false)
    dxDrawLine((screenW * 0.4176) - 1, screenH * 0.6641, screenW * 0.6125, screenH * 0.6641, tocolor(16, 189, 7, 254), 1, false)
    dxDrawLine(screenW * 0.6125, screenH * 0.6641, screenW * 0.6125, (screenH * 0.5977) - 1, tocolor(16, 189, 7, 254), 1, false)
    dxDrawRectangle(screenW * 0.4176, screenH * 0.5977, screenW * 0.1949, screenH * 0.0664, tocolor(107, 0, 0, 254), false)
    dxDrawText("Pegar Trabalho ", screenW * 0.4169, screenH * 0.5951, screenW * 0.6125, screenH * 0.6641, tocolor(207, 141, 36, 199), 1.00, "pricedown", "center", "center", false, false, false, false, false)
    dxDrawText("Carga de Maconha", screenW * 0.4206, screenH * 0.3867, screenW * 0.6110, screenH * 0.4557, tocolor(107, 0, 0, 254), 2.00, "diploma", "center", "center", false, false, false, false, false)
end


function abrirPainel()
    if not visible then
        visible = true
        addEventHandler("onClientRender", getRootElement(), painel)
    else
        visible = false
        removeEventHandler("onClientRender", getRootElement(), painel)
    end
end
addEventHandler("onClientMarkerHit", mrk, abrirPainel)

addEventHandler("onClientMarkerLeave", mrk, function ()
    visible = false
    removeEventHandler("onClientRender", getRootElement(), painel)
end)


 

Edited by tasty
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...