well basically i cant get this to do as i need it to....
[lua]
http.Get("http://127.0.0.1/test.txt", "", function(contents, size)
print("File is "..size..",\n"..contents)
end)
[/lua]
well this works fine, but if i try this below it doesn't
[lua]
function test()
http.Get("http://127.0.0.1/test.txt", "", function(contents, size)
print("File is "..size..",\n"..contents)
end)
end
concommand.Add("testing", test)
[/lua]
can someone explain me why it doesn't work, or what i did wrong?
How does it not work?
well ive type in the console command, and nothing happens(and it doesnt say unnknown command ofc)
[editline]05:13PM[/editline]
like as soon as i put it in a function it wont work
doesn't someone know how to do this?
[lua]
function test()
http.Get("http://127.0.0.1/test.txt", "", contentandsize())
end
concommand.Add("testing", test)
function contentandsize(contents, size)
print("File is "..size..",\n"..contents)
end
[/lua]
This could work.
[QUOTE=yoBrelliKX;16941661][lua]
function test()
http.Get("http://127.0.0.1/test.txt", "", contentandsize())
end
concommand.Add("testing", test)
function contentandsize(contents, size)
print("File is "..size..",\n"..contents)
end
[/lua]
This could work.[/QUOTE]
[lua]function test()
http.Get("http://127.0.0.1/test.txt", "", contentandsize)
end
concommand.Add("testing", test)
function contentandsize(contents, size)
print("File is "..size..",\n"..contents)
end[/lua]
Fixed and [b]probably[/b] won't make a difference.
well it doesnt really work, i have been looking at the wiki and stuff, but what ever i try, it just wont work. i can only gte it to execute when http.Get is outside a function
well, i have tied everything now. i guess its kinda impossible
It's not impossible. I use http.Get in a function. Here's a snippet
[code]
function RefreshList()
SongList = {}
MusicWindow:Clear()
MenuText:SetText("Refreshing...")
MusicWindow:AddLine("Refreshing List...")
http.Get("http://www.decrepitgaming.com/", "", function(Content)
for k,v in pairs(string.Explode("\n", Content)) do
local TempTable = {v}
end
end)
end
[/code]
Of course that right there wont work because I took out code. However, it works perfectly in a function. Not sure what you're doing wrong. Try getting a file from outside your localhost.
it doesnt matter about its outside localhost or inside, anyway thanks for your post, ill check if that works.
[editline]06:31PM[/editline]
doesnt work, i found a error though, i dont know how to fix, but its like this...
[lua]
function RefreshList()
print("Started")
http.Get("http://www.decrepitgaming.com/", "", function(Content)
print("I am In the Http connection function")
end)
print("Finnished")
end
concommand.Add("testing", RefreshList)
[/lua]
and yes the link works...
well as you see it should print...
started
I am In the Http connection function
finished
but it does only print
started
finished
i could really need some help with this
The only other thing I can think of is calling RefreshList in a seperate function. I don't call it directly from concommand.
ill try that
[editline]06:44PM[/editline]
That works just perfect, really thanks for your help.
Sorry, you need to Log In to post a reply to this thread.