Jump to content

[Solved] blink dxDraw


iAxel

Recommended Posts

Hello everybody!

The question is rather blunt, but I can't decide...

How to make blink dxDraw?

  
local alpha = 0 
local atype = 'up' 
  
addEventHandler('onClientRender', root, function () 
    if (alpha >= 0 and atype == 'up') then 
        alpha = alpha + 5 
    elseif (alpha <= 200 and atype == 'down') then 
        alpha = alpha - 5 
    end 
    if (alpha == 0) then 
        atype = 'up' 
    elseif (alpha == 200) then 
        atype = 'down' 
    end 
    dxDrawRectangle(x, y, w, h, tocolor(150, 0, 0, alpha)) 
end) 
  

I already have the code, but I want to use only the alpha variable

  
if (alpha >= 0 and alpha ~= 200) then 
    alpha = alpha + 5 
elseif (alpha <= 200 and alpha ~= 1) then 
    alpha = alpha - 5 
end 
  

Just it does not work ...

Edited by Guest
Link to comment
local data = { 
    login = { 
        hover = false, 
        alphaMode = false, 
        alapAlpha = 190, 
        colors = { 255, 255, 255 } 
    } 
} 
  
function renderDx() --------- This is the hover 
      if data.login.hover then 
        data.login.colors = {201, 0, 20} 
        if not data.login.alphaMode then 
            data.login.alapAlpha = data.login.alapAlpha - 5 
            if data.login.alapAlpha <= 40 then 
                data.login.alphaMode = true 
            end 
        else 
            data.login.alapAlpha = data.login.alapAlpha + 5 
            if data.login.alapAlpha >= 190 then 
                data.login.alphaMode = false 
            end 
        end 
  
    end 
end 
addEventHandler("onClientRender", getRootElement(), renderDx) 
  
addEventHandler("onClientCursorMove", getRootElement(), function(_, _, x, y) 
        if x > X + 35 and x <  X + 195 then --- write your pos 
            if y > Y + 187 and y < Y + 214 then 
                data.login.hover = true 
            else 
                 
                data.login.hover = false 
                data.login.alapAlpha = 190 
                data.login.colors = { 255, 255, 255 } 
                data.login.alphaMode = false 
            end 
end) 
  
} 

And finally you have to display the dx like this:

dxDrawText("STH", X , Y, 0, 0, tocolor(data.login.colors[1], data.login.colors[2], data.login.colors[3], data.login.alapAlpha), 1, "arial", _, _, _, _, _, true) 

copied from my script

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