Jump to content

Return function in html page or sending variables from Lua


Recommended Posts

The Main Question: How I can send data to HTML page (CEF browser) from Lua code?

I know has executeBrowserJavascript, but I don't know how exactly I can use it, I try define variables like a

executeBrowserJavascript(theBrowser, "var example = 5") 

And use it in HTML code

mta.triggerEvent("cmsg", example) 

but nothing. Or:

var test = mta.triggerEvent("cmsg", "hello mta") 
mta.triggerEvent("cmsg", test) 


function cmsg(msg) 
    return 5 
addEvent("cmsg", true) 
addEventHandler("cmsg", root, cmsg) 

But variable test is "unsupported type" (showing outputChatBox)

Can you help me?

Link to comment

I found a one way with using Using innerHTML. Here is my code:


function cmsg(msg) 
    executeBrowserJavascript(theBrowser, 'document.getElementById("demo").innerHTML = "' .. msg .. '"') 
addEvent("cmsg", true) 
addEventHandler("cmsg", root, cmsg) 


<!DOCTYPE html> 
        <p id="demo"></p> 
            mta.triggerEvent("cmsg", "Hello MTA") 

Link to comment
  • 8 years later...

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...