iPrestege Posted March 18, 2013 Share Posted March 18, 2013 no it's not wrong why it well be worng ?and also he say when player he got damge and die the image wont hide because the health he should use setTimer . You will spam the chat with you're code and use source > not defined . try this "GamerDeMTA" : addEventHandler ( 'onClientPlayerDamage', localPlayer, function ( ) setTimer(function() local health = getElementHealth ( localPlayer ) outputChatBox ( "Your health is: ".. math.floor ( health ) .."%" ) if ( health <= 10 ) then guiSetVisible ( image, true ) end end, 1000, 1) end ) addEventHandler( 'onClientPlayerWasted', localPlayer, function ( ) guiSetVisible( image, false ) end ) Link to comment
X-SHADOW Posted March 18, 2013 Share Posted March 18, 2013 oh i foget about source Thank's Any way . Link to comment
GamerDeMTA Posted March 18, 2013 Author Share Posted March 18, 2013 Pai[N] Code doesn't work, I only deleted the outputchatbox. Ah, but that code you posted Pres[T]ege does what I want? I also want when a player recuperate health [i've a script that does that] the image isn't showed, not only when the player die Link to comment
iPrestege Posted March 18, 2013 Share Posted March 18, 2013 Ok,Try : local sx, sy = guiGetScreenSize ( ) local image = guiCreateStaticImage(0,0,sx,sy,"image.png",false) guiSetVisible ( image, false ) addEventHandler ( 'onClientPlayerDamage', root, function( attacker, weapon, bodypart, loss) if ( attacker and attacker ~= source and attacker == localPlayer ) then if ( loss <=10 and guiGetVisible(image) == false) then guiSetVisible ( image, true ) elseif ( loss > 10 and guiGetVisible(image) ) then guiSetVisible ( image, false ) end end end ) addEventHandler( 'onClientPlayerWasted', localPlayer, function ( ) guiSetVisible( image, false ) end ) Link to comment
GamerDeMTA Posted March 18, 2013 Author Share Posted March 18, 2013 But that puts the image when I attack someone, can you say me to put the image when a player has 10 Health or less, and when he recuperates the health image isn't, also when he die the image isn't? No with attacking. Link to comment
iPrestege Posted March 18, 2013 Share Posted March 18, 2013 local sx, sy = guiGetScreenSize ( ) local image = guiCreateStaticImage(0,0,sx,sy,"image.png",false) guiSetVisible ( image, false ) addEventHandler ( 'onClientRender', root, function() local health = getElementHealth(localPlayer) if ( health > 10 and guiGetVisible(image) ) then guiSetVisible ( image, false ) end end ) addEventHandler ( 'onClientPlayerDamage', root, function( attacker,weapon, bodypart, loss) if ( loss <= 10 and guiGetVisible(image) == false) then guiSetVisible ( image, true ) end end ) addEventHandler( 'onClientPlayerWasted', localPlayer, function ( ) guiSetVisible( image, false ) end ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now