Jump to content

How to make dxText to flash?


Adde

Recommended Posts

Hello, I´m woundering how I can get a dxText to flash. Like change the alpha from 0 to 255 and then from 255 to 0.

The lines looks like this atm:

if ( vehHP <= 300 ) then

dxDrawText("Warning", 0.37*x, 0.962*y, 0.5*x, 1.0*y, tocolor(255, 0, 0, 255), 0.0012*x, 0.0019*y, "default", "center", "center", false, false, true, false)

else

return

end

So I want to make that text flashing when it´s showing. Anyone who can help me?

Link to post

Something like this. Untested.

local turn = true -- OUTSIDE THE RENDERER 
local alpha = 255 -- OUTSIDE THE RENDERER  
  
local vehHP = 100 -- YOUR VALUE 
  
function renderHealth() 
  if ( vehHP <= 300 ) then 
  if turn == true then 
    alpha = alpha + 2 
    if alpha > 255 then 
      alpha = 255 
      turn = false 
    end 
  elseif turn == false then 
    alpha = alpha - 2 
    if alpha < 0 then 
      alpha = 0 
      turn = true 
    end 
  end 
  dxDrawText("Warning", 0.37*x, 0.962*y, 0.5*x, 1.0*y, tocolor(255, 0, 0, alpha), 0.0012*x, 0.0019*y, "default", "center", "center", false, false, true, false) 
  else 
  return 
  end 
end 
addEventHandler("onClientRender",getRootElement(),renderHealth) 

Link to post

Hmm, didn´t work. I´ve seen stuff like this around in the forum.

Btw, I am using vehHP as:

vehHP = getElementHealth(getPedOccupiedVehicle(localPlayer))

Edited by Guest
Link to post

Ye but nothing in debug, the text is there like before. But I have tried a lot myself, but nothing was working. That´s why I am asking here if someone knows how to do it.

I fixed it, a small thing that wasn´t noticing in debug some reason. Thx your suggestion.

Link to post

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