Jump to content

Painel Abrindo para todos os jogadores


Recommended Posts

sempre que alguem abre o painel ele abre para todos os jogadores

Serverside

 

Arsenal = createMarker(1950.0999755859,-1444.0446777344,13.538549423218 -1, "cylinder", 1.5, 255, 10, 10, 144)

function AbrirPainel(player) --Abrir
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Policial")) then
    if isElementWithinMarker(player,Arsenal) then
        triggerClientEvent ("OpenPanel", getRootElement())
    end
end
end

addCommandHandler("painel", AbrirPainel)

 

clientside

 

local exibindo_painel = false
function ArsenalP()
    dxDrawRectangle(430, 300, 266, 215, tocolor(127, 127, 127, 100), false)

    dxDrawRectangle(436, 310, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 351, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 392, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 433, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 474, 250, 31, tocolor(0, 0, 0, 179), false)

    dxDrawText("M4A1", 532, 310, 590, 341, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Glock", 532, 351, 590, 382, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Sniper", 532, 392, 590, 423, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Taser", 532, 433, 590, 464, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Colete", 532, 474, 590, 505, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
end

--Abrir

function OpenP()
    if exibindo_painel == false then
        addEventHandler("onClientRender", getRootElement(), ArsenalP)
        exibindo_painel = true
        showCursor(true)
    else
        removeEventHandler("onClientRender", getRootElement(), ArsenalP)
        exibindo_painel = false
        showCursor(false)
    end
end

addEvent( "OpenPanel", true )
addEventHandler( "OpenPanel", localPlayer, OpenP )

Link to comment
On 23/10/2021 at 09:57, MTS_LoneWolf said:

sempre que alguem abre o painel ele abre para todos os jogadores

Serverside

 

Arsenal = createMarker(1950.0999755859,-1444.0446777344,13.538549423218 -1, "cylinder", 1.5, 255, 10, 10, 144)

function AbrirPainel(player) --Abrir
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Policial")) then
    if isElementWithinMarker(player,Arsenal) then
        triggerClientEvent ("OpenPanel", getRootElement())
    end
end
end

addCommandHandler("painel", AbrirPainel)

 

clientside

 

local exibindo_painel = false
function ArsenalP()
    dxDrawRectangle(430, 300, 266, 215, tocolor(127, 127, 127, 100), false)

    dxDrawRectangle(436, 310, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 351, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 392, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 433, 250, 31, tocolor(0, 0, 0, 179), false)
    dxDrawRectangle(436, 474, 250, 31, tocolor(0, 0, 0, 179), false)

    dxDrawText("M4A1", 532, 310, 590, 341, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Glock", 532, 351, 590, 382, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Sniper", 532, 392, 590, 423, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Taser", 532, 433, 590, 464, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
    dxDrawText("Colete", 532, 474, 590, 505, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, false, false, false)
end

--Abrir

function OpenP()
    if exibindo_painel == false then
        addEventHandler("onClientRender", getRootElement(), ArsenalP)
        exibindo_painel = true
        showCursor(true)
    else
        removeEventHandler("onClientRender", getRootElement(), ArsenalP)
        exibindo_painel = false
        showCursor(false)
    end
end

addEvent( "OpenPanel", true )
addEventHandler( "OpenPanel", localPlayer, OpenP )

Olá, boa tarde! Primeiramente, sempre que adicionar um código no fórum, use o botão <code> para facilitar a visualização.

O triggerClientEvent tem como 1° argumento opcional o client que você deseja acionar o evento. No caso, como você não definiu um destinatário, por padrão vai para todos os players (root).

Para corrigir, mude de:

 triggerClientEvent ("OpenPanel", getRootElement())

Para:

triggerClientEvent (player, "OpenPanel", getRootElement())

Leia mais na página da wiki triggerClientEvent

  • Thanks 1
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...