Jump to content

como faço para abrir este painel neste marker ?


Recommended Posts

glock = createMarker(297.947, -80.809, 1000.600, "cylinder", 1, 255, 0, 0, 40)
setElementInterior(glock, 4)



local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender", root,
    function()
        dxDrawLine(365 - 1, 222 - 1, 365 - 1, 546, tocolor(48, 212, 5, 255), 1, false)
        dxDrawLine(660, 222 - 1, 365 - 1, 222 - 1, tocolor(48, 212, 5, 255), 1, false)
        dxDrawLine(365 - 1, 546, 660, 546, tocolor(48, 212, 5, 255), 1, false)
        dxDrawLine(660, 546, 660, 222 - 1, tocolor(48, 212, 5, 255), 1, false)
        dxDrawRectangle((screenW - 295) / 2, (screenH - 324) / 2, 295, 324, tocolor(28, 28, 28, 179), false)
        dxDrawRectangle(422, 254, 0, 66, tocolor(255, 255, 255, 255), false)
        dxDrawImage(365, 222, 295, 324, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(108, 108, 108, 77), false)
        dxDrawLine(375 - 1, 452 - 1, 375 - 1, 536, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(650, 452 - 1, 375 - 1, 452 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(375 - 1, 536, 650, 536, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(650, 536, 650, 452 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(375, 452, 275, 84, tocolor(21, 131, 10, 210), false)
        dxDrawText("R$15.000", 380 - 1, 398 - 1, 655 - 1, 448 - 1, tocolor(0, 0, 0, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("R$15.000", 380 + 1, 398 - 1, 655 + 1, 448 - 1, tocolor(0, 0, 0, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("R$15.000", 380 - 1, 398 + 1, 655 - 1, 448 + 1, tocolor(0, 0, 0, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("R$15.000", 380 + 1, 398 + 1, 655 + 1, 448 + 1, tocolor(0, 0, 0, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("R$15.000", 380, 398, 655, 448, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("comprar", 385, 464, 640, 526, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawRectangle(365, 222, 295, 32, tocolor(48, 212, 5, 255), false)
        dxDrawImage(442, 259, 150, 153, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("Glock-18", 369, 228, 654, 249, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", false, false, false, false, false)
    end
)

 

Edited by DNL291
Código adicionado com a formatação Lua
Link to comment

eu enviei o script errado perdão, vou mandar o correto!

  • Client
local screenW,screenH = guiGetScreenSize()
local resW, resH = 358,380
local x, y = (screenW/resW), (screenH/resH)

function Pdx ()
          dxDrawLine(333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawRectangle((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
        dxDrawImage(333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
        dxDrawImage(417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
        dxDrawRectangle(359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
        dxDrawText("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
    end

function abrir (_,state)
if painel == false then
showCursor(true)
addEventHandler("onClientRender", root, Pdx)
painel = true
else
showCursor(false)
removeEventHandler("onClientRender", root, Pdx)
painel = false
end
end
addEvent("painelglock", true)
addEventHandler("painelglock", root , abrir)

function togglePanel()
	if getElementData(localPlayer,nomeDaACL_Comandante) then
		if not isEventHandlerAdded("onClientRender",root,onClientRender) then
			guiGridListClear(playerList)
			for id, player in ipairs(getElementsByType("player")) do
				guiGridListSetItemText(playerList, guiGridListAddRow(playerList), 1, getPlayerName(player):gsub('#%x%x%x%x%x%x', ''), false, false)
			end
			guiSetVisible(playerList,true)
			guiSetVisible(edit,true)
			aVisible = true
			rVisible = true
			addEventHandler("onClientRender",root,onClientRender)
			showCursor(true)
		else
			guiSetVisible(playerList,false)
			guiSetVisible(edit,false)
			removeEventHandler("onClientRender",root,onClientRender)
			showCursor(false)			
		end
	end
end

function isCursorOnElement(x,y,w,h)
 local mx,my = getCursorPosition ()
 local fullx,fully = guiGetScreenSize()
 cursorx,cursory = mx*fullx,my*fully
 if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  return true
 else
  return false
 end
end

function arma (_,state)
if painel == true then
if  state == "down"  then
if  isCursorOnElement(372, 481, 659, 538) then
triggerServerEvent ("glock", localPlayer)
end
end
end
end
addEventHandler ("onClientClick", root, arma)
Link to comment
2 minutes ago, Jonas^ said:

Ele já te deu todos eventos/funções que você precisa, porque não tenta? quem sabe você consegue, não adianta você baixar esse resource aí e não saber nem como ele funciona.

Mas eu estou fazendo do zero, o problema é que só aprendi a por pela bind, mas queria alterar para um marker, procurei por videos explicativos e não encontrei. Mas vou dar mais uma olhada nos tópicos!

Link to comment

Ok, ainda acho estranho você me dizer que fez até aqui sozinho e não saber fazer uma coisa tão simples.

Aqui está:

Client

local screenW, screenH = guiGetScreenSize ()
local resW, resH = 358, 380
local x, y = (screenW/resW), (screenH/resH)
local markerWeapons = createMarker (x, y, z, "cylinder", 1.0, 255, 255, 255, 255) -- Coloque as coordenadas do seu marker aqui onde tem x, y, z.

function Pdx ()
	dxDrawLine (333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
	dxDrawRectangle ((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
	dxDrawImage (333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
	dxDrawImage (417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle (333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
	dxDrawRectangle (359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
	dxDrawText ("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
	dxDrawText ("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
	dxDrawText ("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
end

addEventHandler ("onClientMarkerHit", markerWeapons, function (hitElement, matchingDimension)
	if (getElementType (hitElement) == "player") then
		abrir ()
	end
end)

function abrir (_, state)
	if painel == false then
		showCursor (true)
		addEventHandler ("onClientRender", root, Pdx)
		painel = true
	else
		showCursor (false)
		removeEventHandler ("onClientRender", root, Pdx)
		painel = false
	end
end
addEvent ("painelglock", true)
addEventHandler ("painelglock", root , abrir)

--[[ -- Não entendi necessidade disso aqui, deixei comentado.
function togglePanel ()
	if getElementData (localPlayer, nomeDaACL_Comandante) then
		if not isEventHandlerAdded ("onClientRender", root, onClientRender) then
			guiGridListClear (playerList)
			for id, player in ipairs(getElementsByType("player")) do
				guiGridListSetItemText (playerList, guiGridListAddRow(playerList), 1, getPlayerName(player):gsub('#%x%x%x%x%x%x', ''), false, false)
			end
			guiSetVisible (playerList, true)
			guiSetVisible (edit, true)
			aVisible = true
			rVisible = true
			addEventHandler ("onClientRender", root, onClientRender)
			showCursor (true)
		else
			guiSetVisible (playerList, false)
			guiSetVisible (edit, false)
			removeEventHandler ("onClientRender", root, onClientRender)
			showCursor (false)			
		end
	end
end
--]]

function isCursorOnElement (x, y, w, h)
	local mx,my = getCursorPosition ()
	local fullx,fully = guiGetScreenSize ()
	cursorx,cursory = mx * fullx, my * fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end

function arma (_, state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement (372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

Server

function arma ()
	giveWeapon (source, 22, 300, true)
	outputChatBox ("( #ff0000INFO#ffffff ) #ffff00Você comprou #00ff00Glock-18 !", source, 255, 255, 255, true)
end
addEvent ("glock",true)
addEventHandler ("glock", root, arma)

OBS: Não testado, vale lembrar que é bom sempre você indentar o código, assim fica mais fácil de você entender e o código fica mais organizado.

  • Thanks 1
Link to comment
13 hours ago, Jonas^ said:

Ok, ainda acho estranho você me dizer que fez até aqui sozinho e não saber fazer uma coisa tão simples.

Aqui está:

Client


local screenW, screenH = guiGetScreenSize ()
local resW, resH = 358, 380
local x, y = (screenW/resW), (screenH/resH)
local markerWeapons = createMarker (x, y, z, "cylinder", 1.0, 255, 255, 255, 255) -- Coloque as coordenadas do seu marker aqui onde tem x, y, z.

function Pdx ()
	dxDrawLine (333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
	dxDrawRectangle ((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
	dxDrawImage (333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
	dxDrawImage (417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle (333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
	dxDrawRectangle (359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
	dxDrawText ("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
	dxDrawText ("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
	dxDrawText ("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
end

addEventHandler ("onClientMarkerHit", markerWeapons, function (hitElement, matchingDimension)
	if (getElementType (hitElement) == "player") then
		abrir ()
	end
end)

function abrir (_, state)
	if painel == false then
		showCursor (true)
		addEventHandler ("onClientRender", root, Pdx)
		painel = true
	else
		showCursor (false)
		removeEventHandler ("onClientRender", root, Pdx)
		painel = false
	end
end
addEvent ("painelglock", true)
addEventHandler ("painelglock", root , abrir)

--[[ -- Não entendi necessidade disso aqui, deixei comentado.
function togglePanel ()
	if getElementData (localPlayer, nomeDaACL_Comandante) then
		if not isEventHandlerAdded ("onClientRender", root, onClientRender) then
			guiGridListClear (playerList)
			for id, player in ipairs(getElementsByType("player")) do
				guiGridListSetItemText (playerList, guiGridListAddRow(playerList), 1, getPlayerName(player):gsub('#%x%x%x%x%x%x', ''), false, false)
			end
			guiSetVisible (playerList, true)
			guiSetVisible (edit, true)
			aVisible = true
			rVisible = true
			addEventHandler ("onClientRender", root, onClientRender)
			showCursor (true)
		else
			guiSetVisible (playerList, false)
			guiSetVisible (edit, false)
			removeEventHandler ("onClientRender", root, onClientRender)
			showCursor (false)			
		end
	end
end
--]]

function isCursorOnElement (x, y, w, h)
	local mx,my = getCursorPosition ()
	local fullx,fully = guiGetScreenSize ()
	cursorx,cursory = mx * fullx, my * fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end

function arma (_, state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement (372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

Server


function arma ()
	giveWeapon (source, 22, 300, true)
	outputChatBox ("( #ff0000INFO#ffffff ) #ffff00Você comprou #00ff00Glock-18 !", source, 255, 255, 255, true)
end
addEvent ("glock",true)
addEventHandler ("glock", root, arma)

OBS: Não testado, vale lembrar que é bom sempre você indentar o código, assim fica mais fácil de você entender e o código fica mais organizado.

Muito, obrigado, estou em outra conta pois minha senha n ta entrando, mas você ajudou muito.
Eu fiz o script faz tempo e agora quero retomalo

Link to comment
14 hours ago, Jonas^ said:

Ok, ainda acho estranho você me dizer que fez até aqui sozinho e não saber fazer uma coisa tão simples.

Aqui está:

Client


local screenW, screenH = guiGetScreenSize ()
local resW, resH = 358, 380
local x, y = (screenW/resW), (screenH/resH)
local markerWeapons = createMarker (x, y, z, "cylinder", 1.0, 255, 255, 255, 255) -- Coloque as coordenadas do seu marker aqui onde tem x, y, z.

function Pdx ()
	dxDrawLine (333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
	dxDrawLine (691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
	dxDrawRectangle ((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
	dxDrawImage (333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
	dxDrawImage (417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle (333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
	dxDrawRectangle (359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
	dxDrawText ("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
	dxDrawText ("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
	dxDrawText ("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
end

addEventHandler ("onClientMarkerHit", markerWeapons, function (hitElement, matchingDimension)
	if (getElementType (hitElement) == "player") then
		abrir ()
	end
end)

function abrir (_, state)
	if painel == false then
		showCursor (true)
		addEventHandler ("onClientRender", root, Pdx)
		painel = true
	else
		showCursor (false)
		removeEventHandler ("onClientRender", root, Pdx)
		painel = false
	end
end
addEvent ("painelglock", true)
addEventHandler ("painelglock", root , abrir)

--[[ -- Não entendi necessidade disso aqui, deixei comentado.
function togglePanel ()
	if getElementData (localPlayer, nomeDaACL_Comandante) then
		if not isEventHandlerAdded ("onClientRender", root, onClientRender) then
			guiGridListClear (playerList)
			for id, player in ipairs(getElementsByType("player")) do
				guiGridListSetItemText (playerList, guiGridListAddRow(playerList), 1, getPlayerName(player):gsub('#%x%x%x%x%x%x', ''), false, false)
			end
			guiSetVisible (playerList, true)
			guiSetVisible (edit, true)
			aVisible = true
			rVisible = true
			addEventHandler ("onClientRender", root, onClientRender)
			showCursor (true)
		else
			guiSetVisible (playerList, false)
			guiSetVisible (edit, false)
			removeEventHandler ("onClientRender", root, onClientRender)
			showCursor (false)			
		end
	end
end
--]]

function isCursorOnElement (x, y, w, h)
	local mx,my = getCursorPosition ()
	local fullx,fully = guiGetScreenSize ()
	cursorx,cursory = mx * fullx, my * fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end

function arma (_, state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement (372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

Server


function arma ()
	giveWeapon (source, 22, 300, true)
	outputChatBox ("( #ff0000INFO#ffffff ) #ffff00Você comprou #00ff00Glock-18 !", source, 255, 255, 255, true)
end
addEvent ("glock",true)
addEventHandler ("glock", root, arma)

OBS: Não testado, vale lembrar que é bom sempre você indentar o código, assim fica mais fácil de você entender e o código fica mais organizado.

O marker apareceu mas não abriu o painel, o debugscript não detectou nenhum erro.

 

local screenW,screenH = guiGetScreenSize()
local resW, resH = 1365,767
local x, y = (screenW/resW), (screenH/resH)
local glock = createMarker(297.947, -80.809, 1000.600, "cylinder", 1, 255, 0, 0, 40)
setElementInterior(glock, 4)

function Pdx () -----Painel
          dxDrawLine(333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawRectangle((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
        dxDrawImage(333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
        dxDrawImage(417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
        dxDrawRectangle(359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
        dxDrawText("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
    end


addEventHandler("onClientHitMarker", glock, function ( hitElement, matchingDimension )  ------Abrir painel no Marker
	if (getElementType(hitElement) == "player") then
	abrir ()
	end
end)



function abrir (_,state)  -------Render do Painel
if painel == false then
showCursor(true)
addEventHandler("onClientRender", root, Pdx)
painel = true
else
showCursor(false)
removeEventHandler("onClientRender", root, Pdx)
painel = false
end
end
addEvent("painelglock", true)
addEventHandler("painelglock", root , abrir)


function isCursorOnElement(x,y,w,h)  ------Cursor
 local mx,my = getCursorPosition ()
 local fullx,fully = guiGetScreenSize()
 cursorx,cursory = mx*fullx,my*fully
 if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  return true
 	else
  return false
 end
end



function arma (_,state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement(372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

meu script ta assim

Edited by MatheusWW
Link to comment
local screenW,screenH = guiGetScreenSize()
local resW, resH = 1365,767
local x, y = (screenW/resW), (screenH/resH)
local glock = createMarker(297.947, -80.809, 1000.600, "cylinder", 1, 255, 0, 0, 40)
setElementInterior(glock, 4)

function Pdx () -----Painel
          dxDrawLine(333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawRectangle((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
        dxDrawImage(333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
        dxDrawImage(417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
        dxDrawRectangle(359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
        dxDrawText("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
    end


function render(hitPlayer, matchingdimension)
    if (hitPlayer == localPlayer) then
        addEventHandler("onClientRender", root, Pdx)
        render = true
        showCursor(true)
    end
end
addEventHandler ("onClientMarkerHit", glock, render)


function abrir (_,state)  -------Render do Painel
if painel == false then
showCursor(true)
addEventHandler("onClientRender", root, Pdx)
painel = true
else
showCursor(false)
removeEventHandler("onClientRender", root, Pdx)
painel = false
end
end
addEvent("painelglock", true)
addEventHandler("painelglock", root , abrir)


function isCursorOnElement(x,y,w,h)  ------Cursor
 local mx,my = getCursorPosition ()
 local fullx,fully = guiGetScreenSize()
 cursorx,cursory = mx*fullx,my*fully
 if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  return true
 	else
  return false
 end
end



function arma (_,state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement(372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

Se isso não funcionar, remova da linha 31 a 43 e tente denovo.

  • Thanks 1
Link to comment
function render(hitPlayer, matchingDimension)
	if (hitPlayer == localPlayer) then
		addEventHandler("onClientRender", root, pdx) ----Erro
		render = true
		showCursor (true)
	end
end
addEventHandler("onClientMarkerHit", glock, render)

 

Apareceu só cursor, e o debug detectou um erro no addEventHandler

http://prnt.sc/omkkhl

 

Edited by MatheusWW
Link to comment
function render(hitPlayer, matchingDimension)
	if (hitPlayer == localPlayer) then
		addEventHandler("onClientRender", root, Pdx) ----Erro
		render = true
		showCursor (true)
	end
end
addEventHandler("onClientMarkerHit", glock, render)

Assim deverá funcionar

  • Thanks 1
Link to comment
36 minutes ago, MesaDowN said:

function render(hitPlayer, matchingDimension)	if (hitPlayer == localPlayer) then		addEventHandler("onClientRender", root, Pdx) ----Erro		render = true		showCursor (true)	endendaddEventHandler("onClientMarkerHit", glock, render)

Assim deverá funcionar

persiste o mesmo erro

Link to comment
local screenW,screenH = guiGetScreenSize()
local resW, resH = 1365,767
local x, y = (screenW/resW), (screenH/resH)
local glock = createMarker(297.947, -80.809, 1000.600, "cylinder", 1, 255, 0, 0, 40)
setElementInterior(glock, 4)

function Pdx () -----Painel
          dxDrawLine(333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawRectangle((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
        dxDrawImage(333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
        dxDrawImage(417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
        dxDrawRectangle(359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
        dxDrawText("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
    end


function render(hitPlayer, matchingdimension)
    if (hitPlayer == localPlayer) then
        addEventHandler("onClientRender", root, Pdx)
        render = true
        showCursor(true)
    end
end
addEventHandler ("onClientMarkerHit", glock, render)


function abrir (_,state)  -------Render do Painel
if painel == false then
showCursor(true)
addEventHandler("onClientRender", root, Pdx)
painel = true
else
showCursor(false)
removeEventHandler("onClientRender", root, Pdx)
painel = false
end
end
addEvent("painelglock", true)
addEventHandler("painelglock", root , abrir)


function isCursorOnElement(x,y,w,h)  ------Cursor
 local mx,my = getCursorPosition ()
 local fullx,fully = guiGetScreenSize()
 cursorx,cursory = mx*fullx,my*fully
 if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  return true
 	else
  return false
 end
end



function arma (_,state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement(372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

Para mim funcionou, qual o seu problema no debugscript?
Edit: https://imgur.com/a/opRPMbu ficou assim.

Edited by MesaDowN
  • Thanks 1
Link to comment

25 Bad argument @ "addEventHandler" [expected function at argument 3, got nil]

local screenW,screenH = guiGetScreenSize()
local resW, resH = 1365,767
local x, y = (screenW/resW), (screenH/resH)
local glock = createMarker(297.947, -80.809, 1000.600, "cylinder", 1, 255, 0, 0, 40)
setElementInterior(glock, 4)

function Pdx ()
          dxDrawLine(333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)
        dxDrawLine(691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)
        dxDrawRectangle((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)
        dxDrawImage(333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)
        dxDrawImage(417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(333, 194, 358, 53, tocolor(21, 133, 6, 111), false)
        dxDrawRectangle(359, 468, 310, 80, tocolor(21, 133, 6, 111), false)
        dxDrawText("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)
    end


function render(hitPlayer, matchingDimension)
	if (hitPlayer == localPlayer) then
		addEventHandler("onClientRender", root, pdx)
		render = true
		showCursor(true)
	end
end
addEventHandler("onClientMarkerHit", glock, render)

function abrir (_,state)
	if painel == false then
		showCursor(true)
		addEventHandler("onClientRender", root, Pdx)
		painel = true
		else
		showCursor(false)
		removeEventHandler("onClientRender", root, Pdx)
		painel = false
	end
end
addEvent("painelglock", true)
addEventHandler("painelglock", root , abrir)


function isCursorOnElement(x,y,w,h)
 local mx,my = getCursorPosition ()
 local fullx,fully = guiGetScreenSize()
 cursorx,cursory = mx*fullx,my*fully
 if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  return true
 	else
  return false
 end
end



function arma (_,state)
	if painel == true then
		if  state == "down"  then
			if  isCursorOnElement(372, 481, 659, 538) then
				triggerServerEvent ("glock", localPlayer)
			end
		end
	end
end
addEventHandler ("onClientClick", root, arma)

eu digitei exatamente como tu me passou

19 minutes ago, MesaDowN said:

local screenW,screenH = guiGetScreenSize()local resW, resH = 1365,767local x, y = (screenW/resW), (screenH/resH)local glock = createMarker(297.947, -80.809, 1000.600, "cylinder", 1, 255, 0, 0, 40)setElementInterior(glock, 4)function Pdx () -----Painel          dxDrawLine(333 - 1, 194 - 1, 333 - 1, 574, tocolor(38, 237, 11, 254), 1, false)        dxDrawLine(691, 194 - 1, 333 - 1, 194 - 1, tocolor(38, 237, 11, 254), 1, false)        dxDrawLine(333 - 1, 574, 691, 574, tocolor(38, 237, 11, 254), 1, false)        dxDrawLine(691, 574, 691, 194 - 1, tocolor(38, 237, 11, 254), 1, false)        dxDrawRectangle((screenW - 358) / 2, (screenH - 380) / 2, 358, 380, tocolor(0, 0, 0, 138), false)        dxDrawImage(333, 194, 358, 380, ":GUI/images/examples/new_city_sfundo.png", 0, 0, 0, tocolor(254, 254, 254, 50), false)        dxDrawImage(417, 257, 202, 160, ":GUI/images/examples/G-18.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        dxDrawRectangle(333, 194, 358, 53, tocolor(21, 133, 6, 111), false)        dxDrawRectangle(359, 468, 310, 80, tocolor(21, 133, 6, 111), false)        dxDrawText("R$15.000", 346, 417, 681, 463, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)        dxDrawText("Glock-18", 338, 203, 681, 237, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)        dxDrawText("comprar", 372, 481, 659, 538, tocolor(255, 255, 255, 255), 2.00, "pricedown", "center", "center", false, false, false, false, false)    endfunction render(hitPlayer, matchingdimension)    if (hitPlayer == localPlayer) then        addEventHandler("onClientRender", root, Pdx)        render = true        showCursor(true)    endendaddEventHandler ("onClientMarkerHit", glock, render)function abrir (_,state)  -------Render do Painelif painel == false thenshowCursor(true)addEventHandler("onClientRender", root, Pdx)painel = trueelseshowCursor(false)removeEventHandler("onClientRender", root, Pdx)painel = falseendendaddEvent("painelglock", true)addEventHandler("painelglock", root , abrir)function isCursorOnElement(x,y,w,h)  ------Cursor local mx,my = getCursorPosition () local fullx,fully = guiGetScreenSize() cursorx,cursory = mx*fullx,my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then  return true 	else  return false endendfunction arma (_,state)	if painel == true then		if  state == "down"  then			if  isCursorOnElement(372, 481, 659, 538) then				triggerServerEvent ("glock", localPlayer)			end		end	endendaddEventHandler ("onClientClick", root, arma)

Para mim funcionou, qual o seu problema no debugscript?
Edit: https://imgur.com/a/opRPMbu ficou assim.

é isso mesmo q tem que acontecer mas o meu ta dando esse erro nao sei pq

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