Jump to content

Enable CEF Again!


Recommended Posts

10 hours ago, Jusonex said:

Does the webbrowser resource work for you? (start webbrowser, press Alt and click on the Chromium icon in the left bottom corner).

If not, please run MTADiag (Download)

webbrowser resource Work

in my login panel, when u click on login or register button its trigger a event from js to lua

with mta 1.5.3 login/register buttons didnt work!

( html and all files are local )

Edited by rouzbeh_TopGTA
Link to comment

I'm having the same problem.

Neither the lua nor the js part have been changed.

The events are just not triggered by mta.triggerEvent function anymore.

 

Another thing I noticed, the event "onClientBrowserCreated" now seems to need the actual browser element as its source.

Before it was working using the gui browser element too.

Thats rather a fix than a bug, but at first it didn't load anything at all, until I changed this. (In case someone has the same mistake in their scripts)

Edited by Bonsai
Link to comment

Could you show me the Lua code where you register the event that is triggered from Javascript and the guiCreateBrowser/createBrowser call?

E.g.:

local browser = createBrowser(...)

addEventHandler("eventCalledFromJS", browser,
    function()
        -- ...
    end
)

 

Link to comment
Login.url = "http://mta/local/lobby/html/index.html"
Login.browser = guiCreateBrowser(0, 0, Login.x, Login.y, true, true, false)
guiSetVisible(Login.browser, false)

function Login.create()

	addEventHandler("onPlayerGuestButton", root, Login.guestButtonHandler)
  
end
addEvent("onShowLogin")
addEventHandler("onShowLogin", root, Login.create)

function Login.browserCreated()
	
	loadBrowserURL(source, Login.url)
	
end
addEventHandler("onClientBrowserCreated", guiGetBrowser(Login.browser), Login.browserCreated)

function Login.guestButtonHandler()

	triggerServerEvent("onGuest", localPlayer)

end
addEvent("onPlayerGuestButton")

The handler is later removed again in another function.

Link to comment

 

10 hours ago, Jusonex said:

Could you show me the Lua code where you register the event that is triggered from Javascript and the guiCreateBrowser/createBrowser call?

E.g.:


local browser = createBrowser(...)addEventHandler("eventCalledFromJS", browser,    function()        -- ...    end)

 

local page = "http://mta/local/index.html"
local screenWidth, screenHeight = guiGetScreenSize()

initBrowser = guiCreateBrowser(0, 0, screenWidth, screenHeight, true, true, false)
theBrowser = guiGetBrowser(initBrowser)
addEventHandler("onClientBrowserCreated", theBrowser, function()
loadBrowserURL(source, page)
guiSetInputEnabled(true)
sound = playSound("files/login.mp3", true)
setSoundVolume(sound, 0.8)
addNotification("Please login or create a new account!", "info")
end )

 

client - be triggered from js:

function clientClickLogin (user, pass, rem)
playSound( "files/click.mp3" )
if user and pass then
	if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then
		if ( string.find ( user, '%s' ) ) then
		return addNotification ( "Spaces (' ') are not allowed in the username.", "error" )
		elseif ( string.find ( pass, '%s' ) ) then
		return addNotification ( "Spaces (' ') are not allowed in the password.", "error" )
		end
		rem = tonumber(rem)
	if rem == 1 then
	data.remember.clicked = true
	elseif rem == 2 then
	data.remember.clicked = false
	end
	triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass )
	clicked = true
	else
	addNotification("A Username And Password Are Required To Access The Server.", "warning")
	end
else
addNotification("A Username And Password Are Required To Access The Server.", "warning")
end
end
addEvent("clientClickLoginEvent", true)
addEventHandler("clientClickLoginEvent", root, clientClickLogin)

 

js:

function loginTrigger() {
var UsernameValue = $( "#UserLogin" ).val();
var PasswordValue = $( "#PasswordLogin" ).val();
if(document.getElementById("rememberme").checked) {
mta.triggerEvent("clientClickLoginEvent", UsernameValue, PasswordValue, 1)
}else {
mta.triggerEvent("clientClickLoginEvent", UsernameValue, PasswordValue, 2)
}

}

 

html:

<form action="javascript:loginTrigger()" method="post">
    	<input id="UserLogin" type="text" name="u" placeholder="Username" required="required" />
        <input id="PasswordLogin" type="password" name="p" placeholder="Password" required="required" />
		<input id="rememberme" type="checkbox" /><img class="remember" src="files/remember.png" />
        <button type="submit" class="btn btn-primary btn-block btn-large">Login</button>
		
    </form>

 

Edited by rouzbeh_TopGTA
Link to comment
  • Recently Browsing   0 members

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