Et-win Posted August 11, 2014 Share Posted August 11, 2014 *Cough* *Goes back to testing* Link to comment
Et-win Posted August 11, 2014 Share Posted August 11, 2014 (edited) Just scripted this for you (Tested and works): *Cut * Will test yours in a minute. Just scripted this to get to know how everything works. (I also was bored ) Edited August 13, 2014 by Guest Link to comment
Saml1er Posted August 11, 2014 Share Posted August 11, 2014 (edited) function createFile ( file ) local createdFile = fileCreate(file) if createdFile then fileWrite( createdFile,file) fileClose( createdFile) end end local resName = "YOURresourceName" if not fileExists(":"..resName.."/model.txd") then local file = fileOpen(":"..resName.."/model.txd",true) if file then local txdFile = fileRead ( file, fileGetSize(file) ) fileClose(file) createFile ( txdFile) end end Edited August 11, 2014 by Guest Link to comment
Et-win Posted August 11, 2014 Share Posted August 11, 2014 Found your problem: It just worked? Lol. And +1 @Saml1er Link to comment
Bonsai Posted August 11, 2014 Share Posted August 11, 2014 function createFile ( file ) local createdFile = fileCreate(file) if createdFile then fileWrite( createdFile,file) fileClose( createdFile) end end local resName = "YOURresourceName" if not fileExists(":"..resName.."/model.txd") then local file = fileOpen(":"..resName.."/model.txd",true) if file then local txdFile = fileRead ( file, fileGetSize(file) ) fileClose(file) createFile ( txdFile) end end Y U NO STAY ON TOPIC So, the problem was, there was no problem?! Link to comment
Et-win Posted August 11, 2014 Share Posted August 11, 2014 Probably the problem was only that the 'onClientRender' was not working how he wished. Ow and btw @Saml1er: That doesn't work, right? I mean. The files are server-sided, and you are now trying to load them client-sided? If so you will have to trigger from client to server, get the files and then trigger them back to client. Link to comment
Saml1er Posted August 11, 2014 Share Posted August 11, 2014 Probably the problem was only that the 'onClientRender' was not working how he wished.Ow and btw @Saml1er: That doesn't work, right? I mean. The files are server-sided, and you are now trying to load them client-sided? If so you will have to trigger from client to server, get the files and then trigger them back to client. Yes, you'll have to read those files from server side and send them back to client side. I did this in my lobby script and I had no problems with it. @Bons: I stole your idea http://imgur.com/Xkfhe8q Link to comment
Bonsai Posted August 11, 2014 Share Posted August 11, 2014 @Bons: I stole your idea http://imgur.com/Xkfhe8q Tss! Make them cirlced Link to comment
Saml1er Posted August 11, 2014 Share Posted August 11, 2014 @Bons: I stole your idea http://imgur.com/Xkfhe8q Tss! Make them cirlced These rectangles look really good when animating ( moving in a circular path ). Link to comment
John Smith Posted August 12, 2014 Author Share Posted August 12, 2014 i have used et-win's example(on page 2) as im not experienced with file functions and triggering events, but it doesn't work in bottom right corner i see downloading (0/2) but it isn't downloading and at line 67 it says file doesn't exist Link to comment
Et-win Posted August 12, 2014 Share Posted August 12, 2014 (edited) You have to change my files to your own files *Cut * You can enter it like this: *Cut * EDIT: You can put unlimited files. Edited August 13, 2014 by Guest Link to comment
John Smith Posted August 12, 2014 Author Share Posted August 12, 2014 ohhh i just noticed it now,i forgot to make it like /mods folder path thing,i forgot about that sorry. anyway could you just tell me 2 things? 1) what is this 3rd thing loadMod(tableData[1], tableData[2], tableData[3]) tableData is for downloadFiles table and there are 2 files only so why must there be a third one? or perhaps this is used because there are 3 arguments in loadMod function? 2) how could i exactly make more files? something like this? local downloadFiles = { {"txd", "hunter.txd", 425}, {"dff", "hunter.dff", 425}, {"txd1", "infernus.txd", 411}, {"dff1", "infernus.dff", 411}, } and it would work automatically or i have to add/edit some more things? sorry for much questions, i just wanna know 100% how this script works so i could edit it later if needed Link to comment
Et-win Posted August 12, 2014 Share Posted August 12, 2014 (edited) 1. *Cut * Hope that explanation was well enough to understand 2. And yes like that. The only thing you have to fill in: *Cut * You can the script even let read meta.xml and check for 'file' childs and then check or 'download' is set to false. And if so, get that file name and put it in a table. And yes, I like fully automatically systems. Edited August 13, 2014 by Guest Link to comment
John Smith Posted August 12, 2014 Author Share Posted August 12, 2014 et-win im sorry but i didnt quite understand what u meant about what i have to fill in if you have time, can you please please show me how this script(lines or full script) would look like if i had infernus in table with id 411 and then tried to check for it as well as checking for hunter file existance sry for my english.. Link to comment
Et-win Posted August 12, 2014 Share Posted August 12, 2014 (edited) Oops, I found a bug. It was loading the mods as soon as the player spawned everytime. Fixed: *Cut * Edited August 13, 2014 by Guest Link to comment
John Smith Posted August 12, 2014 Author Share Posted August 12, 2014 thank you very much! Link to comment
John Smith Posted August 16, 2014 Author Share Posted August 16, 2014 hey guys umm i have tried now to make downloader in other way, without downloadFile function(for lower mta versions) but i have no idea what i'm doing wrong --server dFiles = { {"test_server.lua"}, {"test_client.lua"}, } function someFileFunctionsFunction(thePlayer) outputChatBox("Function initiated!") for _,dFiles in ipairs(dFiles) do if not fileExists(":downloader/files/"..dFiles[1]) then outputChatBox("Starting the download process...",thePlayer,0,255,0) local files = fileOpen(":downloader/files/"..dFiles[1],true) if files then local downloadFiles = fileRead (file,fileGetSize(file)) fileClose(files) triggerClientEvent("onStartDownload",thePlayer,downloadFiles,files) end else outputChatBox("even tho its not possible that player has downloaded already, he has!") triggerClientEvent("onVehModRequest",thePlayer,"startMods") end end end addCommandHandler("download",someFileFunctionsFunction) --client addEvent("onStartDownload",true) function clientDownloaderFunction(downloadFiles,files) if fileExists(files) then fileCreate(files) fileWrite(files,downloadFiles) fileClose(files) outputChatBox("Download has been finished!",0,0,255) else outputChatBox("something went wrong") return end end addEventHandler("onStartDownload",root,clientDownloaderFunction) i dont have any errors except debug saying that onVehModRequest is not added client-side(as i didn't download files yet,should have been impossible to trigger that client function) i dont know what to do now. this isnt working, please help Link to comment
Bonsai Posted August 16, 2014 Share Posted August 16, 2014 Well, first of all, in line 9, what file are you checking to exist there? You can only check files on the server in a serverside script. Also, use latentEvent. This won't make everything laggy during download. Link to comment
John Smith Posted August 16, 2014 Author Share Posted August 16, 2014 Well, first of all, in line 9, what file are you checking to exist there? You can only check files on the server in a serverside script. Actually i wanted to replace table files with mod files which would load on client side,and im trying to download files which werent downloaded Link to comment
Bonsai Posted August 16, 2014 Share Posted August 16, 2014 So, when a player joins u send him a list with all file names. Client checks if they are existing (actually you would also need to do some hashing e.g., to prevent manipulations). Client adds all missing files to a table and sends it back to server. Server opens each of that files, reads the content and send it to client. Client creates that file and write the data into it. After that u can load the mod. Link to comment
John Smith Posted August 26, 2014 Author Share Posted August 26, 2014 (edited) i forgot to answer, thanks bonsai anyway about 1.4 version one i got this but it only works for me,other players cant see carmods..idk why pls help Edited October 13, 2014 by Guest Link to comment
John Smith Posted August 26, 2014 Author Share Posted August 26, 2014 hi guys sorry for doublepost. i have tried this: replacing this line if (source == getLocalPlayer()) then --line 60 with this for i,player in ipairs(getElementsByType("player")) do if player then -- line 61 would that work for other players too? please someone.. sorry if im asking for too much but im just trying to understand whats problem in script Link to comment
Et-win Posted August 26, 2014 Share Posted August 26, 2014 I made it like that, when a player spawns, that player gets the files. This only works 1 time. Resource needs to get restarted when you add more files. (Ofc.) Link to comment
John Smith Posted August 26, 2014 Author Share Posted August 26, 2014 Resource needs to get restarted when you add more files. (Ofc.) yeah but yesterday when other players killed themselves, the carmods didnt download for them at all and they seen default vehicles while when i'd kill myself i'd get the download text and download the mods 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