rusztamas Posted April 1, 2017 Share Posted April 1, 2017 (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 April 1, 2017 by rusztamas Link to comment
Tails Posted April 1, 2017 Share Posted April 1, 2017 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) 1 Link to comment
rusztamas Posted April 1, 2017 Author Share Posted April 1, 2017 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? Link to comment
_DrXenon Posted April 1, 2017 Share Posted April 1, 2017 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. 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