Jump to content

is handler removed after delete element?


IIYAMA

Recommended Posts

  • Moderators
Posted
  
local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) 
addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) 
destroyElement(confirmButton) 
  

Will the handler still be there?

Posted
  
  
function destroyElement(element) 
element = nil  
end 
  

:wink::wink:

Makes no sense. Replaces destroyElement by a function which sets its own local variable to nil, therefore doing absolutely nothing.

Posted
  
local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) 
addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) 
destroyElement(confirmButton) 
  

Will the handler still be there?

  
local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) 
addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) 
  
  
--- if you need destroy 
removeEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) -- to remove this event 
destroyElement(confirmButton) -- then destroy element 
  
  

  • Moderators
Posted

Now I get again two differed answers from two experienced posters...........

(not me "Experienced"...)

If I delete the element that is handled and after that I handle again, there won't be any errors.

Is the handler gone from the previous element?

grrrr I hate it when I can't see what happens..... :|

Posted
Now I get again two differed answers from two experienced posters...........

(not me "Experienced"...)

If I delete the element that is handled and after that I handle again, there won't be any errors.

Is the handler gone from the previous element?

grrrr I hate it when I can't see what happens..... :|

Is the handler gone from the previous element?

yes you should remove this handler then destroy element to prevent any errors

Posted

ok, either way the event handler would be destroyed, because for one, the element wouldn't exist anymore thus the event handler would be no use and wouldn't be triggered, and even if you remove the event handler, I think it would save some ram, but either way the event handler would be destroyed.

Posted
ok, either way the event handler would be destroyed, because for one, the element wouldn't exist anymore thus the event handler would be no use and wouldn't be triggered, and even if you remove the event handler, I think it would save some ram, but either way the event handler would be destroyed.

Great answer :arrowup:

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