Jump to content

loadfile question


John Smith

Recommended Posts

hey guys umm i have noticed something

if i make a script(lets say client sided)

in meta i put cache to false and download option to false as well so it doesn't download by in-built mta downloader

if i got another file in meta which gets downloaded normally by in-built mta downloader

and it has only this code

loadfile("client1.lua")

it will execute the script content of client1.lua file

however,this seems to be too easy to make so i wanted to ask couple of questions.

could scripts be downloaded like this?

if script size would somehow be 10 mb, what would be happening when loadfile function would be initiated?

would it execute the code as its being downloaded or would it execute code after it has been downloaded?

edit: just one more thing, would this thing be downloaded by mta downloader even tho download option is 'false', or would this thing turn into "custom downloading file" ?

Link to comment
You didn't even manage to detect a colshape hit :P

Keep in mind you can't unload a script file that easy, except with restarting the resource.

about colshape:

i have asked for help, i didn't get any reply to it, and i basically have no idea what to do there

and about this,i was planning to make scripts which wouldnt even need to be shut down cuz they would be finished already

however would this function load/download that client1.lua file on custom way, or with mta downloader?i might use this, so im curious

edit: also about unloading:

i could write a script like this instead of just only loadfile function

  
local client1 = assert(loadfile("client1.lua")) 
  
function teee() 
if client1 then 
-- umm nothing,client1 exists 
else 
error("no client1") 
end 
end 
  
function tat() 
teee() 
end 
addCommandHandler("fileload",tat) 
  
function notat() 
client1 = nil 
teee() 
end 
addCommandHandler("nofileload",notat) 
  

it should give an error and stop the loadfile script

aaaalsoo.. why would i even need to unload the script anyway?if i wouldnt need it i would just stop it, and it would stop fine without needing to make any more useless lines

Link to comment
Why don't you try yourself?

because i dont have a hosted server so even 100 gigabyte file would be loaded in 1 second for me and i wouldnt be able to see which kind of download/load would that be

and if someone already knows the answer to my question, it would be easier for me just for him to post the answer

Link to comment

'loadfile' doesn't download any files. 'loadfile' loads the specified file as a function and returns it. It doesn't even work in MTA, it's disabled for security reasons because it loads the file from any specified path, not limiting it to resources directory. Instead, MTA file functions have to be used to read the contents of file into the string and load them as a function using 'loadstring'.

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