Jump to content

[DUVIDA]PAINEL DX NAO ABRE NO MARKER


Recommended Posts

 

ola sou novo no sistema de dx, mas estou comecando a aprender agora, e estou tentando fazer um aqui, mas o debugscript 3 consta que esta tudo certo, mas o painel nao abre, ainda nao coloquei funcao para clicar em algo e fechar, mas so quero que ele abra apenas o painel mas ainda nada.

CLIENT

local screenW,screenH = guiGetScreenSize()
local resW,resH = 1366,768
local x,y =  (screenW/resW), (screenH/resH)

painel = false

-------------------------------------
function PainelBIKE ()
        dxDrawImage(screenW * 0.1589, screenH * 0.0130, screenW * 0.6292, screenH * 0.9259, "painel.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(screenW * 0.6865, screenH * 0.2056, screenW * 0.0359, screenH * 0.0574, "fechar.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(screenW * 0.2474, screenH * 0.2806, screenW * 0.1953, screenH * 0.3704, "bmx.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(screenW * 0.4828, screenH * 0.2806, screenW * 0.1964, screenH * 0.3704, "mountain.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(screenW * 0.3594, screenH * 0.5861, screenW * 0.1974, screenH * 0.1370, "alugar.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end

----------------------------------------

function Open (_,state)
	if painel == false then
		showCursor(true)
		addEventHandler("onClientRender", root, PainelBIKE)
		painel = true
	else
		showCursor(false)
		removeEventHandler("onClientRender", root, PainelBIKE)
		painel = false
	end
end
addEvent("OpenDxBike", true)
addEventHandler("OpenDxBike", root, Open)
Quote

SERVER
 

mrkpanel = createMarker(1489.361, -1741.148, 13.547 -1,"cylinder",1.2,0,0,255,255)

function AbrirPainelBike(thePlayer)
  local account = getPlayerAccount (thePlayer)
  if isGuestAccount (account) then outputChatBox ( "#ff0000✘ #ffffffAGENCIA #ff0000✘➺ #FFFFFFVocê não pode alugar um bike deslogado, Crie uma Conta!", thePlayer, 255,255,255,true) return end
  if isElementWithinMarker(thePlayer, mrkpanel) then
    triggerClientEvent(thePlayer,"OpenDxBike")
  end
end
addEventHandler("onMarkerHit", mrkpanel, AbrirPainelBike)

 

Link to comment

Server-side

 

mrkpanel = createMarker(1489.361, -1741.148, 13.547 -1,"cylinder",1.2,0,0,255,255)

function AbrirPainelBike(hitElement)
  local thePlayer = hitElement
  local account = getPlayerAccount (thePlayer)
  if isGuestAccount (account) then outputChatBox ( "#ff0000✘ #ffffffAGENCIA #ff0000✘➺ #FFFFFFVocê não pode alugar um bike deslogado, Crie uma Conta!", thePlayer, 255,255,255,true) return end
  if isElementWithinMarker(thePlayer, mrkpanel) then
    triggerClientEvent("OpenDxBike", thePlayer) -- Player pode ser definido antes, porém tem de ser definido também ( leia o syntax da function)
  end
end
addEventHandler("onMarkerHit", mrkpanel, AbrirPainelBike)

 

Link to comment
54 minutes ago, ~#BlackSCR said:

Server-side

 


mrkpanel = createMarker(1489.361, -1741.148, 13.547 -1,"cylinder",1.2,0,0,255,255)

function AbrirPainelBike(hitElement)
  local thePlayer = hitElement
  local account = getPlayerAccount (thePlayer)
  if isGuestAccount (account) then outputChatBox ( "#ff0000✘ #ffffffAGENCIA #ff0000✘➺ #FFFFFFVocê não pode alugar um bike deslogado, Crie uma Conta!", thePlayer, 255,255,255,true) return end
  if isElementWithinMarker(thePlayer, mrkpanel) then
    triggerClientEvent("OpenDxBike", thePlayer) -- Player pode ser definido antes, porém tem de ser definido também ( leia o syntax da function)
  end
end
addEventHandler("onMarkerHit", mrkpanel, AbrirPainelBike)

 

Desse jeito vai abrir o painel pra todos do server.

 

Teste assim:

local mrkpanel = createMarker(1489.361, -1741.148, 13.547 -1,"cylinder",1.2,0,0,255,255)

function AbrirPainelBike(hitElement)
	if getElementType (hitElement) == 'player' then
		local account = getPlayerAccount (hitElement)
  		if isGuestAccount (account) then outputChatBox ( "#ff0000✘ #ffffffAGENCIA #ff0000✘➺ #FFFFFFVocê não pode alugar um bike deslogado, Crie uma Conta!", thePlayer, 255,255,255,true) return end
   		 triggerClientEvent(hitElement, "OpenDxBike", hitElement)
  	end
end
addEventHandler("onMarkerHit", mrkpanel, AbrirPainelBike)

 

Link to comment

Sempre utilize resourceRoot no 3º argumento do addEventHandler quando for um evento customizado, se deixar como root qualquer script vai poder acessá-lo, podendo ocorrer problemas com scripts em conflito e perdendo desempenho no servidor.

Para corrigir seu problema basta alterar essas 2 linhas:

-- clientSide
addEventHandler("OpenDxBike", resourceRoot, Open)

-- serverSide
triggerClientEvent(thePlayer, "OpenDxBike", resourceRoot)

 

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