Fist Posted March 24, 2017 Share Posted March 24, 2017 as the title says, how can i make http file downloader that downloads file when they are needed in game not one after one but in exact moment when that model/file is going to be used and if client doesn't have it then downloader will download it for him? Link to comment
NeXuS™ Posted March 24, 2017 Share Posted March 24, 2017 You can use downloadFile for it. Link to comment
Fist Posted March 24, 2017 Author Share Posted March 24, 2017 2 hours ago, NeXuS™ said: You can use downloadFile for it. nice that's what i needed, but how can i detect if that exact object/car/item is in render distance and he has no model for it then only start downloading? Link to comment
NeXuS™ Posted March 24, 2017 Share Posted March 24, 2017 You'll have to set up each model which has to be downloaded, and check for every object/car/item if he moved from his old position, or just by passed time. Link to comment
Fist Posted March 24, 2017 Author Share Posted March 24, 2017 Just now, NeXuS™ said: You'll have to set up each model which has to be downloaded, and check for every object/car/item if he moved from his old position, or just by passed time. That sounds kinda wrong to me, isn't there easier way to do this? Also can this 'downlodFile' function download through http site? Link to comment
NeXuS™ Posted March 24, 2017 Share Posted March 24, 2017 You could just if that model's id has a file for it in the server's download directory. I dunno abait the HTTP download, you gotta test that yourself, but I don't think so. Link to comment
Syntrax# Posted March 24, 2017 Share Posted March 24, 2017 (edited) 6 minutes ago, Fist said: That sounds kinda wrong to me, isn't there easier way to do this? Also can this 'downlodFile' function download through http site? Fetchremote should get the data of it.use that with a callback to the download https://wiki.multitheftauto.com/wiki/FetchRemote Edited March 24, 2017 by Syntrax# 1 Link to comment
Fist Posted March 24, 2017 Author Share Posted March 24, 2017 6 minutes ago, Syntrax# said: Fetchremote should get the data of it.use that with a callback to the download https://wiki.multitheftauto.com/wiki/FetchRemote Ok this is what i needed, ty. But i still don't know how to check if vehicle/model is near client then only start downloading file. Link to comment
NeXuS™ Posted March 24, 2017 Share Posted March 24, 2017 Client side, dont even try this on server side. setTimer(function() for i, k in ipairs(getElementsByType("vehicle", getRootElement(), true)) do if downloadFile(getElementModel(k) .. ".txd") then outputChatBox("Updated a file. (MODEL ID: " .. getElementModel(k) .. ")") end end for i, k in ipairs(getElementsByType("object", getRootElement(), true)) do if downloadFile(getElementModel(k) .. ".txd") then outputChatBox("Updated a file. (MODEL ID: " .. getElementModel(k) .. ")") end end end, 5000, 0) Should work, not tested tho. 1 Link to comment
Syntrax# Posted March 24, 2017 Share Posted March 24, 2017 11 minutes ago, Fist said: Ok this is what i needed, ty. But i still don't know how to check if vehicle/model is near client then only start downloading file. setTimer( function() local x, y, z = getElementPosition(localPlayer) local models = getElementsByType("vehicle") if #models ~= 0 then for i, v in pairs(models) do if getElementModel(v) == 525 then --525 is just a random number, you can just add whatever you want, later i will make this into a table local ex, ey, ez = getElementPosition(v) local elementdistance = getDistanceBetweenPoints2D ( x, y, ex, ey ) if elementdistance <= 350 then outputDebugString("Download File") end end end end end, 500, 0) This will make the Client side check for any elements within this area and if the model id is the same.If both are true then it will trigger the download 1 Link to comment
Fist Posted March 24, 2017 Author Share Posted March 24, 2017 10 minutes ago, NeXuS™ said: Client side, dont even try this on server side. setTimer(function() for i, k in ipairs(getElementsByType("vehicle", getRootElement(), true)) do if downloadFile(getElementModel(k) .. ".txd") then outputChatBox("Updated a file. (MODEL ID: " .. getElementModel(k) .. ")") end end for i, k in ipairs(getElementsByType("object", getRootElement(), true)) do if downloadFile(getElementModel(k) .. ".txd") then outputChatBox("Updated a file. (MODEL ID: " .. getElementModel(k) .. ")") end end end, 5000, 0) Should work, not tested tho. lol i didn't know there is such variable as streamedin' for getlementsbytype, that will solve this problem. Thank you ! 7 minutes ago, Syntrax# said: setTimer( function() local x, y, z = getElementPosition(localPlayer) local models = getElementsByType("vehicle") if #models ~= 0 then for i, v in pairs(models) do if getElementModel(v) == 525 then --525 is just a random number, you can just add whatever you want, later i will make this into a table local ex, ey, ez = getElementPosition(v) local elementdistance = getDistanceBetweenPoints2D ( x, y, ex, ey ) if elementdistance <= 350 then outputDebugString("Download File") end end end end end, 500, 0) This will make the Client side check for any elements within this area and if the model id is the same.If both are true then it will trigger the download this is even better Thank you both! Link to comment
Syntrax# Posted March 24, 2017 Share Posted March 24, 2017 8 minutes ago, Fist said: lol i didn't know there is such variable as streamedin' for getlementsbytype, that will solve this problem. Thank you ! this is even better Thank you both! No problem but did it work like you wanted it to? Link to comment
Fist Posted March 24, 2017 Author Share Posted March 24, 2017 Just now, Syntrax# said: No problem but did it work like you wanted it to? haven't tested yet, was eating this whole time. haha Link to comment
Syntrax# Posted March 24, 2017 Share Posted March 24, 2017 lol But didn't test it so yeah, if there is a problem with it contact me i'll have a look on it. Link to comment
Fist Posted March 24, 2017 Author Share Posted March 24, 2017 6 minutes ago, Syntrax# said: lol But didn't test it so yeah, if there is a problem with it contact me i'll have a look on it. It does work, but how can i make that it doesn't download files from meta ? I tried deleting those meta files so they wouldn't download them but then it can't find file with downloadFile. Link to comment
Syntrax# Posted March 24, 2017 Share Posted March 24, 2017 Ehm gimme 10 mintues will be checking something around this. 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