Jump to content

marker with open DX panel function


Recommended Posts

 

Estou tentando fazer um painel quando o player entrar no marcador abrir um painel com a função de pegar M4, Desert Eagle, Shotgun, MP5, colete salva vidas (salva vidas junto com colete) separadamente para uma corporação, mas estou tendo dificuldade em fazer a ação para pegar a arma (colete salva-vidas/colete), pois acho que essa função deveria ser feita do lado do servidor, mas não sei como fazer isso.

-- Client
local screenW, screenH = guiGetScreenSize()

local bopeP = false

function PainelDX()
   
        dxDrawLine((screenW * 0.2703) - 1, (screenH * 0.2597) - 1, (screenW * 0.2703) - 1, screenH * 0.4125, tocolor(205, 0, 0, 255), 1, false)
        dxDrawLine(screenW * 0.3969, (screenH * 0.2597) - 1, (screenW * 0.2703) - 1, (screenH * 0.2597) - 1, tocolor(205, 0, 0, 255), 1, false)
        dxDrawLine((screenW * 0.2703) - 1, screenH * 0.4125, screenW * 0.3969, screenH * 0.4125, tocolor(205, 0, 0, 255), 1, false)
        dxDrawLine(screenW * 0.3969, screenH * 0.4125, screenW * 0.3969, (screenH * 0.2597) - 1, tocolor(205, 0, 0, 255), 1, false)
        
        dxDrawRectangle(screenW * 0.2703, screenH * 0.2597, screenW * 0.1266, screenH * 0.1528, tocolor(0, 0, 0, 164), false)
        
        dxDrawLine((screenW * 0.4125) - 1, (screenH * 0.2597) - 1, (screenW * 0.4125) - 1, screenH * 0.4125, tocolor(254, 1, 1, 164), 1, false)
        dxDrawLine(screenW * 0.5391, (screenH * 0.2597) - 1, (screenW * 0.4125) - 1, (screenH * 0.2597) - 1, tocolor(254, 1, 1, 164), 1, false)
        dxDrawLine((screenW * 0.4125) - 1, screenH * 0.4125, screenW * 0.5391, screenH * 0.4125, tocolor(254, 1, 1, 164), 1, false)
        dxDrawLine(screenW * 0.5391, screenH * 0.4125, screenW * 0.5391, (screenH * 0.2597) - 1, tocolor(254, 1, 1, 164), 1, false)
       
        dxDrawRectangle(screenW * 0.4125, screenH * 0.2597, screenW * 0.1266, screenH * 0.1528, tocolor(0, 0, 0, 164), false)
        
        dxDrawLine((screenW * 0.5539) - 1, (screenH * 0.2597) - 1, (screenW * 0.5539) - 1, screenH * 0.4125, tocolor(254, 1, 1, 164), 1, false)
        dxDrawLine(screenW * 0.6805, (screenH * 0.2597) - 1, (screenW * 0.5539) - 1, (screenH * 0.2597) - 1, tocolor(254, 1, 1, 164), 1, false)
        dxDrawLine((screenW * 0.5539) - 1, screenH * 0.4125, screenW * 0.6805, screenH * 0.4125, tocolor(254, 1, 1, 164), 1, false)
        dxDrawLine(screenW * 0.6805, screenH * 0.4125, screenW * 0.6805, (screenH * 0.2597) - 1, tocolor(254, 1, 1, 164), 1, false)
       
        dxDrawRectangle(screenW * 0.5539, screenH * 0.2597, screenW * 0.1266, screenH * 0.1528, tocolor(0, 0, 0, 164), false)
        
        dxDrawLine((screenW * 0.5539) - 1, (screenH * 0.4389) - 1, (screenW * 0.5539) - 1, screenH * 0.5917, tocolor(254, 0, 0, 164), 1, false)
        dxDrawLine(screenW * 0.6805, (screenH * 0.4389) - 1, (screenW * 0.5539) - 1, (screenH * 0.4389) - 1, tocolor(254, 0, 0, 164), 1, false)
        dxDrawLine((screenW * 0.5539) - 1, screenH * 0.5917, screenW * 0.6805, screenH * 0.5917, tocolor(254, 0, 0, 164), 1, false)
        dxDrawLine(screenW * 0.6805, screenH * 0.5917, screenW * 0.6805, (screenH * 0.4389) - 1, tocolor(254, 0, 0, 164), 1, false)
      
        dxDrawRectangle(screenW * 0.5539, screenH * 0.4389, screenW * 0.1266, screenH * 0.1528, tocolor(0, 0, 0, 164), false)
        
        dxDrawLine((screenW * 0.4125) - 1, (screenH * 0.4389) - 1, (screenW * 0.4125) - 1, screenH * 0.5917, tocolor(253, 0, 0, 164), 1, false)
        dxDrawLine(screenW * 0.5391, (screenH * 0.4389) - 1, (screenW * 0.4125) - 1, (screenH * 0.4389) - 1, tocolor(253, 0, 0, 164), 1, false)
        dxDrawLine((screenW * 0.4125) - 1, screenH * 0.5917, screenW * 0.5391, screenH * 0.5917, tocolor(253, 0, 0, 164), 1, false)
        dxDrawLine(screenW * 0.5391, screenH * 0.5917, screenW * 0.5391, (screenH * 0.4389) - 1, tocolor(253, 0, 0, 164), 1, false)
        
        dxDrawRectangle(screenW * 0.4125, screenH * 0.4389, screenW * 0.1266, screenH * 0.1528, tocolor(0, 0, 0, 164), false)
        
        dxDrawLine((screenW * 0.2703) - 1, (screenH * 0.4389) - 1, (screenW * 0.2703) - 1, screenH * 0.5917, tocolor(253, 0, 0, 164), 1, false)
        dxDrawLine(screenW * 0.3969, (screenH * 0.4389) - 1, (screenW * 0.2703) - 1, (screenH * 0.4389) - 1, tocolor(253, 0, 0, 164), 1, false)
        dxDrawLine((screenW * 0.2703) - 1, screenH * 0.5917, screenW * 0.3969, screenH * 0.5917, tocolor(253, 0, 0, 164), 1, false)
        dxDrawLine(screenW * 0.3969, screenH * 0.5917, screenW * 0.3969, (screenH * 0.4389) - 1, tocolor(253, 0, 0, 164), 1, false)
        
        dxDrawRectangle(screenW * 0.2703, screenH * 0.4389, screenW * 0.1266, screenH * 0.1528, tocolor(0, 0, 0, 164), false)
        
        dxDrawText("PARAFAL", screenW * 0.2742, screenH * 0.2722, screenW * 0.3922, screenH * 0.3986, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("SHOTGUN", 533, 196, 684, 287, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("MP5", screenW * 0.5586, screenH * 0.2722, screenW * 0.6766, screenH * 0.3986, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("VIDA/COLETE", screenW * 0.5578, screenH * 0.4514, screenW * 0.6758, screenH * 0.5778, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("TASER", screenW * 0.4164, screenH * 0.4514, screenW * 0.5344, screenH * 0.5778, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("DESERT EAGLE", screenW * 0.2742, screenH * 0.4514, screenW * 0.3922, screenH * 0.5778, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawLine((screenW * 0.2625) - 1, (screenH * 0.2444) - 1, (screenW * 0.2625) - 1, screenH * 0.6847, tocolor(181, 0, 0, 251), 1, false)
        dxDrawLine(screenW * 0.6891, (screenH * 0.2444) - 1, (screenW * 0.2625) - 1, (screenH * 0.2444) - 1, tocolor(181, 0, 0, 251), 1, false)
        dxDrawLine((screenW * 0.2625) - 1, screenH * 0.6847, screenW * 0.6891, screenH * 0.6847, tocolor(181, 0, 0, 251), 1, false)
        dxDrawLine(screenW * 0.6891, screenH * 0.6847, screenW * 0.6891, (screenH * 0.2444) - 1, tocolor(181, 0, 0, 251), 1, false)
        dxDrawRectangle(screenW * 0.2625, screenH * 0.2444, screenW * 0.4266, screenH * 0.4403, tocolor(0, 0, 0, 53), false)
        dxDrawText("by:JohnReiDelas", screenW * 0.6156, screenH * 0.6347, screenW * 0.6836, screenH * 0.6847, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("BAC-B.O.P.E", 533, 436, 689, 483, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
    end

addEvent("openPainel", true)
addEventHandler("openPainel", root, function()
  if bopeP == false then
    addEventHandler("onClientRender", getRootElement(), PainelDX)
     bopeP = true
  else
    removeEventHandler("onClientRender", getRootElement(), PainelDX)
     bopeP = false
  end
end)

bindKey("backspace", "down", function()
if bopeP == true then
    removeEventHandler("onClientRender", getRootElement(), PainelDX)
    bopeP = false
 end
end)

function isMouseInPosition ( x, y, width, height )
        if ( not isCursorShowing( ) ) then
            return false
        end
        local sx, sy = guiGetScreenSize ( )
        local cx, cy = getCursorPosition ( )
        local cx, cy = ( cx * sx ), ( cy * sy )
        
        return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
    end
    
   function isCursorOverText(posX, posY, sizeX, sizeY)
        if ( not isCursorShowing( ) ) then
            return false
        end
        local cX, cY = getCursorPosition()
        local screenWidth, screenHeight = guiGetScreenSize()
        local cX, cY = (cX*screenWidth), (cY*screenHeight)
    
        return ( (cX >= posX and cX <= posX+(sizeX - posX)) and (cY >= posY and cY <= posY+(sizeY - posY)) )
    end

    addEventHandler("onClientClick", getRootElement(), function(button, state)
    if button =="left" and state =="down" then
        if bopeP == true then
            if isMouseInPosition(screenW * 0.2703, screenH * 0.2597, screenW * 0.1266, screenH * 0.1528) then
                setWeaponAmmo(thePlayer, 31, 999)
            end
        end
    end            
end)

 

---server-side
local marker = createMarker(-1173.259, -1047.72, 135 -1, "cylinder", 1.5, 16, 111, 231, 99)

addEventHandler("onMarkerHit", marker, function(hit)
if getElementType(hit) == "player" then
triggerClientEvent(hit,"openPainel", hit)
end
end)

 

Edited by Lord Henry
Texto desbugado.
Link to comment
  • Other Languages Moderators

Sim, dar armas, setar vida/colete é tudo feito no lado servidor. Você vai precisar de triggers para fazer o painel ativar um evento no lado servidor.

No seu código client-side, no lugar disso:

setWeaponAmmo(thePlayer, 31, 999)

Coloque isso:

triggerServerEvent("bopepainel", resourceRoot, "armas")

E então no seu código server-side, adicione isso:

addEvent("bopepainel", true)
addEventHandler("bopepainel", resourceRoot, function(tipo)
    if tipo == "armas" then
        giveWeapon (client, 31, 999, true) -- client = localPlayer que ativou este evento.
        giveWeapon (client, 24, 999)
        giveWeapon (client, 25, 999)
        giveWeapon (client, 29, 999)
    -- elseif tipo == "vidacolete" then -- Ative isso depois que criar o botão de vida/colete e configurar o trigger dele.
        -- setElementHealth (client, 100)
        -- setPedArmor (client, 100)
    end
end)

 

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