Jump to content

[Help] Using downloaded files in game


pro-mos

Recommended Posts

Posted

My script downloads files on the player's pc as he play

script/cache/water.fx
script/cache/wrap.txd

So when i try to use these files client side with

-- egineLoadtxd
-- and/or
dxCreateShader('cache/water.fx')

It doesn't work, with a warning like file not found.
Do i have to include downloaded files to the meta.xml?

Posted
9 minutes ago, xyzii said:

Yes, use <file src="filename.type"/> in meta

But how? These files doesn't exist on starting the script, but they're downloaded when a new map starts.

You see im trying to do a script loader

Posted
11 minutes ago, MIKI785 said:

Obviously you have to finish downloading them before you run the dx functions. How do you actually download them?

the server sends the file data and i write them client side with

fileCreate('cache/'..filename)

after creating and writing the file, i try to load it right away.

Posted

Might be a stupid question but do you use fileClose first? it should work otherwise, i guess you're using trigger(Latent)ClientEvent, right? In that case it shouldn't be able to get corrupted either. Show me how you load the files and send them on the server.

Posted (edited)

i use triggerClientEvent to send the files, and i write them with fileWrite, and then close the files with fileClose, the files are fine, i can see them downloaded in deathmatch/resources/script/cache/water.fx

i think it might be a file path error, since im getting confused of how MTA's file path works

EDIT: i've found the problem was the files download with a script and i try to use them with another script.. i've added ':scriptname' to the file path and now it works, sorry for your time.

Edited by pro-mos
Posted

Ok then. But just a bit of advice, dont use triggerClientEvent to transfer large amount of data as it could stall the server. Use triggerLatentClientEvent instead.

  • Like 1
Posted
4 hours ago, MIKI785 said:

Ok then. But just a bit of advice, dont use triggerClientEvent to transfer large amount of data as it could stall the server. Use triggerLatentClientEvent instead.

i tried this latent event now, and it seems a lot slower than the normal triggerClientEvent, i've tested it on local server

Posted (edited)

That's intentional, but you're able to change the maximum transfer rate using the bandwidth argument. So if your server has a good connection you can increase it.

Edited by MIKI785
  • Like 1

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