iDannz [Breno] Posted February 4, 2019 Share Posted February 4, 2019 (edited) Hello everyone, I'm having problems with this ... I have a DX panel, and the problem is this: Sometimes when the player is too long time on the server, or even randomly, the panel stops working due to the following warning: "WARNING: directory/client.lua: line xxx: Error loading image @dxDrawImage [:resourcename/folder/file.png " I do not consider myself to be a mta professional, but I'm also not a beginner, and I'm aware that this error happens when you try to display an image that does not exist in "meta.xml", for example. But in this case all images are listed perfectly within the "meta.xml" and within the client file that displays the images. Does anyone know what might be causing this? Remember that this is an intermittent error, that is, it happens in a random way, usually you connect, the panel is 100% normal, and as time passes the error occurs in several of the images, but also sometimes you already connect with the error. (It's happening in most of my resources that use dxDrawImage.) BUGGED: Spoiler http://prntscr.com/mgift6 NORMAL: Spoiler http://prntscr.com/mgigbv Edited February 4, 2019 by iDannz correct Link to comment
Feche1320 Posted February 4, 2019 Share Posted February 4, 2019 Without code it's too hard to guess Link to comment
iDannz [Breno] Posted February 4, 2019 Author Share Posted February 4, 2019 (edited) i use too many tables to do it, wait just a little --\\this is inside a for, and getImage is an userful function that takes the item name and returns the image filefrom other table --\\code in onclientrender to show image **** itens[indexSelected][pageSelected] is the name of item taken from other table. dxDrawImage (screenW *0.2000+i*screenW*0.0630, screenH * 0.31, screenW * 0.0615, screenH * 0.0917, getImage(itens[indexSelected][pageSelected][i])..'.png', 0, 0,0 ) --\\userful function getImage (used to return the filename using the itemname) function getImage(name) if not descricoes[name] then return 'imagens/error' end return 'imagens/'..descricoes[name].img end --\\ table descricoes. (used in getImage function) descricoes = { --// CRAFTING PAGE 1 \\-- ['Machado'] = {img = 'machado', desc = 'Usado para facilitar a coleta de madeira.'}, ['all the others items'] = {img = 'xxx', description = 'item description.'}, } Edited February 4, 2019 by iDannz Link to comment
Moderators IIYAMA Posted February 4, 2019 Moderators Share Posted February 4, 2019 (edited) If do not know why your error occur, it looks like you are drawing before the resource has been fully loaded. But you could try this: (untested, experimental code and overkill) do -- no errors when drawing without a given texture local dxDrawImage_ = dxDrawImage function dxDrawImage (...) if ({...})[5] then dxDrawImage_(...) end end end do local blackList = {} local nextTimeConvertToTexture = 0 function getImage(name) if not descricoes[name] then return nil end local texture = descricoes[name].texture if not texture then local timeNow = getTickCount() if timeNow > nextTimeConvertToTexture and not blackList[filePath] then local filePath = 'imagens/'..descricoes[name].img if fileExists(filePath) then texture = dxCreateTexture(filePath) descricoes[name].texture = texture nextTimeConvertToTexture = timeNow + (1000 / 60) -- convert at a MAX speed of 60 fps else blackList[filePath] = true end end end return texture end end It will also optimise your code in a later state of the game. (speed up drawing) Edited February 4, 2019 by IIYAMA Link to comment
Mr.Loki Posted February 4, 2019 Share Posted February 4, 2019 7 hours ago, iDannz said: "WARNING: directory/client.lua: line xxx: Error loading image @dxDrawImage [:resourcename/folder/file.png " This can also be caused when your client runs out of vmemory. make sure that you are cleaning up unused fonts, textures, render targets and shaders properly. To check your client memory use the /showmemstat command. Spam a few Windows and check to see if it depletes your memory each time it's opened. If the FreeForMTA number is too low functions like these stop working. Spoiler 1 Link to comment
iDannz [Breno] Posted February 5, 2019 Author Share Posted February 5, 2019 2 hours ago, IIYAMA said: If do not know why your error occur, it looks like you are drawing before the resource has been fully loaded. But you could try this: (untested, experimental code and overkill) do -- no errors when drawing without a given texture local dxDrawImage_ = dxDrawImage function dxDrawImage (...) if ({...})[5] then dxDrawImage_(...) end end end do local blackList = {} local nextTimeConvertToTexture = 0 function getImage(name) if not descricoes[name] then return nil end local texture = descricoes[name].texture if not texture then local timeNow = getTickCount() if timeNow > nextTimeConvertToTexture and not blackList[filePath] then local filePath = 'imagens/'..descricoes[name].img if fileExists(filePath) then texture = dxCreateTexture(filePath) descricoes[name].texture = texture nextTimeConvertToTexture = timeNow + (1000 / 60) -- convert at a MAX speed of 60 fps else blackList[filePath] = true end end end return texture end end It will also optimise your code in a later state of the game. (speed up drawing) its working so good, the only one problem is at the line 20, local filePath... the table returns the filename without the file extension, so i used filepath = 'imagens/'..descricoes[name]..'.png' and its working, thnx, but i dont know if the real problem is fixed too with dxCreateTexture 2 hours ago, Mr.Loki said: This can also be caused when your client runs out of vmemory. make sure that you are cleaning up unused fonts, textures, render targets and shaders properly. To check your client memory use the /showmemstat command. Spam a few Windows and check to see if it depletes your memory each time it's opened. If the FreeForMTA number is too low functions like these stop working. Reveal hidden contents Hi loki, how are u? i didnot know this command, so i didnt tested it when the error appears, but using the userful function from iiyama, the problem is fixed for now, but ill still here seeing the memstat, thnx so much bro. guys, im thinking here... the table is in an shared type archive, the problem could be here? 2 Link to comment
WorthlessCynomys Posted February 5, 2019 Share Posted February 5, 2019 5 hours ago, Mr.Loki said: This can also be caused when your client runs out of vmemory. make sure that you are cleaning up unused fonts, textures, render targets and shaders properly. To check your client memory use the /showmemstat command. Spam a few Windows and check to see if it depletes your memory each time it's opened. If the FreeForMTA number is too low functions like these stop working. Reveal hidden contents 6 years into MTA Scripting and just learned about showmemstat.. Thank you! I don't know if it's solved yet, but this could occur if you haven't refreshed your resource, or you could be missing the file extension. I mean it can be jpg while you try using PNG. Those are my guesses. Link to comment
iDannz [Breno] Posted February 5, 2019 Author Share Posted February 5, 2019 Hi bro, how are u? i think its already fixed, im using now dxCreateTexture, but i think the real problem was the getImage function (was inside an shared file) Link to comment
WorthlessCynomys Posted February 5, 2019 Share Posted February 5, 2019 2 minutes ago, iDannz said: Hi bro, how are u? i think its already fixed, im using now dxCreateTexture, but i think the real problem was the getImage function (was inside an shared file) Okay? Good to know! Thanks Link to comment
Moderators IIYAMA Posted February 5, 2019 Moderators Share Posted February 5, 2019 4 hours ago, iDannz said: but i dont know if the real problem is fixed too with dxCreateTexture If the issue is 100% related to what @Mr.Loki said. Then the texture will simply fail to load. Which shouldn't cause any laggy errors. Thought it might be a good idea to blacklist failed loaded textures as well or use a delay before retrying to load the texture. The main question is now "will textures use more or less vram incompare to file paths?" I can honestly can't awnser that. Technically textures would need more ram, as it is always in use. But drawing from path requires most likely a lot more cleaning, as I am not sure if it buffers those kinds of textures. If you really want to know that, then you only have to watch the free vram. Link to comment
iDannz [Breno] Posted February 5, 2019 Author Share Posted February 5, 2019 yeah, yesterday 10 players who was bugged earlier joined the server to help me to test, and nobody get the bug again xdxdxdxd im so happy now, thnx 1 Link to comment
Moderators IIYAMA Posted February 5, 2019 Moderators Share Posted February 5, 2019 4 hours ago, iDannz said: yeah, yesterday 10 players who was bugged earlier joined the server to help me to test, and nobody get the bug again xdxdxdxd im so happy now, thnx Cheers! 1 Link to comment
Discord Moderators Pirulax Posted February 6, 2019 Discord Moderators Share Posted February 6, 2019 Well, drawing from path is the same as creating the texture internally, just 6x slower. 1 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