Jump to content

How to make dxText to flash?


Adde

Recommended Posts

Posted

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?

Posted

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) 

Posted (edited)

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
Posted (edited)

You can use a lot of things there.

"Didn't work" - debug, find problems, come on, we're not the ones who make everything for you. Would be easier if you posted the code with proper tabulations and full function.

Edited by Guest
Posted

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.

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