kewizzle Posted April 4, 2017 Share Posted April 4, 2017 how would i go about attaching an image above a zombies head to indicate the zombies health/strength addEvent("onZombieSpawned",true) addEventHandler("onZombieSpawned",root, function ( ) setElementHealth ( source, math.random(25, 100 ) ) if getElementHealth(source) >= 50 then end end) Link to comment
Pembo Posted April 4, 2017 Share Posted April 4, 2017 (edited) Use the dx drawing functions and use the event "onClientRender" to draw it for the client. Edited April 4, 2017 by Pembo Link to comment
kewizzle Posted April 4, 2017 Author Share Posted April 4, 2017 3 hours ago, Pembo said: Use the dx drawing functions and use the event "onClientRender" to draw it for the client. I tried this but it doesnt work. client.lua addEvent("Zomb_STFU",true) addEventHandler("Zomb_STFU",root, function ( zomb ) triggerServerEvent ( "onZombieSpawned", zomb ) end) addEvent("drawLevelSt", true) addEventHandler("drawLevelSt", root, function() local x, y = getElementPosition(source) function renderDisplay ( ) local seconds = getTickCount() / 1000 local angle = math.sin(seconds) * 80 dxDrawImage ( x, y, 100, 240, 'arrow.png', angle, 0, -120 ) end function HandleTheRendering ( ) addEventHandler("onClientRender", root, renderDisplay) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) end) server.lua addEvent("onZombieSpawned",true) addEventHandler("onZombieSpawned",root, function ( ) setElementHealth ( source, math.random(25, 100 ) ) if getElementHealth(source) >= 50 then triggerClientEvent ( "drawLevelSt", source, drawLevelStn, source ) end end) i found this dxDrawImageOnElement now to sure how it works ... just read it and i get errors. Link to comment
kewizzle Posted April 4, 2017 Author Share Posted April 4, 2017 I did this, but i dont know how to make it for only peds with health >= 50 local tag = dxCreateTexture("redDot.png") addEventHandler("onClientPreRender", root, function() for k,v in ipairs(getElementsByType("ped")) do dxDrawImageOnElement(v,tag) end end) Link to comment
kewizzle Posted April 4, 2017 Author Share Posted April 4, 2017 works now. local tag = dxCreateTexture("redDot.png") addEvent("onClientPreRender", true) addEventHandler("onClientPreRender", root, function() for k,v in ipairs(getElementsByType("ped")) do if getElementHealth(v) >= 50 then dxDrawImageOnElement(v,tag) end end end) Link to comment
Pembo Posted April 4, 2017 Share Posted April 4, 2017 11 hours ago, kewizzle said: works now. local tag = dxCreateTexture("redDot.png") addEvent("onClientPreRender", true) addEventHandler("onClientPreRender", root, function() for k,v in ipairs(getElementsByType("ped")) do if getElementHealth(v) >= 50 then dxDrawImageOnElement(v,tag) end end end) Yeah sorry didn't mention the dxDrawImageOnElement function its really useful along with dxDrawTextOnElement which will draw text on an element so if you wanted to put text above a player too then you can use that 1 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