HeK Posted April 13, 2013 Share Posted April 13, 2013 Hello there forum, I'd like to know how i could put some text above a player's head? I'm working on a damage display script, and i'd like to have it displayed above the player that's getting shot. local screenWidth, screenHeight = guiGetScreenSize ( ) kill = {} addEventHandler("onClientPedDamage",root, function ( attaker, weapon) local lostHealth = "-" .. math.ceil(getElementHealth(source)) if ( attaker and attaker == localPlayer ) then if ( kill[localPlayer] ) then killTimer(displayTimer) end dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.12, "default-small" ) dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1.1, "default-small" ) displayTimer = setTimer(dxDrawText,5000,1) end end ) Link to comment
iPrestege Posted April 13, 2013 Share Posted April 13, 2013 Draws a string of text on the screen for one frame. In order for the text to stay visible continuously, you need to call this function with the same parameters on each frame update (see onClientRender). Link to comment
HeK Posted April 13, 2013 Author Share Posted April 13, 2013 Well, and how can i make it show above the player's head? With onClientRender it doesn't even show the text anymore. Link to comment
iPrestege Posted April 13, 2013 Share Posted April 13, 2013 local screenWidth, screenHeight = guiGetScreenSize ( ) setElementData(localPlayer,"EventHandler",false) addEventHandler("onClientPedDamage",root, function ( attaker, weapon) lostHealth = "-" .. math.ceil(getElementHealth(source)) if ( attaker and attaker == localPlayer ) then setTimer(function() if getElementData(localPlayer,"EventHandler") == true then return setElementData(localPlayer,"EventHandler",false) and removeEventHandler("onClientRender",root,Draw) end; setElementData(localPlayer,"EventHandler",true) addEventHandler("onClientRender",root,Draw) end,5000,1) end end ) function Draw() dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.12, "default-small" ) dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1.1, "default-small" ) end Try this will show the ped health after 5 sec! Link to comment
HeK Posted April 13, 2013 Author Share Posted April 13, 2013 That's showing random numbers on the screen, and i want it to show instantly not 5 secs after i shot him, what i need is to make that text show above the ped's head. Link to comment
iPrestege Posted April 13, 2013 Share Posted April 13, 2013 getScreenFromWorldPosition 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