Blinker. Posted June 24, 2014 Share Posted June 24, 2014 hello guys , i've been working for couple of hours on a script i don't want to get stucked here. i edited admin_report.lua in admin , i want to make a new gui , so if i click on proceed the report would open. --[[********************************** * * Multi Theft Auto - Admin Panel * * gui\admin_report.lua * * Original File by lil_Toady * **************************************]] aReportForm = nil function aReport ( player ) if ( aReportForm == nil ) then local x, y = guiGetScreenSize() aReportForm = guiCreateWindow ( x / 2 - 150, y / 2 - 150, 300, 300, "Contact", false ) guiCreateLabel ( 0.05, 0.11, 0.20, 0.09, "Category:", true, aReportForm ) guiCreateLabel ( 0.05, 0.21, 0.20, 0.09, "Subject:", true, aReportForm ) guiCreateLabel ( 0.05, 0.30, 0.20, 0.07, "Message:", true, aReportForm ) aReportCategory = guiCreateEdit ( 0.30, 0.10, 0.65, 0.09, "Question", true, aReportForm ) guiEditSetReadOnly ( aReportCategory, true ) aReportDropDown = guiCreateStaticImage ( 0.86, 0.10, 0.09, 0.09, "client\\images\\dropdown.png", true, aReportForm ) guiBringToFront ( aReportDropDown ) aReportCategories = guiCreateGridList ( 0.30, 0.10, 0.65, 0.30, true, aReportForm ) guiGridListAddColumn( aReportCategories, "", 0.85 ) guiSetVisible ( aReportCategories, false ) guiGridListSetItemText ( aReportCategories, guiGridListAddRow ( aReportCategories ), 1, "Rights", false, false ) aReportSubject = guiCreateEdit ( 0.30, 0.20, 0.65, 0.09, "", true, aReportForm ) aReportMessage = guiCreateMemo ( 0.05, 0.38, 0.90, 0.45, "~nicknames(old: | new:):\n~Your real name:\n~how old are you:", true, aReportForm ) aReportAccept = guiCreateButton ( 0.40, 0.88, 0.25, 0.09, "Send", true, aReportForm ) aReportCancel = guiCreateButton ( 0.70, 0.88, 0.25, 0.09, "Cancel", true, aReportForm ) addEventHandler ( "onClientGUIClick", aReportForm, aClientReportClick ) addEventHandler ( "onClientGUIDoubleClick", aReportForm, aClientReportDoubleClick ) end guiBringToFront ( aReportForm ) showCursor ( true ) end addCommandHandler ( "nothing123", aReport ) function aReportClose ( ) if ( aReportForm ) then removeEventHandler ( "onClientGUIClick", aReportForm, aClientReportClick ) removeEventHandler ( "onClientGUIDoubleClick", aReportForm, aClientReportDoubleClick ) destroyElement ( aReportForm ) aReportForm = nil showCursor ( false ) end end function aClientReportDoubleClick ( button ) if ( button == "left" ) then if ( source == aReportCategories ) then if ( guiGridListGetSelectedItem ( aReportCategories ) ~= -1 ) then local cat = guiGridListGetItemText ( aReportCategories, guiGridListGetSelectedItem ( aReportCategories ), 1 ) guiSetText ( aReportCategory, cat ) guiSetVisible ( aReportCategories, false ) end end end end function aClientReportClick ( button ) if ( source == aReportCategory ) then guiBringToFront ( aReportDropDown ) end if ( source ~= aReportCategories ) then guiSetVisible ( aReportCategories, false ) end if ( button == "left" ) then if ( source == aReportAccept ) then if ( ( string.len ( guiGetText ( aReportSubject ) ) < 1 ) or ( string.len ( guiGetText ( aReportMessage ) ) < 5 ) ) then aMessageBox ( "error", "Subject/Message missing." ) else aMessageBox ( "info", "Your message has been submited and will be processed as soon as possible." ) setTimer ( aMessageBoxClose, 3000, 1, true ) local tableOut = {} tableOut.category = guiGetText ( aReportCategory ) tableOut.subject = guiGetText ( aReportSubject ) tableOut.message = guiGetText ( aReportMessage ) triggerServerEvent ( "aMessage", getLocalPlayer(), "new", tableOut ) aReportClose () end elseif ( source == aReportSubject ) then elseif ( source == aReportMessage ) then elseif ( source == aReportCancel ) then aReportClose () elseif ( source == aReportDropDown ) then guiBringToFront ( aReportCategories ) guiSetVisible ( aReportCategories, true ) end end end ------------------------------ -----EDIT ------------------------------ local sW, sH = guiGetScreenSize() window1 = guiCreateWindow(sW / 2 - 150, sH / 2 - 150, 298, 171, "Request Rights", false) guiWindowSetSizable(window1, false) proceed1 = guiCreateButton(10, 123, 123, 38, "Proceed", false, window1) guiSetFont(proceed1, "default-bold-small") close1 = guiCreateButton(152, 122, 122, 39, "Close", false, window1) guiSetFont(close1, "default-bold-small") label1 = guiCreateLabel(9, 20, 279, 25, "Here, you can submit a Request if you wish to get Rights in order to manage cw's or fw's.", false, window1) guiSetFont(label1, "default-small") guiLabelSetHorizontalAlign(label1, "left", true) label2 = guiCreateLabel(8, 47, 159, 18, "Our rules are the followings:", false, window1) guiSetFont(label2, "default-bold-small") label3 = guiCreateLabel(10, 66, 157, 16, "You Should:", false, window1) guiSetFont(label3, "default-small") guiLabelSetColor(label3, 25, 255, 7) label4 = guiCreateLabel(170, 66, 123, 16, "You shouldn't:", false, window1) guiSetFont(label4, "default-small") guiLabelSetColor(label4, 237, 0, 0) label5 = guiCreateLabel(9, 76, 158, 51, "~Respect others\n~Wait if other clans are playing a cw\n~mute annoyers/insulters\n~kick hackers/cheaters \n", false, window1) guiSetFont(label5, "default-small") label6 = guiCreateLabel(166, 77, 127, 50, "~Interrupt cw's/fw's\n~kick for 'no reason'\n~Abuse admin powers\n~spec if players don't accept\n", false, window1) guiSetFont(label6, "default-small") guiSetVisible( window1, false ) showCursor ( false ) function onresourceStart () bindKey ("F4", "down", showPanel) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresourceStart) addEventHandler ( "onClientGUIClick", root, setStats ) function showPanel () getVisible = guiGetVisible (window1) playerName = getPlayerName ( getLocalPlayer() ) if (getVisible == true) then guiSetVisible (window1, false) showCursor (false) end if (getVisible == false) then guiSetVisible (window1, true) showCursor (true) end end function onGuiClick (button, state, absoluteX, absoluteY) if (source == close1) then guiSetVisible (window1, false) showCursor (false) end end addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) function onGuiClick (button, state, absoluteX, absoluteY) if (source == proceed1) then guiSetVisible (aReportForm, true) showCursor (true) end end addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) well , the error shows at line 165 "Bad Argument @ 'guiSetVisible' [expected -element at argument 1 , got nil ]" the report panel doesn't show when i click on proceed button. Please help, a lot of thanks Link to comment
Castillo Posted June 24, 2014 Share Posted June 24, 2014 That's because "aReportForm" doesn't exist, because "aReport" function was never executed. Link to comment
Castillo Posted June 24, 2014 Share Posted June 24, 2014 Well, you shouldn't start editing a script if you don't know how it works. You could execute "aReport" function when the resource starts, but make sure to hide the window after it's created. Link to comment
Blinker. Posted June 24, 2014 Author Share Posted June 24, 2014 function onGuiClick (button, state, absoluteX, absoluteY) if (source == proceed1) then executeCommandHandler ("nothing123") endend should this work? , honestly I don't understand it mate EDIT : that works , thanks for your help 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