Jump to content

color problem


daKillar2000

Recommended Posts

heey i have a little problem whit this

local defR = 255 
local defG = 0 
local defB =  0 
  
  
addEventHandler( "onClientPlayerDamage", getLocalPlayer(), function() 
  setTimer( background, 1000, 1, defR, defG, defB ) 
end ) 

warnin: bad argument@ 'setTimer'

Can Someone Help me please?:)

ohyeah background is a image;)

Link to comment
heey i have a little problem whit this
local defR = 255 
local defG = 0 
local defB =  0 
  
  
addEventHandler( "onClientPlayerDamage", getLocalPlayer(), function() 
  setTimer( background, 1000, 1, defR, defG, defB ) 
end ) 

warnin: bad argument@ 'setTimer'

Can Someone Help me please?:)

ohyeah background is a image;)

setTimer is meant to call a function after specified amount of time, not image. you should put a function there

local defR = 255 
local defG = 0 
local defB =  0 
  
function changeBackground(r,g,b) 
  -- the stuff you'll do with background image 
end 
  
addEventHandler( "onClientPlayerDamage", getLocalPlayer(), function() 
  setTimer(changeBackground, 1000, 1, defR, defG, defB) 
end ) 

Link to comment
it's a dxdraw image

background = dxDrawImage(37, 450.5, 147.5, 130,"background.png",0.0,0.0,0.0,tocolor( 255 ,255, 255 ),false,nil)

i whil when he Damage change it to red for one sec.

well, dxDrawImage needs to be called from "onClientRender" event:

local defR = 255 
local defG = 255 
local defB = 255 
  
function changeBackground(r,g,b) 
  defR, defG, defB = r, g, b 
end 
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), function() 
  changeBackground(255, 0, 0) 
  setTimer(changeBackground, 1000, 1, 255, 255, 255) 
end) 
  
addEventHandler("onClientRender", getRootElement(), function() 
  dxDrawImage(37, 450.5, 147.5, 130,"background.png",0.0,0.0,0.0,tocolor(defR, defG, defB),false,nil) 
end) 

Link to comment

he/you forgot about alpha argument..

https://wiki.multitheftauto.com/wiki/DxDrawImage

local defR = 255 
local defG = 255 
local defB = 255 
  
function changeBackground(r,g,b) 
  defR, defG, defB = r, g, b 
end 
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), function() 
  changeBackground(255, 0, 0) 
  setTimer(changeBackground, 1000, 1, 255, 255, 255) 
end) 
  
addEventHandler("onClientRender", getRootElement(), function() 
  dxDrawImage(37, 450.5, 147.5, 130,"asd.png",0.0,0.0,0.0,tocolor(255, defR, defG, defB),false) 
end) 

Link to comment

again, post the code you use, check if the event is triggered at all. like:

  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), function() 
  outputChatBox("onClientPlayerDamage triggered") 
  changeBackground(255, 0, 0) 
  setTimer(changeBackground, 1000, 1, 255, 255, 255) 
end) 
  

Link to comment

well then obviously you're not trying it right, cause when i tried this:

local defR = 255 
local defG = 255 
local defB = 255 
  
function changeBackground(r,g,b) 
  defR, defG, defB = r, g, b 
end 
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), function() 
  changeBackground(255, 0, 0) 
  setTimer(changeBackground, 1000, 1, 255, 255, 255) 
end) 
  
addEventHandler("onClientRender", getRootElement(), function() 
  dxDrawImage(37, 450.5, 147.5, 130,"background.png",0.0,0.0,0.0,tocolor(defR, defG, defB),false) 
end) 

it worked.

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