FlyingSpoon Posted August 23, 2015 Share Posted August 23, 2015 local window = guiCreateWindow(0.21, 0.15, 0.62, 0.62, "D4MN Website - ©RaysMTA", true) local closebtn = guiCreateButton(0.87, 0.92, 0.11, 0.06, "Close", true, window) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible(window, false) local theBrowser = guiGetBrowser(browser) function openBrowser() local browser = guiCreateBrowser(9, 22, 611, 409, false, false, false, window) addEventHandler("onClientBrowserCreated", theBrowser) loadBrowserURL(source, "http://d4mnserver.uk") showCursor (true) guiSetVisible(window, true) end bindKey("F2", "down", openBrowser) function closeAll() if source == closebtn then guiSetVisible ( window, false ) showCursor ( false ) end end addEventHandler("onClientGUIClick", getRootElement(), closeAll) Doesn't work - GUI opens, and shows cursor but browser doesn't. Bad argument @ 'addEventHandler' [Expected element at argument 2, got boolean] Bad argument @ 'loadBrowserURL' [Expected texture at argument 1, got nil] Link to comment
Addlibs Posted August 24, 2015 Share Posted August 24, 2015 1) You haven't even created a browser in your code, add guiCreateBrowser anywhere between line 7 and line 1, making the window its parent. This is the reason why you have a Bad argument error at addEventHandler, the source you've specified is false, not the GUI browser. 2) Secondly, you haven't specified what function the event handler should call, i.e. you failed to specify the 3rd argument at addEventHandler Link to comment
FlyingSpoon Posted August 24, 2015 Author Share Posted August 24, 2015 --In order to render the browser on the full screen, we need to know the dimensions. --local screenWidth, screenHeight = guiGetScreenSize() --Let's create a new browser in remote mode. local window = guiCreateWindow(0.21, 0.15, 0.62, 0.62, "D4MN Website - ©RaysMTA", true) local closebtn = guiCreateButton(0.87, 0.92, 0.11, 0.06, "Close", true, window) local browser = guiCreateBrowser(9, 22, 611, 409, false, false, false, window) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible(window, false) function getBro() local theBrowser = guiGetBrowser(browser) end function openBrowser() addEventHandler("onClientBrowserCreated", theBrowser, getBro) loadBrowserURL(source, "http://d4mnserver.uk") showCursor (true) guiSetVisible(window, true) end bindKey("F2", "down", openBrowser) function closeAll() if source == closebtn then guiSetVisible ( window, false ) showCursor ( false ) end end addEventHandler("onClientGUIClick", getRootElement(), closeAll) Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Bad argument @ 'loadBrowserURL' [Expected texture at argument 1, got nil] Link to comment
Enkanet Posted August 24, 2015 Share Posted August 24, 2015 You need to request your website first with: requestBrowserDomains Link to comment
FlyingSpoon Posted August 24, 2015 Author Share Posted August 24, 2015 --In order to render the browser on the full screen, we need to know the dimensions. --local screenWidth, screenHeight = guiGetScreenSize() --Let's create a new browser in remote mode. local isBrowserOpened = false function openBrowser() if (not isBrowserOpened) then -- We check if the browser is showing or not. isBrowserOpened = true -- If we open the browser, we set our variable to true. window = guiCreateWindow(0.21, 0.15, 0.62, 0.62, "D4MN Website - ©RaysMTA", true) closebtn = guiCreateButton(0.87, 0.92, 0.11, 0.06, "Close", true, window) browser = guiCreateBrowser(9, 22, 611, 409, false, false, false, window) requestBrowserDomains({ "http://d4mnserver.uk" }) theBrowser = guiGetBrowser(browser) addEventHandler("onClientBrowserCreated", theBrowser, function() loadBrowserURL(theBrowser, "http://d4mnserver.uk") end ) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) showCursor (true) addEventHandler("onClientGUIClick", guiRoot, closeAll) end end bindKey("F2", "down", openBrowser) function closeAll() if source == closebtn then isBrowserOpened = false -- As we close it we set it to false. destroyElement(window) showCursor ( false ) removeEventHandler("onClientGUIClick", guiRoot, closeAll) end end bindKey("F2", "down", closeAll) My code works now, but now it only appears for me, I mean the web, when someone else tries nothing? Link to comment
Kelvin Perez Posted August 24, 2015 Share Posted August 24, 2015 Or use mines https://community.multitheftauto.com/ind ... s&id=11963 You are permitted to edit anything you would like, but please do not remove the credits. Enjoy. 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