Jump to content

Help DxRetangle


Recommended Posts

Hello friends I need a little help

I created a small square dxDraw

But the problem is that when he called the square dxdraw disappears very fast

And what I need is for it to stay at least 30 seconds

---Client  


function helpe(emergenci)
	local screenW, screenH = guiGetScreenSize()
        dxDrawLine((screenW * 0.4281) - 1, (screenH * 0.1380) - 1, (screenW * 0.4281) - 1, screenH * 0.4232, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(screenW * 0.5594, (screenH * 0.1380) - 1, (screenW * 0.4281) - 1, (screenH * 0.1380) - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine((screenW * 0.4281) - 1, screenH * 0.4232, screenW * 0.5594, screenH * 0.4232, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(screenW * 0.5594, screenH * 0.4232, screenW * 0.5594, (screenH * 0.1380) - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(screenW * 0.4281, screenH * 0.1380, screenW * 0.1313, screenH * 0.2852, tocolor(0, 0, 0, 98), false)
    end
addEvent("helpe", true)
addEventHandler("helpe", root, helpe)

function delhelpe ()
addEventHandler("onClientRender",getRootElement(),helpe)
setTimer(function() removeEventHandler("onClientRender",getRootElement(),helpe) end,10000,1)
end
addEvent ("onSpecialEvent", true)
addEventHandler ("onSpecialEvent", root, delhelpe)


---Server
triggerClientEvent (player,"helpe", player,emergenci)

 

Edited by xRGamingx
Link to comment

Try this.

 

?
local screenW, screenH = guiGetScreenSize() -- you don't have to get the screen size inside the render function
local disappearTime = 10 -- seconds

function renderPanel()
	dxDrawLine((screenW * 0.4281) - 1, (screenH * 0.1380) - 1, (screenW * 0.4281) - 1, screenH * 0.4232, tocolor(0, 0, 0, 255), 1, false)
	dxDrawLine(screenW * 0.5594, (screenH * 0.1380) - 1, (screenW * 0.4281) - 1, (screenH * 0.1380) - 1, tocolor(0, 0, 0, 255), 1, false)
	dxDrawLine((screenW * 0.4281) - 1, screenH * 0.4232, screenW * 0.5594, screenH * 0.4232, tocolor(0, 0, 0, 255), 1, false)
	dxDrawLine(screenW * 0.5594, screenH * 0.4232, screenW * 0.5594, (screenH * 0.1380) - 1, tocolor(0, 0, 0, 255), 1, false)
	dxDrawRectangle(screenW * 0.4281, screenH * 0.1380, screenW * 0.1313, screenH * 0.2852, tocolor(0, 0, 0, 98), false)
end

function handlePanelRender(state)
	removeEventHandler("onClientRender",getRootElement(),renderPanel)
  	if state then
		addEventHandler("onClientRender",getRootElement(),renderPanel)
   	end
  
  -- if you want the timer solution then just delete the --[[ and the ]] at the end and delete the code above
  --[[
	removeEventHandler("onClientRender",getRootElement(),renderPanel) -- add this so there won't be errors in debugscript about event is being already handled
  	addEventHandler("onClientRender",getRootElement(),renderPanel)
	setTimer(function()
		removeEventHandler("onClientRender",getRootElement(),renderPanel)
	end, disappearTime*1000, 1)
  ]]
end
addEvent ("onSpecialEvent", true)
addEventHandler ("onSpecialEvent", root, handlePanelRender)


---Server
triggerClientEvent(player,"onSpecialEvent",player, true) -- change true to false if you want to make the panel disappear

 

Edited by Dzsozi (h03)
  • Like 1
Link to comment
2 hours ago, Dzsozi (h03) said:

Try this.

 


?
local screenW, screenH = guiGetScreenSize() -- you don't have to get the screen size inside the render function
local disappearTime = 10 -- seconds

function renderPanel()
	dxDrawLine((screenW * 0.4281) - 1, (screenH * 0.1380) - 1, (screenW * 0.4281) - 1, screenH * 0.4232, tocolor(0, 0, 0, 255), 1, false)
	dxDrawLine(screenW * 0.5594, (screenH * 0.1380) - 1, (screenW * 0.4281) - 1, (screenH * 0.1380) - 1, tocolor(0, 0, 0, 255), 1, false)
	dxDrawLine((screenW * 0.4281) - 1, screenH * 0.4232, screenW * 0.5594, screenH * 0.4232, tocolor(0, 0, 0, 255), 1, false)
	dxDrawLine(screenW * 0.5594, screenH * 0.4232, screenW * 0.5594, (screenH * 0.1380) - 1, tocolor(0, 0, 0, 255), 1, false)
	dxDrawRectangle(screenW * 0.4281, screenH * 0.1380, screenW * 0.1313, screenH * 0.2852, tocolor(0, 0, 0, 98), false)
end

function handlePanelRender(state)
	removeEventHandler("onClientRender",getRootElement(),renderPanel)
  	if state then
		addEventHandler("onClientRender",getRootElement(),renderPanel)
   	end
  
  -- if you want the timer solution then just delete the --[[ and the ]] at the end and delete the code above
  --[[
	removeEventHandler("onClientRender",getRootElement(),renderPanel) -- add this so there won't be errors in debugscript about event is being already handled
  	addEventHandler("onClientRender",getRootElement(),renderPanel)
	setTimer(function()
		removeEventHandler("onClientRender",getRootElement(),renderPanel)
	end, disappearTime*1000, 1)
  ]]
end
addEvent ("onSpecialEvent", true)
addEventHandler ("onSpecialEvent", root, handlePanelRender)


---Server
triggerClientEvent(player,"onSpecialEvent",player, true) -- change true to false if you want to make the panel disappear

 

Thanks broth

 

  • Like 1
Link to comment

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