BrastaSauce Posted May 1, 2014 Share Posted May 1, 2014 So, I have this script I'm starting and so far I only have the GUI, it's to an alarm system. Well, here's my script. local time = getRealTime() local hour = time.hour local minute = time.minute function setAlarmGUI() winSetAlarm = guiCreateWindow(804, 306, 313, 187, "Set Alarm", false) guiWindowSetSizeable(winSetAlarm, false) lblHour = guiCreateEdit(117, 61, 30, 23, hour, false, winSetAlarm) guiCreateLabel(153, 64, 15, 20, ":", false, winSetAlarm) lblMin = guiCreateEdit(163, 61, 30, 23, minute, false, winSetAlarm) guiCreateLabel(126, 44, 21, 17, "hh", false, winSetAlarm) guiCreateLabel(168, 44, 21, 17, "mm", false, winSetAlarm) btnCloseAlarm = guiCreateButton(23, 56, 62, 28, "Close", false, winSetAlarm) btnSetAlarm = guiCreateButton(231, 56, 62, 28, "Set", false, winSetAlarm) winSetAlarmGrid = guiCreateGridList(13, 91, 290, 86, false, winSetAlarm) guiGridListAddColumn(winSetAlarmGrid, "Alarm", 0.9) guiCreateLabel(7, 32, 273, 44, "This alarm uses 24-hour times. Set it according to\nlocal time.", false, winSetAlarmGrid) guiEditSetMaxLength(lblHour, 2) guiEditSetMaxLength(lblMin, 2) end addCommandHandler("setalarm", setAlarmGUI) function onSetClick(button) if button == left then guiGetText(lblHour) guiGetText(lblMin) destroyElement(winSetAlarm) outputChatBox("Alarm set!", thePlayer, 0, 255, 0) end end Alright, and here is my meta.xml to prove that this is set to Client Side. <meta> <info author="Brasta" type="script" description="Alarm System"/> <script src="s_alarm.lua" type="server"/> <script src="c_alarm.lua" type="client"/> </meta> Here's my problem. It is giving me three errors. 2 of which happen immediately and are "Line 14: addEventHandler Bad Argument at 2, expected Element" and "Line 21: addEventHandler Bad Argument at 2, expected Element". That's the gist of that. The problem? Line 14 and line 21 on my client file aren't even addEventHandlers. In fact, I don't have a single one in that entire script. Then when I do /setalarm, it only loads the window and says "Line 7: attempted to call global "guiWindowSetSizable" " Which isn't even true, since it loads the window before it easily, and since this file is set to Clientside. What's going on? Link to comment
justn Posted May 1, 2014 Share Posted May 1, 2014 local time = getRealTime() local hour = time.hour local minute = time.minute function setAlarmGUI() winSetAlarm = guiCreateWindow(804, 306, 313, 187, "Set Alarm", false) guiWindowSetSizable(winSetAlarm, false) lblHour = guiCreateEdit(117, 61, 30, 23, hour, false, winSetAlarm) guiCreateLabel(153, 64, 15, 20, ":", false, winSetAlarm) lblMin = guiCreateEdit(163, 61, 30, 23, minute, false, winSetAlarm) guiCreateLabel(126, 44, 21, 17, "hh", false, winSetAlarm) guiCreateLabel(168, 44, 21, 17, "mm", false, winSetAlarm) btnCloseAlarm = guiCreateButton(23, 56, 62, 28, "Close", false, winSetAlarm) btnSetAlarm = guiCreateButton(231, 56, 62, 28, "Set", false, winSetAlarm) winSetAlarmGrid = guiCreateGridList(13, 91, 290, 86, false, winSetAlarm) guiGridListAddColumn(winSetAlarmGrid, "Alarm", 0.9) guiCreateLabel(7, 32, 273, 44, "This alarm uses 24-hour times. Set it according to\nlocal time.", false, winSetAlarmGrid) guiEditSetMaxLength(lblHour, 2) guiEditSetMaxLength(lblMin, 2) end addCommandHandler("setalarm", setAlarmGUI) addEventHandler("onClientGUIClick",getRootElement(), function(button) if button == "left" then if source == btnSetAlarm then guiGetText(lblHour) guiGetText(lblMin) guiSetVisible(winSetAlarm,false) outputChatBox("Alarm set!",0, 255, 0) end end end) Link to comment
BrastaSauce Posted May 1, 2014 Author Share Posted May 1, 2014 Thank you! Any chance you could tell me what I did wrong for that to happen? Link to comment
justn Posted May 1, 2014 Share Posted May 1, 2014 Well, you spelt guiWindowSetSizable wrongly. and the event onClientGUIClick was not added also you didn't add the quotation marks around the word left. NOTE: Instead of destroying the gui, use guiSetVisible and set it to false 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