Jump to content

I need help.


Michcio

Recommended Posts

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.

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

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