Jump to content

[HELP] How to stop this?


Hard*

Recommended Posts

Posted

Hello guys, i have one problem with addEventHandler and remove, i need stop the messages on debug, but idk...

Problem: https://i.imgur.com/jLg4yTn.png

Code:

function addPanel(clickpanel, state)
	if clickpanel == "left" and state == "down" then
	elseif cursorPosition(x*213, y*64, x*240, y*140) then
		addEventHandler("onClientRender", getRootElement(), panel_news_selected)
		addEventHandler("onClientRender", getRootElement(), panel_news_)
		removeEventHandler("onClientRender", getRootElement(), panel_login_selected)
		removeEventHandler("onClientRender", getRootElement(), panel_login_)
		removeEventHandler("onClientRender", getRootElement(), panel_register_selected)
		removeEventHandler("onClientRender", getRootElement(), panel_register_)
	elseif cursorPosition(x*213, y*206, x*240, y*140) then
		removeEventHandler("onClientRender", getRootElement(), panel_news_selected)
		removeEventHandler("onClientRender", getRootElement(), panel_news_)
		addEventHandler("onClientRender", getRootElement(), panel_login_selected)
		addEventHandler("onClientRender", getRootElement(), panel_login_)
		removeEventHandler("onClientRender", getRootElement(), panel_register_selected)
		removeEventHandler("onClientRender", getRootElement(), panel_register_)
	elseif cursorPosition(x*213, y*348, x*240, y*140) then
		removeEventHandler("onClientRender", getRootElement(), panel_news_selected)
		removeEventHandler("onClientRender", getRootElement(), panel_news_)
		removeEventHandler("onClientRender", getRootElement(), panel_login_selected)
		removeEventHandler("onClientRender", getRootElement(), panel_login_)
		addEventHandler("onClientRender", getRootElement(), panel_register_selected)
		addEventHandler("onClientRender", getRootElement(), panel_register_)
	end
end
addEventHandler("onClientClick", getRootElement(), addPanel)

 

Sorry for english, i no use translator xd

  • Moderators
Posted

You called the addEventHandler twice.

Example: You open the login page with the news, BUT the news already handled. It's not critical error, only spamming the debug with warning.

  • Like 1
Posted
10 minutes ago, Patrick2562 said:

Você chamou o addEventHandler duas vezes.

Exemplo: você abre a página de login com as notícias, MAS as notícias já foram tratadas. Não é um erro crítico, apenas spamming a depuração com aviso.

Yes, I know it's nothing serious, I also know why the message in the debug is appearing, but I wanted to know a way to disable these warnings for this function, I already saw this in other resources but I do not remember how to do this.

Thanks for the answer

  • Moderators
Posted
1 hour ago, Hard* said:

Yes, I know it's nothing serious, I also know why the message in the debug is appearing, but I wanted to know a way to disable these warnings for this function, I already saw this in other resources but I do not remember how to do this.

Thanks for the answer

I said, you call the addEventHandler 2 times.

Find where you call it 2th time.

But I think a better solution if you use only 1 clientRender.

Like this:

local pageName = false

function render()
	if pageName == "login" then
    	-- draw login page
    elseif pageName == "register" then
    	-- draw register page
    elseif pageName == "news" then
    	-- draw news page
    end
end
addEventHandler("onClientRender", root, render)

function addPanel(clickpanel, state)
	if clickpanel == "left" and state == "down" then
      if cursorPosition(x*213, y*64, x*240, y*140) then
          pageName = "news"
      elseif cursorPosition(x*213, y*206, x*240, y*140) then
          pageName = "login"
      elseif cursorPosition(x*213, y*348, x*240, y*140) then
          pageName = "register"
      end
  	end
end
addEventHandler("onClientClick", getRootElement(), addPanel)

 

Posted (edited)
1 hour ago, Patrick2562 said:

I said, you call the addEventHandler 2 times.

Find where you call it 2th time.

But I think a better solution if you use only 1 clientRender.

Like this:


local pageName = false

function render()
	if pageName == "login" then
    	-- draw login page
    elseif pageName == "register" then
    	-- draw register page
    elseif pageName == "news" then
    	-- draw news page
    end
end
addEventHandler("onClientRender", root, render)

function addPanel(clickpanel, state)
	if clickpanel == "left" and state == "down" then
      if cursorPosition(x*213, y*64, x*240, y*140) then
          pageName = "news"
      elseif cursorPosition(x*213, y*206, x*240, y*140) then
          pageName = "login"
      elseif cursorPosition(x*213, y*348, x*240, y*140) then
          pageName = "register"
      end
  	end
end
addEventHandler("onClientClick", getRootElement(), addPanel)

 

Oooh, thank u man, very nice ❤️ loveU

Just one more thing xd
How do I leave a page started before clicking on the others?

Edited by Hard*
One more question
  • Moderators
Posted
1 hour ago, Hard* said:

Oooh, thank u man, very nice ❤️ loveU

Just one more thing xd
How do I leave a page started before clicking on the others?

Do not quite understand

Posted
47 minutes ago, Patrick2562 said:

Não entendi muito bem

It may seem so easy, but I could not make it work very well.

I want you to start the panel, the Home tab is already added

  • Moderators
Posted (edited)
8 minutes ago, Hard* said:

It may seem so easy, but I could not make it work very well.

I want you to start the panel, the Home tab is already added

You want to define the default page? Example: the login page?

local pageName = "login"

function render()
	if pageName == "login" then
    	-- draw login page
    elseif pageName == "register" then
    	-- draw register page
    elseif pageName == "news" then
    	-- draw news page
    end
end
addEventHandler("onClientRender", root, render)

function addPanel(clickpanel, state)
	if clickpanel == "left" and state == "down" then
      if cursorPosition(x*213, y*64, x*240, y*140) then
          pageName = "news"
      elseif cursorPosition(x*213, y*206, x*240, y*140) then
          pageName = "login"
      elseif cursorPosition(x*213, y*348, x*240, y*140) then
          pageName = "register"
      end
  	end
end
addEventHandler("onClientClick", getRootElement(), addPanel)

 

Edited by Patrick2562
Posted
function panel()
	if inHome then
		dxDrawtext... ... ...
	end
  	if inNews then
		dxDrawtext... ... ...
	end
  	if inLogin then
		dxDrawtext... ... ...
	end
  	if inRegister then
		dxDrawtext... ... ...
	end
end

function onClientClick(button,state,cX,cY)
	if not isCursorShowing() then
		return
	end
	if button == "left" and state == "up" then
		if not inHome then
			if cursorPosition(x*213, y*64, x*240, y*140) then
				inHome = false
				inNews = true
				inLogin = false
				inRegister = false
			elseif cursorPosition(x*213, y*206, x*240, y*140) then
				inHome = false
				inNews = false
				inLogin = true
				inRegister = false
			elseif cursorPosition(x*213, y*348, x*240, y*1400) then
				inHome = false
				inNews = false
				inLogin = false
				inRegister = true
			end
		end
	end
end
addEventHandler("onClientClick", root, onClientClick)

 

  • Moderators
Posted
7 minutes ago, Hard* said:

function panel()
	if inHome then
		dxDrawtext... ... ...
	end
  	if inNews then
		dxDrawtext... ... ...
	end
  	if inLogin then
		dxDrawtext... ... ...
	end
  	if inRegister then
		dxDrawtext... ... ...
	end
end

function onClientClick(button,state,cX,cY)
	if not isCursorShowing() then
		return
	end
	if button == "left" and state == "up" then
		if not inHome then
			if cursorPosition(x*213, y*64, x*240, y*140) then
				inHome = false
				inNews = true
				inLogin = false
				inRegister = false
			elseif cursorPosition(x*213, y*206, x*240, y*140) then
				inHome = false
				inNews = false
				inLogin = true
				inRegister = false
			elseif cursorPosition(x*213, y*348, x*240, y*1400) then
				inHome = false
				inNews = false
				inLogin = false
				inRegister = true
			end
		end
	end
end
addEventHandler("onClientClick", root, onClientClick)

 

It's looks good. But the onClientRender is missing.

addEventHandler("onClientRender", root, panel)

 

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