Jump to content

Problem with bindkey


Jurandovsky

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...