Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-02-29, 13:04


Kacperiusz

.






Wiek: 24
Na forum: 2911 dni
Posty: 113

Piwa: 206

Respekt: 50

Witam.
Robi? skrypt na panel zmiany kolor?w aut w gui.
Problem polega na tym ?e nie wiem jak zrobi? by po drugim klikni?ciu przycisku "F3" gui znika?o.

Kod:

local sw, sh = guiGetScreenSize() 
local zoom = 1920/sw

marker = createMarker(-2455.00879, -424.13968, 84.04877-1, "cylinder", 1, 255, 0, 0)

local t = dxCreateTexture("tlo.png")
local t2 = dxCreateTexture("pasek.png")

function mysz ( 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 gui()
    dxDrawImage(sw/2-1540/zoom, sh/2-800/zoom, 1920/zoom, 1080/zoom, t)
    dxDrawImage(sw/2-1540/zoom, sh/2-745/zoom, 1920/zoom, 1080/zoom, t2, 0, 0, 0, tocolor(255, 0, 0))
    dxDrawText("Kup czerwone", 310/zoom, 260/zoom, 83/zoom, 236/zoom, tocolor(255, 255, 255), 2)

    
    --dxDrawImage(sw/2-400/zoom, sh/2-600/zoom, 1920/zoom, 1080/zoom, t2)
end

function myszka()
    showCursor(true)
end

function wywolaj()
    addEventHandler("onClientRender", root, gui)
    bindKey("F3", "down", myszka)
end
addEventHandler("onClientMarkerHit", marker, wywolaj)

addEventHandler("onClientClick", root, function(btn, state)
    local veh = getPedOccupiedVehicle(localPlayer)
        if veh then 
            if btn == "left" and state == "down" then
            if mysz(sw/2-1540/zoom, sh/2-800/zoom, 1920/zoom, 1080/zoom)then 
            setVehicleColor(veh, 255, 0, 0)
            end
        end 
    end 
end) 


Prosz? o pomoc. Daje :piwo:


Podpis
pecik
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-29, 15:00


NotPaladyn







Wiek: 23
Na forum: 2931 dni
Posty: 866
Nick w MP: NotPaladyn

Piwa: 3150

Respekt: 690
Respekt: 690Respekt: 690


   Vice Admin: Jeśli potrzebujesz pomocy w sprawach organizacyjnych lub technicznych - skontaktuj się ze mną.
Spr?buj tak, nietestowane jak b?d? problemy to pisz


local sw, sh = guiGetScreenSize() 
local zoom = 1920/sw

marker = createMarker(-2455.00879, -424.13968, 84.04877-1, "cylinder", 1, 255, 0, 0)

local t = dxCreateTexture("tlo.png")
local t2 = dxCreateTexture("pasek.png")

function mysz ( 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 isEventHandlerAdded( sEventName, pElementAttachedTo, func )
     if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then
          local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
          if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
               for i, v in ipairs( aAttachedFunctions ) do
                    if v == func then
                     return true
                end
           end
      end
     end
     return false
end



function gui()
    dxDrawImage(sw/2-1540/zoom, sh/2-800/zoom, 1920/zoom, 1080/zoom, t)
    dxDrawImage(sw/2-1540/zoom, sh/2-745/zoom, 1920/zoom, 1080/zoom, t2, 0, 0, 0, tocolor(255, 0, 0))
    dxDrawText("Kup czerwone", 310/zoom, 260/zoom, 83/zoom, 236/zoom, tocolor(255, 255, 255), 2)

    
    --dxDrawImage(sw/2-400/zoom, sh/2-600/zoom, 1920/zoom, 1080/zoom, t2)
end


bindKey("F3", "down", function()
if isElementWithinMarker(localPlayer, marker) and not isEventHandlerAdded("onClientRender", root, gui) then
addEventHandler("onClientRender", root, gui)
showCursor(true)
else
removeEventHandler("onClientRender", root, gui)
showCursor(false)
end
end)


addEventHandler("onClientClick", root, function(btn, state)
    local veh = getPedOccupiedVehicle(localPlayer)
        if veh then 
            if btn == "left" and state == "down" then
            if mysz(sw/2-1540/zoom, sh/2-800/zoom, 1920/zoom, 1080/zoom)then 
            setVehicleColor(veh, 255, 0, 0)
            end
        end 
    end 
end)  


Postaw piwo autorowi tego posta
 

 
Tagi: bindkey.
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku