Jump to content

onClientRender function already handled


Recommended Posts

Posted

how do i fix this annoying error?its really pain in the ass

it occurs when removing event handlers and trying to add them again like with dxDrawText onClientRender

how to fix this?

Posted
function test() 
-- dxdraw and shit bla bla 
-- couple of ends without handler 
  
 function firstFunction() 
setElementData(localPlayer,"apple",1) 
addEventHandler("onClientRender",root,test) 
end 
addEvent("firstFunctionn",true) 
addEventHandler("firstFunctionn",root,firstFunction) 
  
function secondFunction() 
setElementData(localPlayer,"apple",0) 
thirdFunction() 
end 
addEvent("secondFunction",true) 
addEventHandler("secondFunction",root,secondFunction) 
  
function thirdFunction() 
removeEventHandler("onClientRender",getRootElement(),test) 
end 

the events are getting triggered by server side script

Posted

If text is already rendered before then it will show the error. I don't know where is your problem.. Because as you told in function test and blablabla. Anyways try this:

  
function test() 
-- dxdraw and :~ bla bla 
-- couple of ends without handler 
  
 function firstFunction() 
setElementData(localPlayer,"apple",1) 
removeEventHandler("onClientRender",getRootElement(),test) 
addEventHandler("onClientRender",root,test) 
end 
addEvent("firstFunctionn",true) 
addEventHandler("firstFunctionn",root,firstFunction) 
  
function secondFunction() 
setElementData(localPlayer,"apple",0) 
thirdFunction() 
end 
addEvent("secondFunction",true) 
addEventHandler("secondFunction",root,secondFunction) 
  
function thirdFunction() 
removeEventHandler("onClientRender",getRootElement(),test) 
end 
  

Posted
no errors and the text is always drawn

what's your problem Exactly Please Explain Better .

it can clearly be seen in the script code that im trying to remove the text when custom event gets triggered,and it gets triggered in server side script

Posted (edited)

Try This ,

--- ClientSide

addEvent('firstFunctionn', true ) 
addEventHandler ( 'firstFunctionn', root, 
function ( ) 
addEventHandler("onClientRender",root,test) 
setElementData(localPlayer,"apple",1) 
   end 
) 
  
addEvent ( 'secondFunction', true ) 
addEventHandler ( 'secondFunction', root, 
function ( ) 
setElementData(localPlayer,"apple",0) 
setTimer(removeEventHandler,1000,1,"onClientRender",getRootElement(),test) 
   end 
) 

Edited @

Edited by Guest
Posted

no errors and text doesnt get removed

edit:

more info: im having element data 1, and it should be 0 when server event was triggered

but i don't see any problem

function serverFunction() 
setElementData(source,"apple",0) 
triggerClientEvent("secondFunction",source) 
end 
addEventHandler("onPlayerUnmute",root,serverFunction) 

Posted
no errors and text doesnt get removed

edit:

more info: im having element data 1, and it should be 0 when server event was triggered

but i don't see any problem

function serverFunction() 
setElementData(source,"apple",0) 
triggerClientEvent("secondFunction",source) 
end 
addEventHandler("onPlayerUnmute",root,serverFunction) 

Copy My Post Again and Make sure it's ClientSide

===================

and this Code is ServerSide ,

addEventHandler("onPlayerUnmute",root, 
function ( ) 
   triggerClientEvent ( source , 'secondFunction', source ) 
end 
) 
Posted
i dont really see point of making function unnamed,it will do same work

only change what you did is added source twice, and it doesn't work for me.

iam sure my code is Correct and will work fine , post the other code if you have one , or Send it Pm .

Posted

i have tried your timer solution and it gave me error that it expected a function in 3rd argument but got nil

what the fuck?

function exists already and script says that it doesnt exist when i unmute myself

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