MrCode Posted Tuesday at 11:30 Share Posted Tuesday at 11:30 (edited) Good day, What is the best way to check if a or (any) file actually exists while using onClientRender? I'm using onClientRender to draw a PNG image located in another resource but if the image is missing (not yet downloaded by the client), then still, debug would output an error message. "Error loading image @ 'dxDrawImage' [:resource2/images/image.png]" To avoid that, should the file path become some type of local variable or? I'm not sure because I've tried a bunch of different ways and each of them have the same result. -- resource1: onClientRender if fileExists ( ":resource2/images/image.png" ) then dxDrawImage ( sx, sy, 32, 32, ":resource2/images/image.png" ) end -- Debug: { Error loading image @ 'dxDrawImage' [:resource2/images/image.png] } (x1) Edited Tuesday at 18:04 by MrCode Incorrect info Link to comment
Emnadai Posted Tuesday at 17:15 Share Posted Tuesday at 17:15 (edited) check the meta.xml of resource2 Edited Tuesday at 17:15 by Emnadai Link to comment
MrCode Posted Tuesday at 18:10 Author Share Posted Tuesday at 18:10 Sorry, I wrote the wrong debug output. The actual error is: Error loading image @ 'dxDrawImage' [:resource2/images/image.png] The PNG file in resource2 does indeed exist in the meta.xml, everything is in order with the path and the image does render normal. It just briefly outputs an error before it renders. It's like fileExists returns true while there is a (clear path to image.png), then when using dxDrawImage it has problems loading the image because the image.png itself is not yet recognized as a PNG file by the MTA client. So perhaps fileExists being used onClientRender is a bad move.. Link to comment
Moderators IIYAMA Posted 7 hours ago Moderators Share Posted 7 hours ago On 21/01/2025 at 19:10, MrCode said: So perhaps fileExists being used onClientRender I wouldn't run that function either in combination with onClientRender. Since you are fetching the file from another resource, you could increase or decrease the download priority for either resource. https://wiki.multitheftauto.com/wiki/Meta.xml Or just wait a little bit longer before start rendering. (I also recommend to convert the image into a texture before rendering) 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