Moderators IIYAMA Posted April 4, 2013 Moderators Posted April 4, 2013 local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) destroyElement(confirmButton) Will the handler still be there?
Moderators IIYAMA Posted April 4, 2013 Author Moderators Posted April 4, 2013 Thank you! That was a fast answer
DiSaMe Posted April 4, 2013 Posted April 4, 2013 function destroyElement(element) element = nil end Makes no sense. Replaces destroyElement by a function which sets its own local variable to nil, therefore doing absolutely nothing.
MR.S3D Posted April 5, 2013 Posted April 5, 2013 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 IIYAMA Posted April 5, 2013 Author Moderators Posted April 5, 2013 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.....
MR.S3D Posted April 5, 2013 Posted April 5, 2013 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
Jaysds1 Posted April 5, 2013 Posted April 5, 2013 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.
MR.S3D Posted April 5, 2013 Posted April 5, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now