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?

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

Thank you!

That was a fast answer :)

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
  
  
function destroyElement(element) 
element = nil  
end 
  

:wink::wink:

تذكر عند تصفحك للأنترنت قوله تعالى: (( وهو معكم أين ما كنتم والله بما تعملون بصير )) ا

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 
  
  

Welcom to my server Q.5

Current game type in my server Drift

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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

Welcom to my server Q.5

Current game type in my server Drift

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

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.

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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:

Welcom to my server Q.5

Current game type in my server Drift

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

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