Jump to content

bug on render


iiv03

Recommended Posts

Hi all i have a problem here, i added an onClientClick when i pressed the button i used this

isCursorWithin
getKeyState

I did if i pressed the button then delete the render to the first page i also added another render to the second page soo.. , i made buttons on the first page and when i pressed the button above this will delete render the first page and comes on the second page like this

the problem is if i click on the second page and i close the panel and open it again comes Render event first page with second page

i don't know how fix that :(

 

this my code:

-- TABS ON TOP
function tabsPage()
	local offsetX = 0
    if getKeyState("mouse1") then
         if isCursorWithin(posX, referee.y, sizeX, sizeY) then
		outputChatBox("page 1")
		addEventHandler("onClientRender", root, referee.dxPage1)
		addEventHandler("onClientClick", root, onClickPage1)
		--
		playersPanel = false
		removeEventHandler("onClientRender", root, referee.dxPage2)
		--
		end
		offsetX = offsetX + textmoveX + textmoveX
         if isCursorWithin(posX - textmoveX + offsetX, referee.y, sizeX, sizeY) then
		outputChatBox("page 2")
		removeEventHandler("onClientRender", root, referee.dxPage1)
		removeEventHandler("onClientClick", root, onClickPage1)
		--
		addEventHandler("onClientRender", root, referee.dxPage2)
		--
		end
	end
end






-- WHEN PLAYER PRESS KEY TO OPEN PANEL
	function Opendx()
	referee.ShowDxPanel = not referee.ShowDxPanel
	if referee.ShowDxPanel then
		referee.tick = getTickCount()
		removeEventHandler("onClientRender", root, referee.render)
		removeEventHandler("onClientRender", root, referee.dxPage1)
		showCursor(true)
		addEventHandler("onClientRender", root, referee.render)
		addEventHandler("onClientRender", root, referee.dxPage1)
		addEventHandler("onClientClick", root, onClickPage1)
		addEventHandler("onClientClick", root, tabsPage)
	else
		removeEventHandler("onClientClick", root, onClickPage1)
		removeEventHandler("onClientClick", root, tabsPage)
		showCursor(false)
		referee.tick = getTickCount()
  	end
end
bindKey("f2", "down", Opendx)

could someone help me please?

EDIT:

 

 

i'm fixed like this

		if removeEventHandler("onClientRender", root, referee.dxPage2) then
		addEventHandler("onClientRender", root, referee.dxPage1)
		end

but in debug i get already handled

p_14357m70f1.png

how fix this error's? ?

Edited by xFabel
Link to comment
if getKeyState("mouse1") then
         if isCursorWithin(posX, referee.y, sizeX, sizeY) then

this part of code will execute each frame (onClientRender) while you're holding left mouse button (getKeyState("mouse1")) and cursor is there (posX, referee.y, sizeX, sizeY)
You need to add an additional variable to use click event once

Link to comment
On 07/12/2019 at 16:44, JeViCo said:

if getKeyState("mouse1") then
         if isCursorWithin(posX, referee.y, sizeX, sizeY) then

this part of code will execute each frame (onClientRender) while you're holding left mouse button (getKeyState("mouse1")) and cursor is there (posX, referee.y, sizeX, sizeY)
You need to add an additional variable to use click event once

hey JeViCo

i use on

onClientClick

and i put each mouse1 push into another function

		addEventHandler("onClientClick", root, tabsPage)

 

so.. my problem in function is already handled how stop this spamming? and If it is a large number of players give lag ❔

Link to comment

Sorry for my bad explanation ?
Try this code:

local mouseClick -- additional variable
function tabsPage()
    if getKeyState("mouse1") then
        if isCursorWithin(posX, referee.y, sizeX, sizeY) and not mouseClick then
            outputChatBox("page 1")
            addEventHandler("onClientRender", root, referee.dxPage1)
            addEventHandler("onClientClick", root, onClickPage1)
            --
            playersPanel = false
            removeEventHandler("onClientRender", root, referee.dxPage2)
            --
            mouseClick = true -- 'button click' - click detected. No more code executing
        elseif isCursorWithin(posX + textmoveX, referee.y, sizeX, sizeY) and not mouseClick then
            outputChatBox("page 2")
            removeEventHandler("onClientRender", root, referee.dxPage1)
            removeEventHandler("onClientClick", root, onClickPage1)
            --
            addEventHandler("onClientRender", root, referee.dxPage2)
            --
            mouseClick = true -- 'button click' - click detected. No more code executing
        else
            mouseClick = false -- nothing happend - returning to normal state
        end
    end
end

 

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