Jump to content
  • 0

Help me about Loadfile


BaldiGT

Question

Posted

how to make if the script file has been downloaded then the script can be run ... but if the script has not been downloaded then a special message will appear

testsssss

 

Pls help me about Loadfile

Sorry for my bad english

7 answers to this question

Recommended Posts

Posted
4 hours ago, saiaapiz said:

--In case of errors, loadfile returns nil
local chunk = loadfile("")
if chunk == nil then gg.alert("LoadFile Error !") os.exit() end

References: https://www.lua.org/pil/8.html

Can u give me an example?

ill learn more with the example..

Posted
16 hours ago, BaldiGT said:

how to make if the script file has been downloaded then the script can be run ... but if the script has not been downloaded then a special message will appear

testsssss

 

Pls help me about Loadfile

Sorry for my bad english

@Enyby pls help me

Posted
18 hours ago, BaldiGT said:

how to make if the script file has been downloaded then the script can be run ... but if the script has not been downloaded then a special message will appear

testsssss

 

Pls help me about Loadfile

Sorry for my bad english

local chunk = loadfile("/storage/emulated/0/Download/HACK lock.txt")
if not chunk then
  gg.alert("The Script Is Not Found...Make Sure To Download The Script")
  os.exit()
else
  chunk()
end

 

Posted
11 minutes ago, Revoxtical said:

local chunk = loadfile("/storage/emulated/0/Download/HACK lock.txt")
if not chunk then
  gg.alert("The Script Is Not Found...Make Sure To Download The Script")
  os.exit()
else
  chunk()
end

 

Screenshot_20181209-174334.thumb.png.a14f059ad78708bcdbda63432a19e05c.png

Posted

Based on your solution analysis:

local chunk = loadfile("/storage/emulated/0/Download/HACK lock .txt")() -- Do not directly execute chunk, You doesn't know what loadfile return.
if chunk == nil then -- Useless check !
	gg.alert("The Script Is Not Found...Make Sure To Download The Script")
	os.exit()
end
gg.processResume()

This is my solution:

local chunk = loadfile("<PATH TO SCRIPT>")
-- incase of error, loadfile return nil
if chunk == nil then
	gg.alert("Error occured when loading script !")
	os.exit()
end
chunk() --No error occured !, load script Yeahhh !

gg.processResume()

 

Fixed script: testsssss

Posted
19 hours ago, saiaapiz said:

Based on your solution analysis:


local chunk = loadfile("/storage/emulated/0/Download/HACK lock .txt")() -- Do not directly execute chunk, You doesn't know what loadfile return.
if chunk == nil then -- Useless check !
	gg.alert("The Script Is Not Found...Make Sure To Download The Script")
	os.exit()
end
gg.processResume()

This is my solution:


local chunk = loadfile("<PATH TO SCRIPT>")
-- incase of error, loadfile return nil
if chunk == nil then
	gg.alert("Error occured when loading script !")
	os.exit()
end
chunk() --No error occured !, load script Yeahhh !

gg.processResume()

 

Fixed script: testsssss

Not work bro....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.