Sign in to follow this  
brksc

Help me with my download screen

Recommended Posts

function imagem()

    dxDrawImage(986, 269, 349, 197, ":scr_screenloader/img/background.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	
 end
addEventHandler("onClientRender", root, imagem)

function checkTransfer()    
    if isTransferBoxActive() == true then
        setTimer(checkTransfer,2000,1)
    else 
        removeEventHandler("onClientRender", root, imagem)
    end
end
addEventHandler("onClientResourceStart",resourceRoot,checkTransfer)
I need help with a script I'm trying to do, it's an image that stays open while downloading the resources and closes when the download is finished.

Obs: I already added as a goal, until I can make the image open but I can not make it close, with the code below it does not appear

Share this post


Link to post
Quote

onClientResourceStart


This event is triggered when a resource is started. (...) This means it is triggered when a clientside script is initiated after a download, which includes downloading after join.

You need to create a separeted resource, and make you sure this resource starts before all.

You can make it with <download_priority_group>. (Link: https://wiki.multitheftauto.com/wiki/Meta.xml)

 

So, here is the script:

-- CLIENT SIDE

local sx, sy = guiGetScreenSize()

function loadingScreen()
    dxDrawImage(0, 0, sx, sy, "loadingimage.png")
end

addEventHandler("onClientResourceStart", resourceRoot, function()
    addEventHandler("onClientRender", root, loadingScreen)

    local function check()
        if isTransferBoxActive() then
            setTimer(check, 1000, 1)
        else
            removeEventHandler("onClientRender", root, loadingScreen)
        end
    end
    setTimer(check, 1000, 1)
end)

 

And the meta:

-- META

<meta>
    <download_priority_group>10</download_priority_group> <!-- IMPORTANT -->

    <script src="client.lua" type="client"/>
    <file src="loadingimage.png"/>
</meta>

 

Edited by stPatrick

Share this post


Link to post

You can put a:

if isTimer(check) then
	killTimer(check)
end

after line 13 and before line 14.

Edited by koragg

Share this post


Link to post
31 minutes ago, koragg said:

You can put a:


if isTimer(check) then
	killTimer(check)
end

after line 13 and before line 14.

No killTimer needed, because the setTimer runs once.

(And the check is a function and not a timer)

Edited by stPatrick
  • Thanks 1

Share this post


Link to post
4 hours ago, stPatrick said:

 

 

4 hours ago, stPatrick said:

You need to create a separeted resource, and make you sure this resource starts before all.

You can make it with <download_priority_group>. (Link: https://wiki.multitheftauto.com/wiki/Meta.xml)

 

So, here is the script:


-- CLIENT SIDE

local sx, sy = guiGetScreenSize()

function loadingScreen()
    dxDrawImage(0, 0, sx, sy, "loadingimage.png")
end

addEventHandler("onClientResourceStart", resourceRoot, function()
    addEventHandler("onClientRender", root, loadingScreen)

    local function check()
        if isTransferBoxActive() then
            setTimer(check, 1000, 1)
        else
            removeEventHandler("onClientRender", root, loadingScreen)
        end
    end
    setTimer(check, 1000, 1)
end)

 

And the meta:


-- META

<meta>
    <download_priority_group>10</download_priority_group> <!-- IMPORTANT -->

    <script src="client.lua" type="client"/>
    <file src="loadingimage.png"/>
</meta>

 

 

Many thanks, now it worked ... I just have not understood how this SetTimer works yet

Edited by brksc

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.