Jump to content

Table Dialogs


Dice

Recommended Posts

dialogs = {} 
function createAttentionDialog ( text ) 
    index = index + 1 
    if not dialogs[index] then 
        dialogs[index] = {} 
    else 
        return createAttentionDialog ( text ) 
    end 
    local screenW, screenH = guiGetScreenSize() 
    -- tabs = #dialogs[index] + 1 
    dialogs[index].window = guiCreateWindow((screenW - 386) / 2, (screenH - 185) / 2, 386, 185, "Attention!", false) 
    -- guiWindowSetSizable(dialogs[1].window, false) 
  
    dialogs[index].okbutton = guiCreateButton(87, 127, 89, 24, "OK", false, dialogs[index].window) 
    dialogs[index].lbl = guiCreateLabel(15, 27, 355, 85, text, false, dialogs[index].window) 
    guiSetFont(dialogs[index].lbl, "clear-normal") 
    guiLabelSetHorizontalAlign(dialogs[index].lbl, "center", true) 
    guiLabelSetVerticalAlign(dialogs[index].lbl, "center") 
    dialogs[index].cancelbutton = guiCreateButton(198, 127, 89, 24, "Cancel", false,  dialogs[index].window) 
    dialogs[index].chk = guiCreateCheckBox(128, 156, 117, 15, "Disable requests", false, false,  dialogs[index].window) 
    guiSetFont( dialogs[index].chk, "default-bold-small") 
    addEventHandler ( "onClientGUIClick", dialogs[index].okbutton, 
                        function ( ) 
                            _destroyElement ( dialogs[index].window ) 
                         
                        end 
                            ,false 
                        ) 
end 
     

A friend put me in charge of a part of a script. and i don't know how to make it so for each window it creates, i can press ok to close eacch one. Right now it works but i can only close the most current ones. the rest stay open adn when i press ok on them it says destroyElement ( bad pointer ). my friend patched _destroyElement so dont worry about that

Link to comment
dialogs = {} 
function createAttentionDialog ( text ) 
    index = index + 1 
    if not dialogs[index] then 
        dialogs[index] = {} 
    else 
        return createAttentionDialog ( text ) 
    end 
    local screenW, screenH = guiGetScreenSize() 
    -- tabs = #dialogs[index] + 1 
    dialogs[index].window = guiCreateWindow((screenW - 386) / 2, (screenH - 185) / 2, 386, 185, "Attention!", false) 
    -- guiWindowSetSizable(dialogs[1].window, false) 
  
    dialogs[index].okbutton = guiCreateButton(87, 127, 89, 24, "OK", false, dialogs[index].window) 
    dialogs[index].lbl = guiCreateLabel(15, 27, 355, 85, text, false, dialogs[index].window) 
    guiSetFont(dialogs[index].lbl, "clear-normal") 
    guiLabelSetHorizontalAlign(dialogs[index].lbl, "center", true) 
    guiLabelSetVerticalAlign(dialogs[index].lbl, "center") 
    dialogs[index].cancelbutton = guiCreateButton(198, 127, 89, 24, "Cancel", false,  dialogs[index].window) 
    dialogs[index].chk = guiCreateCheckBox(128, 156, 117, 15, "Disable requests", false, false,  dialogs[index].window) 
    guiSetFont( dialogs[index].chk, "default-bold-small") 
    addEventHandler ( "onClientGUIClick", dialogs[index].okbutton, 
                        function ( ) 
                            _destroyElement ( getElementParent ( source ) )  
                        
                        end 
                            ,false 
                        ) 
end 

You don't need a costum destroyElement function btw, destroyElement itself is fine.

Link to comment

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