Moderators IIYAMA Posted April 4, 2013 Moderators Share 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? Link to comment
Moderators IIYAMA Posted April 4, 2013 Author Moderators Share Posted April 4, 2013 Thank you! That was a fast answer Link to comment
Booo Posted April 4, 2013 Share Posted April 4, 2013 function destroyElement(element) element = nil end Link to comment
DiSaMe Posted April 4, 2013 Share 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. Link to comment
MR.S3D Posted April 5, 2013 Share 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 Link to comment
Moderators IIYAMA Posted April 5, 2013 Author Moderators Share 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..... Link to comment
MR.S3D Posted April 5, 2013 Share 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 Link to comment
Jaysds1 Posted April 5, 2013 Share 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. Link to comment
MR.S3D Posted April 5, 2013 Share 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 Link to comment
Moderators IIYAMA Posted April 5, 2013 Author Moderators Share Posted April 5, 2013 YES! thx guys. Link to comment
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