Jump to content

Meu sistema não está fechando, Oque pode ser?


Recommended Posts

Salve Guys blz? bom manos estou tento problemas com esse meu "sistema de tela de download" bom ele está funcionando mas quando um player termina o download o script continua rodando como posso remove-lo assim que o usuario terminar o download? 

local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser)


addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

addEventHandler("onClientResourceStart", getResourceRootElement(), showPreload);



function renderLoaldLogin()
	if getElementData(getLocalPlayer(),"load_notLogin") then
		if isTransferBoxActive() then return end
		setElementData(getLocalPlayer(),"load_notLogin",false)
	    destroyElement(initBrowser)
		showCursor(false)
		browser = nil;
		initBrowser = nil;
		removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser);
		showChat(true)
	end
end
addEventHandler("onClientRender", root, renderLoaldLogin)













 

Edited by .Doctor
Link to comment

Reparei que tem 2 Eventos inúteis que não está sendo usado.

addEventHandler("onClientResourceStart", getResourceRootElement(), showPreload)
addEventHandler("onClientBrowserCreated", browser)

Você errou na hora de destruir o elemento gui. Pois tu não destruiu. Tente dessa forma.

local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

function renderLoaldLogin()
	if getElementData(getLocalPlayer(),"load_notLogin") then
		if isTransferBoxActive() then return end
		setElementData(getLocalPlayer(),"load_notLogin",false)
		initBrowser = nil;
	    destroyElement(initBrowser)
		showCursor(false)
		browser = nil;
		removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser);
		showChat(true)
	end
end
addEventHandler("onClientRender", root, renderLoaldLogin)


Foi útil meu comentário? Deixe o thanks :D 

  • Thanks 1
Link to comment
16 minutes ago, #DaNiLiN said:

Reparei que tem 2 Eventos inúteis que não está sendo usado.

addEventHandler("onClientResourceStart", getResourceRootElement(), showPreload)
addEventHandler("onClientBrowserCreated", browser)

Você errou na hora de destruir o elemento gui. Pois tu não destruiu. Tente dessa forma.


local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

function renderLoaldLogin()
	if getElementData(getLocalPlayer(),"load_notLogin") then
		if isTransferBoxActive() then return end
		setElementData(getLocalPlayer(),"load_notLogin",false)
		initBrowser = nil;
	    destroyElement(initBrowser)
		showCursor(false)
		browser = nil;
		removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser);
		showChat(true)
	end
end
addEventHandler("onClientRender", root, renderLoaldLogin)


Foi útil meu comentário? Deixe o thanks :D 

O Erro Continua :3  

 

 

 

local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

function renderLoaldLogin()
	if getElementData(getLocalPlayer(),"load_notLogin") then
		if isTransferBoxActive() then return end
		setElementData(getLocalPlayer(),"load_notLogin",false)
		initBrowser = nil;
	    destroyElement(initBrowser)
		showCursor(false)
		browser = nil;
		removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser);
		showChat(true)
	end
end
addEventHandler("onClientRender", root, renderLoaldLogin)

 

Link to comment

o Erro dai não e ali pois eu testei com um comando e funfou. 

function Remove ()
	setElementData(getLocalPlayer(),"load_notLogin",false)
	showCursor(false)
	showChat(true)
	initBrowser = nil
	browser = nil
	destroyElement(initBrowser)
	removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser)
end
addCommandHandler("b", Remove)


Leia também a função
IsTransferBoxActive
Acho que tu errou, Acho que não se deve usar onClientRender

  • Thanks 1
Link to comment
20 minutes ago, #DaNiLiN said:

o Erro dai não e ali pois eu testei com um comando e funfou. 


function Remove ()
	setElementData(getLocalPlayer(),"load_notLogin",false)
	showCursor(false)
	showChat(true)
	initBrowser = nil
	browser = nil
	destroyElement(initBrowser)
	removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser)
end
addCommandHandler("b", Remove)


Leia também a função
IsTransferBoxActive
Acho que tu errou, Acho que não se deve usar onClientRender

O erro persiste,  realmente nao é mais um erro pois li IsTransferBoxActive e agora apenas não desativa 

resourceRoot = getResourceRootElement()
local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)


end
)

function checkTransfer()
    if isTransferBoxActive() then
        setTimer(checkTransfer,2000) -- Check again after 2 seconds
    else 
        destroyElement(initBrowser) 
    end
end
addEventHandler("onClientResourceStart",resourceRoot,checkTransfer)

 

Link to comment

Seu seTimer está incompleto. 

resourceRoot = getResourceRootElement()
local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

function checkTransfer()
    if isTransferBoxActive() then
        setTimer(checkTransfer,2000, 1) -- Check again after 2 seconds
    else 
        destroyElement(initBrowser) 
		fadeCamera(true)
    end
end
addEventHandler("onClientResourceStart",resourceRoot,checkTransfer)

 

  • Thanks 1
Link to comment
1 hour ago, .Doctor said:

Salve Guys blz? bom manos estou tento problemas com esse meu "sistema de tela de download" bom ele está funcionando mas quando um player termina o download o script continua rodando como posso remove-lo assim que o usuario terminar o download? 


local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser)


addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

addEventHandler("onClientResourceStart", getResourceRootElement(), showPreload);



function renderLoaldLogin()
	if getElementData(getLocalPlayer(),"load_notLogin") then
		if isTransferBoxActive() then return end
		setElementData(getLocalPlayer(),"load_notLogin",false)
	    destroyElement(initBrowser)
		showCursor(false)
		browser = nil;
		initBrowser = nil;
		removeEventHandler("onClientBrowserCreated", getResourceRootElement(), browser);
		showChat(true)
	end
end
addEventHandler("onClientRender", root, renderLoaldLogin)













 

Só fazer uma função que remova esta "tela de carregamento", e exporta-la no script do painel de login.

  • Like 1
Link to comment
1 minute ago, Vazern said:

Só fazer uma função que remova esta "tela de carregamento", e exporta-la no script do painel de login.

Já Foi Resolvido!

4 minutes ago, #DaNiLiN said:

Seu seTimer está incompleto. 


resourceRoot = getResourceRootElement()
local sx, sy = guiGetScreenSize()
local link = "http://mta/n_Download/html/index.html"
local initBrowser = guiCreateBrowser(0, 0, sx, sy, true, false, false)
local browser = guiGetBrowser(initBrowser)
guiSetInputMode("no_binds_when_editing")

addEventHandler("onClientBrowserCreated", browser,
function ()
		fadeCamera(false,0)
		showCursor(true)
		loadBrowserURL(source, link)
end
)

function checkTransfer()
    if isTransferBoxActive() then
        setTimer(checkTransfer,2000, 1) -- Check again after 2 seconds
    else 
        destroyElement(initBrowser) 
		fadeCamera(true)
    end
end
addEventHandler("onClientResourceStart",resourceRoot,checkTransfer)

 

Thanks bb, ❤️

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