Jump to content

Por Painel de enviar Armas por ACL


Recommended Posts

E ai galera, blz?

 

Queria saber se vcs poderiam me ajudar a por esse script por ACL, só quem estiver na ACL puder abrir o painel, e quem n estiver e tentar apertar a Key configurada aparecer uma msg dizendo que ele não pode abrir tal.

eu tentei por editar um código, só que nada aconteceu...

 

codigo do client abaixo.

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


local dxfont0_icons = dxCreateFont("font/icons.ttf", x*12)
local dxfont1_icons = dxCreateFont("font/icons.ttf", x*11)
local ID = createElement("TS:EditBoxArmas")
local Preco = createElement("TS:EditBoxArmas")
local Municao = createElement("TS:EditBoxArmas")
painel = false
painel3 = false


--[[
         ><><><><><><><><><><><><><><><><><><><><
         ><          Painel Inicial            ><
         ><><><><><><><><><><><><><><><><><><><><
--]]

function painelsamu ()
        exports["Blur"]:dxDrawBluredRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.4323, tocolor(255, 255, 255, 230))	
        dxDrawRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.4323, tocolor(0, 0, 0, 77), false)
        dxDrawRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.0599, tocolor(0, 0, 0, 167), false)
        dxDrawLine(screenW * 0.2848, screenH * 0.3424, screenW * 0.7152, screenH * 0.3424, tocolor(5, 0, 217, 254), 3, false)
        dxDrawText("Enviar Armas", screenW * 0.4641, screenH * 0.2969, screenW * 0.5381, screenH * 0.3229, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
        dxDrawEditBox("ID Do Jogador", screenW * 0.5124, screenH * 0.3659, screenW * 0.1559, screenH * 0.0534, false, 10, ID)
        dxDrawEditBox("Preço da Arma", screenW * 0.5124, screenH * 0.4648, screenW * 0.1559, screenH * 0.0534, false, 10, Preco)
        dxDrawEditBox("Quantidade de Munição", screenW * 0.5124, screenH * 0.5534, screenW * 0.1559, screenH * 0.0534, false, 10, Municao)
        if isCursorOnElement(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625) then
        dxDrawImage(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 255), false)
        else
        dxDrawImage(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 123), false)
        end
        if isCursorOnElement(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625) then
        dxDrawImage(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 255), false)
        else
        dxDrawImage(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 123), false)
        end
        dxDrawText("Enviar Arma", screenW * 0.3763, screenH * 0.6471, screenW * 0.4502, screenH * 0.6732, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
        dxDrawText("Fechar Painel", screenW * 0.5234, screenH * 0.6484, screenW * 0.5974, screenH * 0.6745, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
          end



addEventHandler("onClientResourceStart", resourceRoot,
  function ()
    Lista_Armas = dxGridW:Create(408, 278, 254, 192)
    Lista_Armas:AddColumn("Armas", 150)
    Lista_Armas:AddColumn("Muniçao", 70)
    Lista_Armas:AddColumn("ID", 100)
    Lista_Armas:SetVisible(false) 
    
end)
  

function Refresh_Jogadores ()	
Lista_Armas:Clear(true)		
for slot = 0, 12 do
local Armamento = getPedWeapon ( localPlayer, slot )
local Municao = getPedTotalAmmo ( localPlayer, slot )
if Armamento > 0 then 
local NomeDaArma = getWeaponNameFromID ( Armamento )
Lista_Armas:AddItem(1, ""..NomeDaArma)
Lista_Armas:AddItem(2, ""..Municao)
Lista_Armas:AddItem(3, ""..Armamento)
end
end
end

function painelsamu2 ()
  local Jogador = getElementData(localPlayer, "TS:Vendedor") 
  local Preco = getElementData(Jogador, "TS:Preco") or "Error"
  local Municoes = getElementData(Jogador, "TS:Muni") or "Error"
  local IDArma = getElementData(Jogador, "TS:IDArma") or "Error"
  local NomeArma = getWeaponNameFromID(IDArma)
  dxDrawRectangle(screenW * 0.3426, screenH * 0.0130, screenW * 0.3155, screenH * 0.2578, tocolor(0, 0, 0, 123), false)
  dxDrawRectangle(screenW * 0.3426, screenH * 0.0130, screenW * 0.3155, screenH * 0.0560, tocolor(0, 0, 0, 162), false)
  dxDrawLine(screenW * 0.3426, screenH * 0.0690, screenW * 0.6589, screenH * 0.0690, tocolor(10, 0, 198, 254), 3, false)
  dxDrawText("Venda de Armas", screenW * 0.4605, screenH * 0.0260, screenW * 0.5527, screenH * 0.0560, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
  dxDrawText("Algum jogador está querendo te vender uma "..NomeArma.." por #00FF00R$#FFFFFF "..Preco.." \ncom "..Municoes.." Munições. Você deseja:", screenW * 0.3499, screenH * 0.0820, screenW * 0.4422, screenH * 0.1120, tocolor(255, 255, 255, 255), 1.00, dxfont1_icons, "left", "top", false, false, false, true, false)
  if isCursorOnElement(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
  dxDrawImage(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 255), false)
else
  dxDrawImage(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 126), false)
end
   if isCursorOnElement(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
  dxDrawImage(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 255), false)
   else
  dxDrawImage(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 126), false)
   end
  dxDrawText("Comprar", screenW * 0.3865, screenH * 0.1732, screenW * 0.4348, screenH * 0.2031, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
  dxDrawText("Rejeitar", screenW * 0.5410, screenH * 0.1732, screenW * 0.5893, screenH * 0.2031, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)

		end

--[[
         ><><><><><><><><><><><><><><><><><><><><
         ><      Configurações N Altere        ><
         ><><><><><><><><><><><><><><><><><><><><
--]]

function convertTime(ms) 
    local min = math.floor ( ms/60000 ) 
    local sec = math.floor( (ms/1000)%60 ) 
    return min, sec 
end

function AbrirArmas ()
if getElementData(localPlayer, "TS:Cliente") then return end
if painel == false then
  addEventHandler ( "onClientRender", root, painelsamu )
  painel = true
  showCursor ( true )
  playSoundFrontEnd ( 43 )
  setElementData(ID, "text2", "")
  setElementData(Preco, "text2", "")
  setElementData(Municao, "text2", "")
Lista_Armas:SetVisible(true)
  Refresh_Jogadores ()
end
end
bindKey("F5", "down", AbrirArmas)

function FecharPainel (_,state)
 if painel == true then
  if state == "down" then
   if isCursorOnElement ( screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625 ) then
    removeEventHandler("onClientRender", root, painelsamu )
    showCursor (false)
    playSoundFrontEnd ( 43 )
    painel = false
	Lista_Armas:SetVisible(false)
  end
  end
  end
 end
addEventHandler ("onClientClick", root, FecharPainel )

function VenderArmas (_,state)
 if painel == true then
   if isCursorOnElement ( screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625 ) then
   local getID = tonumber(getElementData(ID, "text2"))
  local getPreco = tonumber(getElementData(Preco, "text2")) or 0
  local getMunicao = tonumber(getElementData(Municao, "text2")) or 0
  local gridItem = Lista_Armas:GetSelectedItem()
  local Arma_Selecionada = Lista_Armas:GetItemDetails(1, gridItem, 1) or nil
  local MunicaoAtual = Lista_Armas:GetItemDetails(2, gridItem, 2) or nil
  local WeaponID = Lista_Armas:GetItemDetails(3, gridItem, 3) or nil
    removeEventHandler("onClientRender", root, painelsamu )
    showCursor (false)
    playSoundFrontEnd ( 43 )
    painel = false
  Lista_Armas:SetVisible(false)
  setElementData(localPlayer, "TS:IDArma", WeaponID)
  setElementData(localPlayer, "TS:MuniAtual", MunicaoAtual)
	triggerServerEvent( 'TS:IniciarVendaArmas', getLocalPlayer(), localPlayer, Arma_Selecionada, getID, getPreco, getMunicao, WeaponID)
  end
  end
 end
addEventHandler ("onClientClick", root, VenderArmas )

painelcomprador = false

function ConfirmacaoWeapon ()
addEventHandler("onClientRender", root, painelsamu2)
end
addEvent("TS:ConfirmacaoWeapon", true)
addEventHandler("TS:ConfirmacaoWeapon", getRootElement(), ConfirmacaoWeapon)


function ParteComprador (_,state)
   if state == "down" then
    if isCursorOnElement ( screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534 ) then
     removeEventHandler("onClientRender", root, painelsamu2 )
     triggerServerEvent("TS:Rejeitado", localPlayer)
    elseif isCursorOnElement(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
      removeEventHandler("onClientRender", root, painelsamu2 )
     triggerServerEvent("TS:AceitarWeapon", localPlayer)
   end
   end
  end
 addEventHandler ("onClientClick", root, ParteComprador )

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

 

Link to comment

Para você verificar o grupo ACL de um Jogador, você precisará fazer isso do lado server-side.

Então, você vai precisa muda basicamente, algumas coisinhas, como :

1. BindKey : remove do client-side, e enviar para o server-side (fazer alterações).

2. isObjectInACLGroup : verificar o grupo ACL do jogador.

3. triggerClientEvent : utilizar para dispara um evento para o client-side, para abrir o painel.

  • Sad 1
Link to comment

server

function AbrirArmas (thePlayer)
  accountname = getAccountName(getPlayerAccount(thePlayer))
  if isObjectInACLGroup("user." .. accountname, aclGetGroup("CHEFECF")) then ---So Mude  "Armas" Grupo que vai poder abrir o painel !
    triggerClientEvent(thePlayer, "painelsamu", getRootElement())
  end
end

function AbrirArmas ()
if getElementData(localPlayer, "TS:Cliente") then return end
if painel == false then
  addEventHandler ( "onClientRender", root, painelsamu )
  painel = true
  showCursor ( true )
  playSoundFrontEnd ( 43 )
  setElementData(ID, "text2", "")
  setElementData(Preco, "text2", "")
  setElementData(Municao, "text2", "")
Lista_Armas:SetVisible(true)
  Refresh_Jogadores ()
end
end
bindKey("F5", "down", AbrirArmas)

-------------------------------- Funções Iniciais

function IniciarVendaArmas (source, Arma_Selecionada, getID, getPreco, getMunicao, WeaponID)
local Jogador = getPlayerID(getID)
local Preco = tonumber(getPreco)
local Municao = tonumber(getMunicao)
local MunicaoAtual = getElementData(source, "TS:MuniAtual") or 0
if not Jogador then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffJogador não encontrado!") return end
if source == Jogador then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffVocê não pode vender arma para você mesmo!") return end
--if getElementData(Jogador, "TS:Vendedor") then triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffO jogador já esta em uma negociação!") return end
if tonumber(MunicaoAtual) < tonumber(getMunicao) then
triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffVocê não tem essa munição!")
else
local Posx, Posy, Poz = getElementPosition ( source )
local Posx1, Posy1, Pos1z = getElementPosition ( Jogador )
local Distancia = getDistanceBetweenPoints3D ( Posx, Posy, Poz, Posx1, Posy1, Pos1z  )
if Distancia > 3 then
triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffO jogador está muito longe!")
return end
setElementData(source, "TS:Cliente", Jogador)
setElementData(Jogador, "TS:Vendedor", source)
setElementData(source, "TS:Preco", getPreco)
setElementData(source, "TS:Muni", Municao)
setElementData(source, "TS:NomeArma", Arma_Selecionada)
triggerClientEvent(Jogador, "TS:ConfirmacaoWeapon", Jogador)
end
end
addEvent ("TS:IniciarVendaArmas", true)
addEventHandler ("TS:IniciarVendaArmas", root, IniciarVendaArmas)

function Rejeitado ()
local Vendedor = getElementData(source, "TS:Vendedor")
if Vendedor then
triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffO jogador recusou a negociação!")
triggerClientEvent(Vendedor, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffVocê rejeitou a negociação!")
setElementData(Vendedor, "TS:Cliente", nil)
setElementData(source, "TS:Vendedor", nil)
setElementData(Vendedor, "TS:Preco", nil)
setElementData(Vendedor, "TS:Muni", nil)
setElementData(Vendedor, "TS:IDArma", nil)
setElementData(Vendedor, "TS:NomeArma", nil)
end
end
addEvent ("TS:Rejeitado", true)
addEventHandler ("TS:Rejeitado", root, Rejeitado)

function AceitarWeapon ()
local Vendedor = getElementData(source, "TS:Vendedor")
if Vendedor then
local Preco = tonumber(getElementData(Vendedor, "TS:Preco")) or 0
local Municoes = getElementData(Vendedor, "TS:Muni") or 5
local IDArmaTS = tonumber(getElementData(Vendedor, "TS:IDArma")) or 0
local NomeArma = getElementData(Vendedor, "TS:NomeArma") or "Error"
local MunicaoAtual = getElementData(Vendedor, "TS:MuniAtual") or 0
local MunicaoTotalVendedor = MunicaoAtual - Municoes
if getPlayerMoney(source) < Preco then
triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffDinheiro Insuficiente!")
triggerClientEvent(Vendedor, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffO jogador não tem dinheiro suficiente!")
setElementData(Vendedor, "TS:Cliente", nil) 
setElementData(source, "TS:Vendedor", nil)
setElementData(Vendedor, "TS:Preco", nil)
setElementData(Vendedor, "TS:Muni", nil)
setElementData(Vendedor, "TS:IDArma", nil)
setElementData(Vendedor, "TS:NomeArma", nil)
return end
takePlayerMoney(source, Preco)
givePlayerMoney(Vendedor, Preco)
takeWeapon(Vendedor, IDArmaTS, Municoes)
giveWeapon(source, IDArmaTS, Municoes, true )
setElementData(Vendedor, "TS:Cliente", nil)
setElementData(source, "TS:Vendedor", nil)
setElementData(Vendedor, "TS:Preco", nil)
setElementData(Vendedor, "TS:Muni", nil)
setElementData(Vendedor, "TS:IDArma", nil)
setElementData(Vendedor, "TS:NomeArma", nil)
triggerClientEvent(Vendedor, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffO jogador aceitou a negociação !")
triggerClientEvent(source, "addNotification", root, "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffVocê aceitou a negociação!")
end
end
addEvent ("TS:AceitarWeapon", true)
addEventHandler ("TS:AceitarWeapon", root, AceitarWeapon)
--------- Não mecha

function getPlayerID(id)
v = false
for i, player in ipairs (getElementsByType("player")) do
if getElementData(player, "ID") == id then
v = player
break
end
end
return v
end

client

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


local dxfont0_icons = dxCreateFont("font/icons.ttf", x*12)
local dxfont1_icons = dxCreateFont("font/icons.ttf", x*11)
local ID = createElement("TS:EditBoxArmas")
local Preco = createElement("TS:EditBoxArmas")
local Municao = createElement("TS:EditBoxArmas")
painel = false
painel3 = false


--[[
         ><><><><><><><><><><><><><><><><><><><><
         ><          Painel Inicial            ><
         ><><><><><><><><><><><><><><><><><><><><
--]]

function painelsamu ()
        exports["Blur"]:dxDrawBluredRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.4323, tocolor(255, 255, 255, 230))	
        dxDrawRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.4323, tocolor(0, 0, 0, 77), false)
        dxDrawRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.0599, tocolor(0, 0, 0, 167), false)
        dxDrawLine(screenW * 0.2848, screenH * 0.3424, screenW * 0.7152, screenH * 0.3424, tocolor(5, 0, 217, 254), 3, false)
        dxDrawText("Enviar Armas", screenW * 0.4641, screenH * 0.2969, screenW * 0.5381, screenH * 0.3229, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
        dxDrawEditBox("ID Do Jogador", screenW * 0.5124, screenH * 0.3659, screenW * 0.1559, screenH * 0.0534, false, 10, ID)
        dxDrawEditBox("Preço da Arma", screenW * 0.5124, screenH * 0.4648, screenW * 0.1559, screenH * 0.0534, false, 10, Preco)
        dxDrawEditBox("Quantidade de Munição", screenW * 0.5124, screenH * 0.5534, screenW * 0.1559, screenH * 0.0534, false, 10, Municao)
        if isCursorOnElement(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625) then
        dxDrawImage(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 255), false)
        else
        dxDrawImage(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 123), false)
        end
        if isCursorOnElement(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625) then
        dxDrawImage(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 255), false)
        else
        dxDrawImage(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 123), false)
        end
        dxDrawText("Enviar Arma", screenW * 0.3763, screenH * 0.6471, screenW * 0.4502, screenH * 0.6732, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
        dxDrawText("Fechar Painel", screenW * 0.5234, screenH * 0.6484, screenW * 0.5974, screenH * 0.6745, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
          end



addEventHandler("onClientResourceStart", resourceRoot,
  function ()
    Lista_Armas = dxGridW:Create(408, 278, 254, 192)
    Lista_Armas:AddColumn("Armas", 150)
    Lista_Armas:AddColumn("Muniçao", 70)
    Lista_Armas:AddColumn("ID", 100)
    Lista_Armas:SetVisible(false) 
    
end)
  

function Refresh_Jogadores ()	
Lista_Armas:Clear(true)		
for slot = 0, 12 do
local Armamento = getPedWeapon ( localPlayer, slot )
local Municao = getPedTotalAmmo ( localPlayer, slot )
if Armamento > 0 then 
local NomeDaArma = getWeaponNameFromID ( Armamento )
Lista_Armas:AddItem(1, ""..NomeDaArma)
Lista_Armas:AddItem(2, ""..Municao)
Lista_Armas:AddItem(3, ""..Armamento)
end
end
end

function painelsamu2 ()
  local Jogador = getElementData(localPlayer, "TS:Vendedor") 
  local Preco = getElementData(Jogador, "TS:Preco") or "Error"
  local Municoes = getElementData(Jogador, "TS:Muni") or "Error"
  local IDArma = getElementData(Jogador, "TS:IDArma") or "Error"
  local NomeArma = getWeaponNameFromID(IDArma)
  dxDrawRectangle(screenW * 0.3426, screenH * 0.0130, screenW * 0.3155, screenH * 0.2578, tocolor(0, 0, 0, 123), false)
  dxDrawRectangle(screenW * 0.3426, screenH * 0.0130, screenW * 0.3155, screenH * 0.0560, tocolor(0, 0, 0, 162), false)
  dxDrawLine(screenW * 0.3426, screenH * 0.0690, screenW * 0.6589, screenH * 0.0690, tocolor(10, 0, 198, 254), 3, false)
  dxDrawText("Venda de Armas", screenW * 0.4605, screenH * 0.0260, screenW * 0.5527, screenH * 0.0560, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
  dxDrawText("Algum jogador está querendo te vender uma "..NomeArma.." por #00FF00R$#FFFFFF "..Preco.." \ncom "..Municoes.." Munições. Você deseja:", screenW * 0.3499, screenH * 0.0820, screenW * 0.4422, screenH * 0.1120, tocolor(255, 255, 255, 255), 1.00, dxfont1_icons, "left", "top", false, false, false, true, false)
  if isCursorOnElement(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
  dxDrawImage(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 255), false)
else
  dxDrawImage(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 126), false)
end
   if isCursorOnElement(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
  dxDrawImage(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 255), false)
   else
  dxDrawImage(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 126), false)
   end
  dxDrawText("Comprar", screenW * 0.3865, screenH * 0.1732, screenW * 0.4348, screenH * 0.2031, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
  dxDrawText("Rejeitar", screenW * 0.5410, screenH * 0.1732, screenW * 0.5893, screenH * 0.2031, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)

		end

--[[
         ><><><><><><><><><><><><><><><><><><><><
         ><      Configurações N Altere        ><
         ><><><><><><><><><><><><><><><><><><><><
--]]

function convertTime(ms) 
    local min = math.floor ( ms/60000 ) 
    local sec = math.floor( (ms/1000)%60 ) 
    return min, sec 
end

function FecharPainel (_,state)
 if painel == true then
  if state == "down" then
   if isCursorOnElement ( screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625 ) then
    removeEventHandler("onClientRender", root, painelsamu )
    showCursor (false)
    playSoundFrontEnd ( 43 )
    painel = false
	Lista_Armas:SetVisible(false)
  end
  end
  end
 end
addEventHandler ("onClientClick", root, FecharPainel )

function VenderArmas (_,state)
 if painel == true then
   if isCursorOnElement ( screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625 ) then
   local getID = tonumber(getElementData(ID, "text2"))
  local getPreco = tonumber(getElementData(Preco, "text2")) or 0
  local getMunicao = tonumber(getElementData(Municao, "text2")) or 0
  local gridItem = Lista_Armas:GetSelectedItem()
  local Arma_Selecionada = Lista_Armas:GetItemDetails(1, gridItem, 1) or nil
  local MunicaoAtual = Lista_Armas:GetItemDetails(2, gridItem, 2) or nil
  local WeaponID = Lista_Armas:GetItemDetails(3, gridItem, 3) or nil
    removeEventHandler("onClientRender", root, painelsamu )
    showCursor (false)
    playSoundFrontEnd ( 43 )
    painel = false
  Lista_Armas:SetVisible(false)
  setElementData(localPlayer, "TS:IDArma", WeaponID)
  setElementData(localPlayer, "TS:MuniAtual", MunicaoAtual)
	triggerServerEvent( 'TS:IniciarVendaArmas', getLocalPlayer(), localPlayer, Arma_Selecionada, getID, getPreco, getMunicao, WeaponID)
  end
  end
 end
addEventHandler ("onClientClick", root, VenderArmas )

painelcomprador = false

function ConfirmacaoWeapon ()
addEventHandler("onClientRender", root, painelsamu2)
end
addEvent("TS:ConfirmacaoWeapon", true)
addEventHandler("TS:ConfirmacaoWeapon", getRootElement(), ConfirmacaoWeapon)


function ParteComprador (_,state)
   if state == "down" then
    if isCursorOnElement ( screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534 ) then
     removeEventHandler("onClientRender", root, painelsamu2 )
     triggerServerEvent("TS:Rejeitado", localPlayer)
    elseif isCursorOnElement(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
      removeEventHandler("onClientRender", root, painelsamu2 )
     triggerServerEvent("TS:AceitarWeapon", localPlayer)
   end
   end
  end
 addEventHandler ("onClientClick", root, ParteComprador )

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

 

Sou muito leigo no assunto, desculpa kkk

poderia ajudar?

Edited by Mec.Love
Link to comment

Tente isso :

-- Server-Side 

addEventHandler("onPlayerLogin", getRootElement( ), function ( )
   bindKey( source, "F5", "down", abrir_painel_f5 ) 
end)

addEventHandler("onResourceStart", resourceRoot, function ( )
   for i, player in ipairs(getElementsByType("player")) do
      bindKey( player, "F5", "down", abrir_painel_f5 ) 
   end
end)

addEventHandler("onResourceStop", resourceRoot, function ( )
   for i, player in ipairs(getElementsByType("player")) do
      unbindKey( player, "F5", "down", abrir_painel_f5 ) 
   end
end)

function abrir_painel_f5 ( thePlayer )
   local accountname = getAccountName( getPlayerAccount ( thePlayer ) )
   if isObjectInACLGroup("user." .. accountname, aclGetGroup("Armas")) then
      triggerClientEvent( thePlayer, "Painel_de_Armas:Abrir", thePlayer)
   end
end
-- Client-Side 

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


local dxfont0_icons = dxCreateFont("font/icons.ttf", x*12)
local dxfont1_icons = dxCreateFont("font/icons.ttf", x*11)
local ID = createElement("TS:EditBoxArmas")
local Preco = createElement("TS:EditBoxArmas")
local Municao = createElement("TS:EditBoxArmas")
painel = false
painel3 = false


--[[
         ><><><><><><><><><><><><><><><><><><><><
         ><          Painel Inicial            ><
         ><><><><><><><><><><><><><><><><><><><><
--]]

function painelsamu ()
        exports["Blur"]:dxDrawBluredRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.4323, tocolor(255, 255, 255, 230))	
        dxDrawRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.4323, tocolor(0, 0, 0, 77), false)
        dxDrawRectangle(screenW * 0.2848, screenH * 0.2839, screenW * 0.4305, screenH * 0.0599, tocolor(0, 0, 0, 167), false)
        dxDrawLine(screenW * 0.2848, screenH * 0.3424, screenW * 0.7152, screenH * 0.3424, tocolor(5, 0, 217, 254), 3, false)
        dxDrawText("Enviar Armas", screenW * 0.4641, screenH * 0.2969, screenW * 0.5381, screenH * 0.3229, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
        dxDrawEditBox("ID Do Jogador", screenW * 0.5124, screenH * 0.3659, screenW * 0.1559, screenH * 0.0534, false, 10, ID)
        dxDrawEditBox("Preço da Arma", screenW * 0.5124, screenH * 0.4648, screenW * 0.1559, screenH * 0.0534, false, 10, Preco)
        dxDrawEditBox("Quantidade de Munição", screenW * 0.5124, screenH * 0.5534, screenW * 0.1559, screenH * 0.0534, false, 10, Municao)
        if isCursorOnElement(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625) then
        dxDrawImage(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 255), false)
        else
        dxDrawImage(screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 123), false)
        end
        if isCursorOnElement(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625) then
        dxDrawImage(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 255), false)
        else
        dxDrawImage(screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625, "0.png", 0, 0, 0, tocolor(5, 0, 217, 123), false)
        end
        dxDrawText("Enviar Arma", screenW * 0.3763, screenH * 0.6471, screenW * 0.4502, screenH * 0.6732, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
        dxDrawText("Fechar Painel", screenW * 0.5234, screenH * 0.6484, screenW * 0.5974, screenH * 0.6745, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
          end



addEventHandler("onClientResourceStart", resourceRoot,
  function ()
    Lista_Armas = dxGridW:Create(408, 278, 254, 192)
    Lista_Armas:AddColumn("Armas", 150)
    Lista_Armas:AddColumn("Muniçao", 70)
    Lista_Armas:AddColumn("ID", 100)
    Lista_Armas:SetVisible(false) 
    
end)
  

function Refresh_Jogadores ()	
Lista_Armas:Clear(true)		
for slot = 0, 12 do
local Armamento = getPedWeapon ( localPlayer, slot )
local Municao = getPedTotalAmmo ( localPlayer, slot )
if Armamento > 0 then 
local NomeDaArma = getWeaponNameFromID ( Armamento )
Lista_Armas:AddItem(1, ""..NomeDaArma)
Lista_Armas:AddItem(2, ""..Municao)
Lista_Armas:AddItem(3, ""..Armamento)
end
end
end

function painelsamu2 ()
  local Jogador = getElementData(localPlayer, "TS:Vendedor") 
  local Preco = getElementData(Jogador, "TS:Preco") or "Error"
  local Municoes = getElementData(Jogador, "TS:Muni") or "Error"
  local IDArma = getElementData(Jogador, "TS:IDArma") or "Error"
  local NomeArma = getWeaponNameFromID(IDArma)
  dxDrawRectangle(screenW * 0.3426, screenH * 0.0130, screenW * 0.3155, screenH * 0.2578, tocolor(0, 0, 0, 123), false)
  dxDrawRectangle(screenW * 0.3426, screenH * 0.0130, screenW * 0.3155, screenH * 0.0560, tocolor(0, 0, 0, 162), false)
  dxDrawLine(screenW * 0.3426, screenH * 0.0690, screenW * 0.6589, screenH * 0.0690, tocolor(10, 0, 198, 254), 3, false)
  dxDrawText("Venda de Armas", screenW * 0.4605, screenH * 0.0260, screenW * 0.5527, screenH * 0.0560, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
  dxDrawText("Algum jogador está querendo te vender uma "..NomeArma.." por #00FF00R$#FFFFFF "..Preco.." \ncom "..Municoes.." Munições. Você deseja:", screenW * 0.3499, screenH * 0.0820, screenW * 0.4422, screenH * 0.1120, tocolor(255, 255, 255, 255), 1.00, dxfont1_icons, "left", "top", false, false, false, true, false)
  if isCursorOnElement(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
  dxDrawImage(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 255), false)
else
  dxDrawImage(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 126), false)
end
   if isCursorOnElement(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
  dxDrawImage(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 255), false)
   else
  dxDrawImage(screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534, "0.png", 0, 0, 0, tocolor(10, 0, 198, 126), false)
   end
  dxDrawText("Comprar", screenW * 0.3865, screenH * 0.1732, screenW * 0.4348, screenH * 0.2031, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)
  dxDrawText("Rejeitar", screenW * 0.5410, screenH * 0.1732, screenW * 0.5893, screenH * 0.2031, tocolor(255, 255, 255, 255), 1.00, dxfont0_icons, "left", "top", false, false, false, false, false)

		end

--[[
         ><><><><><><><><><><><><><><><><><><><><
         ><      Configurações N Altere        ><
         ><><><><><><><><><><><><><><><><><><><><
--]]

function convertTime(ms) 
    local min = math.floor ( ms/60000 ) 
    local sec = math.floor( (ms/1000)%60 ) 
    return min, sec 
end

-- /> APENAS FIZ ALTERAÇÃO AQUI :
addEvent("Painel_de_Armas:Abrir", true)
function AbrirArmas ( )
   if getElementData(localPlayer, "TS:Cliente") then return end
   if painel == false then
      addEventHandler ( "onClientRender", root, painelsamu )
      painel = true
      showCursor ( true )
      playSoundFrontEnd ( 43 )
      setElementData(ID, "text2", "")
      setElementData(Preco, "text2", "")
      setElementData(Municao, "text2", "")
      Lista_Armas:SetVisible(true)
      Refresh_Jogadores ( )
   end
end
addEventHandler("Painel_de_Armas:Abrir", getRootElement(), AbrirArmas )
--bindKey("F5", "down", AbrirArmas) --/> Removido

function FecharPainel (_,state)
 if painel == true then
  if state == "down" then
   if isCursorOnElement ( screenW * 0.5015, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625 ) then
    removeEventHandler("onClientRender", root, painelsamu )
    showCursor (false)
    playSoundFrontEnd ( 43 )
    painel = false
	Lista_Armas:SetVisible(false)
  end
  end
  end
 end
addEventHandler ("onClientClick", root, FecharPainel )

function VenderArmas (_,state)
 if painel == true then
   if isCursorOnElement ( screenW * 0.3507, screenH * 0.6328, screenW * 0.1127, screenH * 0.0625 ) then
   local getID = tonumber(getElementData(ID, "text2"))
  local getPreco = tonumber(getElementData(Preco, "text2")) or 0
  local getMunicao = tonumber(getElementData(Municao, "text2")) or 0
  local gridItem = Lista_Armas:GetSelectedItem()
  local Arma_Selecionada = Lista_Armas:GetItemDetails(1, gridItem, 1) or nil
  local MunicaoAtual = Lista_Armas:GetItemDetails(2, gridItem, 2) or nil
  local WeaponID = Lista_Armas:GetItemDetails(3, gridItem, 3) or nil
    removeEventHandler("onClientRender", root, painelsamu )
    showCursor (false)
    playSoundFrontEnd ( 43 )
    painel = false
  Lista_Armas:SetVisible(false)
  setElementData(localPlayer, "TS:IDArma", WeaponID)
  setElementData(localPlayer, "TS:MuniAtual", MunicaoAtual)
	triggerServerEvent( 'TS:IniciarVendaArmas', getLocalPlayer(), localPlayer, Arma_Selecionada, getID, getPreco, getMunicao, WeaponID)
  end
  end
 end
addEventHandler ("onClientClick", root, VenderArmas )

painelcomprador = false

function ConfirmacaoWeapon ()
addEventHandler("onClientRender", root, painelsamu2)
end
addEvent("TS:ConfirmacaoWeapon", true)
addEventHandler("TS:ConfirmacaoWeapon", getRootElement(), ConfirmacaoWeapon)


function ParteComprador (_,state)
   if state == "down" then
    if isCursorOnElement ( screenW * 0.5110, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534 ) then
     removeEventHandler("onClientRender", root, painelsamu2 )
     triggerServerEvent("TS:Rejeitado", localPlayer)
    elseif isCursorOnElement(screenW * 0.3572, screenH * 0.1628, screenW * 0.1061, screenH * 0.0534) then
      removeEventHandler("onClientRender", root, painelsamu2 )
     triggerServerEvent("TS:AceitarWeapon", localPlayer)
   end
   end
  end
 addEventHandler ("onClientClick", root, ParteComprador )

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

 

Edited by Angelo Pereira
  • Thanks 2
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...