Jurandovsky Posted September 14, 2015 Share Posted September 14, 2015 Hello. Yesterday i tried to make a script which uses js, css, html and lua. When i almost done, i've founded last one problem.. I can't or i don't know how to hook my lua-code to bindkey. Here is a code about gui browser, if i remove that eventhandler, then code isn't working. : addEventHandler("onClientBrowserCreated", browser, function() if isPedInVehicle(localPlayer) then loadBrowserURL(source, "http://mta/interakcja/web/web.html") focusBrowser(source) outputChatBox("Please wait until page will load!") showCursor(true) end end) Best regards ;> Link to comment
Jurandovsky Posted September 14, 2015 Author Share Posted September 14, 2015 Wow... But i've tried with this and nothing.. i was trying something like : bindKey("lshift", "down", function() -- load url -- etc end) and nothing. Link to comment
obuhhh Posted September 14, 2015 Share Posted September 14, 2015 First, create browser. After the bind to open and close. The same bind can do everything else. -- create browser ... bindKey("lshift", "down", function() guiSetVisible(windowBrowser, not guiGetVisible(windowBrowser)) -- load url -- etc end end) Something like this... Sorry for my English. It's all Google translator. Link to comment
Markeloff Posted September 14, 2015 Share Posted September 14, 2015 I gave a try and made this. I hope it helps you to figure out how to do. var = false local screenWidth, screenHeight = guiGetScreenSize() browser_ = createBrowser(screenWidth, screenHeight, false, false) function webBrowserRender() if isElement(browser_) then dxDrawImage(0, 0, screenWidth, screenHeight, browser_, 0, 0, 0, tocolor(255,255,255,255), true) end end function loadBrowser_(bool) if bool == true then showCursor(true) loadBrowserURL(browser_, "https://www.youtube.com/watch?v=ohBQ59OXnYM") focusBrowser(browser_) addEventHandler("onClientRender", root, webBrowserRender) elseif bool == false then destroyElement(browser_) removeEventHandler("onClientRender", root, webBrowserRender) showCursor(false) end end bindKey("b","down", function() if var == true then var = false loadBrowser_(false) elseif var == false then var = true if isPedInVehicle(localPlayer) then loadBrowser_(true) end end end) Link to comment
Jurandovsky Posted September 14, 2015 Author Share Posted September 14, 2015 I repaired it, thanks anyway for 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