brksc Posted February 15, 2019 Share Posted February 15, 2019 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 Link to comment
iDannz [Breno] Posted February 15, 2019 Share Posted February 15, 2019 try to change resourceRoot to root in onClientResourceStart event Link to comment
Moderators Patrick Posted February 15, 2019 Moderators Share Posted February 15, 2019 (edited) 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 February 15, 2019 by stPatrick Link to comment
koragg Posted February 15, 2019 Share Posted February 15, 2019 (edited) You can put a: if isTimer(check) then killTimer(check) end after line 13 and before line 14. Edited February 15, 2019 by koragg Link to comment
Moderators Patrick Posted February 15, 2019 Moderators Share Posted February 15, 2019 (edited) 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 February 15, 2019 by stPatrick 1 Link to comment
brksc Posted February 15, 2019 Author Share Posted February 15, 2019 (edited) 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 February 15, 2019 by brksc Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now