Jump to content

destroyElement isn't *really* destroyed


Morelli

Recommended Posts

I found out this while testing GUIs. When an element is destroyed with the function destroyElement, the script still recognises it to exist, even though the visual representation of it (whatever it may be), ceases to exist. A sample code illustrating this can be found below.

function test( button, state, sx, sy, x, y, z, elem, gui ) 
    Grid = guiCreateGridList ( 0.5, 0.5, 0.3, 0.2, true ) 
    destroyElement( Grid ) 
    if ( Grid ) then 
        outputChatBox( "Yes") 
    else 
        outputChatBox( "No") 
    end 
end 
  
addCommandHandler( "o", test) 

Link to comment

This is normal in any language - see malloc/free in C. The "value" returned from malloc is a pointer (reference) to the memory block. The same thing happens with MTA elements - variables point to the type data but aren't the type themselves (references).

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...