Jump to content

Please Help Me Creating A Browser


Recommended Posts

Idk Why But this script is not working please correct it:

local browser
local browserVisible = false
local screenWidth, screenHeight = guiGetScreenSize()

function createYouTubeBrowser()
    -- Create the browser with a custom size and position
    local browserWidth, browserHeight = 800, 600
    local browserPosX, browserPosY = (screenWidth - browserWidth) / 2, (screenHeight - browserHeight) / 2
    browser = createBrowser(browserWidth, browserHeight, true, false)
    setBrowserProperty(browser, "scalable", "false")
    setBrowserProperty(browser, "movable", "true")

    -- Load the YouTube website
    loadBrowserURL(browser, "https://www.youtube.com")
end

function toggleYouTubeBrowser()
    if browserVisible then
        -- If the browser is already showing, hide it
        destroyElement(browser)
        browserVisible = false
    else
        -- If the browser is not showing, create it
        createYouTubeBrowser()
        browserVisible = true
    end
end

-- Bind the toggleYouTubeBrowser function to the F4 key
bindKey("F4", "down", toggleYouTubeBrowser)

This is AI generated script from Chat GPT btw The script is not working and showing no error in the console or in the debug please help

 

Link to comment

I haven't tested it, but it should work.

 

local screenWidth, screenHeight = guiGetScreenSize();

local isVisible = false;
local browser = false;

loadBrowser = function ()
    loadBrowserURL(source, "https://www.youtube.com");
end

addEventHandler("onClientResourceStart", resourceRoot, 
    function ()
        browser = createBrowser(screenWidth, screenHeight, true, true);
        
        if browser then
            addEventHandler("onClientBrowserCreated", browser, loadBrowser);
        end
    end);

toggleBrowser = function ()
	if isVisible then 
		isVisible = false;
		removeEventHandler("onClientRender", root, draw);
	else
		isVisible = true;
		addEventHandler("onClientRender", root, draw);
	end
end

draw = function ()
	local sx = 800;
	local sy = 600;

    local x = (screenWidth - sx) / 2;
    local y = (screenHeight - sy) / 2;

	dxDrawImage(x, y, sx, sy, browser);
end

bindKey("F4", "down", toggleBrowser);

 

Edited by klue
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...