Jump to content

image above zombies head


kewizzle

Recommended Posts

Posted

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)

 

Posted (edited)

Use the dx drawing functions and use the event "onClientRender" to draw it for the client.

 

 

Edited by Pembo
Posted
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.

Posted

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) 

 

Posted

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)

 

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

  • Like 1

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