Jump to content

color problem


daKillar2000

Recommended Posts

Posted

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;)

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

Posted

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.

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

Posted

what exactly "not works"? my phone "not works", can you fix it? :D

seriously, post the whole code that "not works".

p.s. i doubt that is the problem, but what is that "nil" in dxDrawImage anyway?

Posted
no men he spams me debug 3 xD

dxdrawimage can't load background.png O_o

you have it in place and added it to meta.xml, don't you?

Posted

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) 

Posted

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) 
  

Posted

whats your hesitation to post your code then?

because i've just even tested the code above, and it works fine. so it's a fault on your end.

Posted

you have your code, you fix it. i can't, because i can't see it.

i've already asked like 3? times to post it.

Posted

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.

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