Jump to content

dxDrawImage


Recommended Posts

Posted (edited)

Hi! I want to make a script, in which you die, an image appears. It really does, but only just for like not even for a second. About half a second. And i could see the image in game, after triggering it, but it disappeared immediately.
 

function startHalalMusic()
local halalMusic = playSound ("assets/death.mp3")
local dX, dY, dZ = getElementPosition(localPlayer)
setCameraMatrix (dX+5, dY+5, dZ+5, dX, dY, dZ)
setPlayerHudComponentVisible ("all", false)
local x, y = guiGetScreenSize(localPlayer)
local img = dxDrawImage (x/2, y/2, 500, 500, "assets/death.png")
showChat (false)
end
addEvent("startHalalMusic", true)
addEventHandler("startHalalMusic", getRootElement(), startHalalMusic)

function stopHalalMusic()
end
addEvent("stopHalalMusic", true)
addEventHandler("stopHalalMusic", getRootElement(), stopHalalMusic)

function ujraeledes()
	local varjalMar = setTimer( function()
			triggerServerEvent ("respawnJatekos", localPlayer)
			setPlayerHudComponentVisible ("all", true)
			outputChatBox ("#A1D490[King of the Hill]#FFFFFF Újra éledtél.", 255, 255, 255, true)
			showChat (true)
	end, 6000, 1)
end
addEvent ("ujraeledes", true)
addEventHandler ("ujraeledes", getRootElement(), ujraeledes)

I really barely can see the image, but it disappears, right away.

Edited by rusztamas
Posted

You need to render it on screen for every frame with this event:

addEventHandler("onClientRender", root, function()
	dxDrawImage (x/2, y/2, 500, 500, "assets/death.png")
end)

 

  • Like 1
Posted

i definied it, like local deathimg = dxDrawImage(............), and how can i destroy it? it says that destroyElement(deathimg)'s first argument got nil, now what?

Posted

well do this;

function dxDrawDeathImage()
  ...
  dxDrawImage(...)
  ...
 end
addEventHandler("onClientRender",root,dxDrawDeathImage)

and then later to remove or destroy it;

...
removeEventHandler("onClientRender",root,dxDrawDeathImage)
...

Also, you don't need to define the dx image since it returns a bool to tell whether it was created or not and not an element that can be later destroyed.

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