Jump to content

I can't find the bug here


Sir.BEEF

Recommended Posts

Hello guys so i've been trying to fix that bug.

 

Please help me

local screenWidth, screenHeight = guiGetScreenSize(945, 736)
local webBrowser = createBrowser(945, 736, false, false)
	
function webBrowserRender()
	dxDrawImage(0, 0, 945, 736, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end

	addEventHandler("onClientRender",function ()
		loadBrowserURL(webBrowser, "http://www.youtube.com")

	end
)
addCommandHandler("youtube", function()
end
)

 

here's a screenshot where the bug is: 7QYZeoQ.png

Link to comment
10 minutes ago, koragg said:

addEventHandler ("onClientRender", root, function ()... )

Thanks, but i kind of :Oed up in the addcommandhandler,

so i was wondering how to fix it:

local screenWidth, screenHeight = guiGetScreenSize(945, 736)
local webBrowser = createBrowser(945, 736, false, false)
    
function webBrowserRender()
    dxDrawImage(0, 0, 945, 736, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end

        addEventHandler ("onClientRender", root, function ()
        loadBrowserURL(webBrowser, "http://www.youtube.com")

    end
)
 

the command should be /youtube 

which i thought it should be 

addCommandHandler ( "youtube", Youtube)
Link to comment
local screenWidth, screenHeight = guiGetScreenSize(945, 736)
local webBrowser = createBrowser(945, 736, false, false)

function createBrowser()
	loadBrowserURL(webBrowser, "http://www.youtube.com")
end
addEventHandler("onClientBrowserCreated", webBrowser, createBrowser)	

function webBrowserRender()
	dxDrawImage(0, 0, 945, 736, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end

function toggleBrowser()
	if isEventHandlerAdded("onClientRender", root, webBrowserRender) == false then
		addEventHandler("onClientRender", root, webBrowserRender)
	end
	if isEventHandlerAdded("onClientRender", root, webBrowserRender) == true then
		removeEventHandler("onClientRender", root, webBrowserRender)
	end
end
addCommandHandler("youtube", webBrowserRender)

function isEventHandlerAdded(sEventName, pElementAttachedTo, func)
 if type(sEventName) == 'string' and
  isElement(pElementAttachedTo) and
  type(func) == 'function'
 then
  local aAttachedFunctions = getEventHandlers(sEventName, pElementAttachedTo)
  if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then
   for i, v in ipairs(aAttachedFunctions) do
    if v == func then
     return true
    end
   end
  end
 end
 return false
end

I'm not sure if you can give arguments to 'guiGetScreenSize' though.

  • Like 1
Link to comment
15 minutes ago, koragg said:

local screenWidth, screenHeight = guiGetScreenSize(945, 736)
local webBrowser = createBrowser(945, 736, false, false)

function createBrowser()
	loadBrowserURL(webBrowser, "http://www.youtube.com")
end
addEventHandler("onClientBrowserCreated", webBrowser, createBrowser)	

function webBrowserRender()
	dxDrawImage(0, 0, 945, 736, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end

function toggleBrowser()
	if isEventHandlerAdded("onClientRender", root, webBrowserRender) == false then
		addEventHandler("onClientRender", root, webBrowserRender)
	end
	if isEventHandlerAdded("onClientRender", root, webBrowserRender) == true then
		removeEventHandler("onClientRender", root, webBrowserRender)
	end
end
addCommandHandler("youtube", webBrowserRender)

function isEventHandlerAdded(sEventName, pElementAttachedTo, func)
 if type(sEventName) == 'string' and
  isElement(pElementAttachedTo) and
  type(func) == 'function'
 then
  local aAttachedFunctions = getEventHandlers(sEventName, pElementAttachedTo)
  if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then
   for i, v in ipairs(aAttachedFunctions) do
    if v == func then
     return true
    end
   end
  end
 end
 return false
end

I'm not sure if you can give arguments to 'guiGetScreenSize' though.

idk how to fix that but it's instantly closing @koragg

Edited by Sir.BEEF
Link to comment

Hmmm... it should've worked. Try this example from the wiki (without changing anything, just to test if it works and if you get errors):

-- In order to render the browser on the full screen, we need to know the dimensions.
local screenWidth, screenHeight = guiGetScreenSize()

-- Let's create a new browser in local mode. We will not be able to load an external URL.
local webBrowser = createBrowser(screenWidth, screenHeight, false, false)
	
-- This is the function to render the browser.
function webBrowserRender()
	-- Render the browser on the full size of the screen.
	dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end

-- The event onClientBrowserCreated will be triggered, after the browser has been initialized.
-- After this event has been triggered, we will be able to load our URL and start drawing.
addEventHandler("onClientBrowserCreated", webBrowser, 
	function()
		-- After the browser has been initialized, we can load our website.
		loadBrowserURL(webBrowser, "https://www.youtube.com/")

		-- Now we can start to render the browser.
		addEventHandler("onClientRender", root, webBrowserRender)
	end
)

 

Link to comment
local screenWidth, screenHeight = guiGetScreenSize()
local webBrowser = nil
local visible = false 

function webBrowserRender()
    if visible then
		dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
	end
end
addEventHandler("onClientRender", root, webBrowserRender)

addEventHandler("onClientBrowserCreated", webBrowser, 
function()
	loadBrowserURL(webBrowser, "http://www.youtube.com")
end)

addCommandHandler("youtube",function()
    visible = not visible
	webBrowser = createBrowser(screenWidth, screenHeight, false, false)
    showCursor(visible)
end)

This would fix your problem :)

 

  • Like 1
Link to comment
1 hour ago, Ayush Rathore said:

local screenWidth, screenHeight = guiGetScreenSize()
local webBrowser = nil
local visible = false 

function webBrowserRender()
    if visible then
		dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
	end
end
addEventHandler("onClientRender", root, webBrowserRender)

addEventHandler("onClientBrowserCreated", webBrowser, 
function()
	loadBrowserURL(webBrowser, "http://www.youtube.com")
end)

addCommandHandler("youtube",function()
    visible = not visible
	webBrowser = createBrowser(screenWidth, screenHeight, false, false)
    showCursor(visible)
end)

This would fix your problem :)

 

this isn't working.

please help me guys

????????

16 minutes ago, Sir.BEEF said:

this isn't working.

please help me guys

????????

kkkk

Link to comment
23 hours ago, Sir.BEEF said:

this isn't working.

please help me guys

????????

kkkk

my bad ;) sorry try this 

local screenWidth, screenHeight = guiGetScreenSize()
local visible = false 
local window = nil
local browser = nil
local theBrowser = nil


addCommandHandler("youtube",function()
    visible = not visible
	if visible == true then
	window = guiCreateWindow( (screenWidth-800)/2 , (screenHeight-600)/2, 800, 600, "Web Browser", false )
	browser = guiCreateBrowser( 0, 28, 800, 600, false, false, false, window )
	theBrowser = guiGetBrowser( browser )
	addEventHandler("onClientBrowserCreated", theBrowser, 
	function()
		loadBrowserURL(source, "http://www.youtube.com")
	end)
	elseif visible == false then
		destroyElement(browser)
		destroyElement(window)
		browser = nil
      	window = nil
		theBrowser = nil
	end
    showCursor(visible)	
end)

if you like my work please like and follow me :) happy scripting :):D .

Edited by Ayush Rathore
  • Like 1
Link to comment
2 hours ago, Ayush Rathore said:

my bad ;) sorry try this 


local screenWidth, screenHeight = guiGetScreenSize()
local visible = false 
local window = nil
local browser = nil
local theBrowser = nil


addCommandHandler("youtube",function()
    visible = not visible
	if visible == true then
	window = guiCreateWindow( (screenWidth-800)/2 , (screenHeight-600)/2, 800, 600, "Web Browser", false )
	browser = guiCreateBrowser( 0, 28, 800, 600, false, false, false, window )
	theBrowser = guiGetBrowser( browser )
	addEventHandler("onClientBrowserCreated", theBrowser, 
	function()
		loadBrowserURL(source, "http://www.youtube.com")
	end)
	elseif visible == false then
		destroyElement(browser)
		destroyElement(window)
		browser = nil
      	window = nil
		theBrowser = nil
	end
    showCursor(visible)	
end)

if you like my work please like and follow me :) happy scripting :):D .

Thanks for your help, add me on skype: saiframahi.

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