Michcio Posted November 24, 2012 Share Posted November 24, 2012 Hi! I want to do a dxtext when player download resources on join. What events should I use? Link to comment
uhm Posted November 24, 2012 Share Posted November 24, 2012 I tried this a while back, but back then it wasn't possible because the MTA client starts running the client scripts only after every single resource has downloaded. Alternatively you can use server side functions to write text: Read more on Wiki Link to comment
Michcio Posted November 24, 2012 Author Share Posted November 24, 2012 Thanks for help. I will try. Link to comment
Anderl Posted November 24, 2012 Share Posted November 24, 2012 Alternatively, you could make a custom "downloader" and use loadstring to load your code instantly so you don't need neither to wait download to end or to have to do all that with server-side text functions. Link to comment
uhm Posted November 24, 2012 Share Posted November 24, 2012 Ah, that's fantastic! +1 For anyone else: loadstring is a native LUA function, so it's not documented on the MTA wiki. It also takes files as parameter, making it perfect to use in the way Anderl described. I'm guessing it'll need downloadFile though, available from 1.4 onward. Link to comment
Anderl Posted November 24, 2012 Share Posted November 24, 2012 Ah, that's fantastic! +1For anyone else: loadstring is a native LUA function, so it's not documented on the MTA wiki. It also takes files as parameter, making it perfect to use in the way Anderl described. I'm guessing it'll need downloadFile though, available from 1.4 onward. It doesn't take file as a parameter, it takes a string with a code. http://pgl.yoyo.org/luai/i/loadstring Example ( this example only works in any software with default Lua package ( e.g. Lua interpreter that comes with Lua for Windows ): local luaf = io.open( "file.lua", "r" ); -- this opens a file with read permissions assert( luaf, "blabla lua file not loaded" ); loadstring( luaf:read( "*all" ) )(); -- loads the code that is read from the file --now tries to call a function from that file if (initSomethingElse()) then print( "Yes, it did work." ) end And for MTA:SA, no, you don't need any download function. Just use file functions. Of course, to do that you need to make sure everything that everything the client-side file needs is already downloaded ( all that can be easily programmed not to be downloaded, and I mean it gets loaded/the client receives the file but without actually downloading the file ). 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