Dear friends,
I have scripted a InputBox for my own admin panel and in the function are different parameters and one parameter is also a function. This function is called if I press the "OK-Button" at the InputBox. But the next time I create a InputBox, the old event from the OK-Button should be removed. I think I have scripted all true, but everytime I press OK-Button the event is called as many times as I opened the InputBox. I hope anyone of you find the error in the following code:
function showInputBox(title,label,eingabet,abbrechen,func)
removeEventHandler("onClientGUIClick", abbrechenbutton,
function()
guiSetVisible(eingabewindow,false)
guiSetInputEnabled(oldinput)
showCursor(oldcursor)
guiSetEnabled(adminpanel,adminenabled)
end
)
removeEventHandler("onClientGUIClick", eingabebutton,
function()
oldfunc()
end
)
oldinput = guiGetInputEnabled()
oldcursor = isCursorShowing()
guiSetText(eingabewindow, tostring(title))
guiSetText(eingabegrundlabel, tostring(label))
guiSetText(eingabebutton, tostring(eingabet))
guiSetText(abbrechenbutton, tostring(abbrechen))
guiSetInputEnabled(true)
showCursor(true)
guiSetVisible(eingabewindow,true)
guiBringToFront(eingabewindow)
function oldfunc()
func()
end
addEventHandler ("onClientGUIClick",abbrechenbutton,
function()
guiSetVisible(eingabewindow,false)
guiSetInputEnabled(oldinput)
showCursor(oldcursor)
guiSetEnabled(adminpanel,adminenabled)
end
,false)
addEventHandler("onClientGUIClick",eingabebutton,
function()
guiSetVisible(eingabewindow,false)
guiSetInputEnabled(oldinput)
showCursor(oldcursor)
oldfunc()
guiSetEnabled(adminpanel,adminenabled)
end
,false)
end