mommytellme Posted January 16, 2016 Share Posted January 16, 2016 Hi, I started with the CEF and created the login panel, but if I try to call the JS-level event MTA using mta.triggerEvent("onCEFLoginRegister"); , nothing happens. What am I doing wrong? My code: local sw,sh = guiGetScreenSize() local webView = guiCreateBrowser(0, 0, sw, sh, true, true, true) --function render () --dxDrawImage(0, 0, sw, sh, webView) --end addEventHandler("onClientBrowserCreated", webView, function() loadBrowserURL(source, "http://mta/local/html/index.html") focusBrowser(source) end ) addEventHandler("onCEFLoginRegister", root, function () outputChatBox("beniz") end) Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 Just a stupid question, is your javascript enabled? Are you sure there are no errors in the JS files? JS is a little kid that cries about everything and drops all of it's stuff when 1 thing is wrong. Link to comment
mommytellme Posted January 16, 2016 Author Share Posted January 16, 2016 Also I thought about it, but I do not see anywhere on / off JS Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 It's in your MTA settings, as far as I know. Link to comment
mommytellme Posted January 16, 2016 Author Share Posted January 16, 2016 Yes, it is turned on Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 Any errors if you open the html file in chrome/ie/edge in your js file? Also, the trigger you're using. Are you sure you've initialized the mta variable? If you're using the javascript SDK, which I assume you do, you can also try to call the resource's function directly without the eventHandler trigger. callFunction ( "resourceName", "functionName", returnFunction, errorFunction [, arguments... ] ); source; https://wiki.multitheftauto.com/wiki/Javascript_SDK Link to comment
mommytellme Posted January 16, 2016 Author Share Posted January 16, 2016 Yup, Uncaught ReferenceError: mta is not defined Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 There you go, your file will be messed up because of that. Therefore you should use the Javascript SDK and call the resource from there. Or you can use PHP to trigger the function, what ever you like. Link to comment
Jusonex Posted January 16, 2016 Share Posted January 16, 2016 The Javascript SDK has nothing to do with CEF. It's part of the resource web access system. Where exactly did you get the ReferenceError error message? The problem is that you forgot adding the event before binding it using: addEvent("onCEFLoginRegister") Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 If you're not adding the event, the server's console should've thrown an error. Guess ThePiotrek did watch his console before coming here. From the style that the error has been noted, it should be in his browser outside of MTA. Even though it does miss some things for a real console error from Javascript. It's not styled as an error from MTA either, so it could be IE/edge's console. Not sure how they build up their errors. Link to comment
Jusonex Posted January 16, 2016 Share Posted January 16, 2016 If you're not adding the event, the server's console should've thrown an error. No. An error is only thrown when triggering an event to the server. mta.triggerEvent calls triggerEvent internally. From the style that the error has been noted, it should be in his browser outside of MTA. Yes, that's what I think either. In general: Calling toggleBrowserDevTools opens the Chromium dev tools window which provides a proper console (remember to enable devmode using setDevelopmentMode(true,true) before though). Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 An error is only thrown when triggering an event to the server Totally off-topic, last message from being off topic too. By triggereing a client sided event which hasn't been added, it also gets called. Just on the client's console ( debugscript ). Which in his case, probably, is the same location as the server. The chromium dev tools could be the way he found the error, not sure how chromium builds up their errors. If it's the same way as Chrome, it doesn't really fit in there. I've been working with chromium a lot but I can't remember the way they build them up. Not even sure if they aren't just transforming the direct javascript error towards the console. Link to comment
mommytellme Posted January 16, 2016 Author Share Posted January 16, 2016 The Javascript SDK has nothing to do with CEF. It's part of the resource web access system.Where exactly did you get the ReferenceError error message? The problem is that you forgot adding the event before binding it using: addEvent("onCEFLoginRegister") Thanks, I forgot about it 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