THREAD: File Downloader Code (For SPRX)
  1. 07-24-2017, 10:30 PM
    Tustin's Avatar
    Tustin
    Balls of Steel
    Tustin's Avatar
    Tustin
    Balls of Steel
    5,462
    Posts
    310,646
    Reputation
    May 2008
    NextGenUpdate
    I wrote this code with the intention of making a auto updater for Lexicon a while back but ran into problems with file permissions so it was never used. Figured someone here could find it useful for something. You need to add this code to your sprx project, and then create a listening server in whatever language you want to serve the file.


    C++ code: (I can't remember if the progress bar thing worked properly or not)



    Server code (written in PHP =Z):



    This is a basic example that will help you get started. Although if you want to modify this any further you probably want to do some research on socket programming before messing with this.
    Last edited by Tustin ; 07-24-2017 at 10:34 PM.

  2. The Following 2 Users Say Thank You to Tustin For This Useful Post:

    ,

  3. 08-01-2017, 03:30 PM
    PhucedMODZ's Avatar
    PhucedMODZ
    Do a barrel roll!
    PhucedMODZ's Avatar
    PhucedMODZ
    Do a barrel roll!
    122
    Posts
    214
    Reputation
    Jul 2016
    NextGenUpdate
    Originally Posted by Tustin View Post
    I wrote this code with the intention of making a auto updater for Lexicon a while back but ran into problems with file permissions so it was never used. Figured someone here could find it useful for something. You need to add this code to your sprx project, and then create a listening server in whatever language you want to serve the file.


    C++ code: (I can't remember if the progress bar thing worked properly or not)



    Server code (written in PHP =Z):



    This is a basic example that will help you get started. Although if you want to modify this any further you probably want to do some research on socket programming before messing with this.


    nice work tustin, nice to see something new
  4. 08-01-2017, 05:51 PM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Originally Posted by Tustin View Post
    Sorry, ignore what I said about the response header/body. For some reason when I replied earlier I was thinking this was using HTTP requests. The buffer size should be a length of bytes you're comfortable storing at one time. Setting it to 1024 (or 1 KB) should be sufficient. That basically means the socket will read 1 KB of your file each time and store that in the file.


    Mmmh, when i put the function in prx.cpp in int main() like this > You must login or register to view this content.
    I launch my game, and the game freez (i lokked the GTA;sprx placed in tmp, and it's blank. 0Ko). Where i must put the function DownloadFile in my sprx ?
    Last edited by Smoulougde ; 08-01-2017 at 06:43 PM.

  5. 08-01-2017, 08:20 PM
    Tustin's Avatar
    Tustin
    Balls of Steel
    Tustin's Avatar
    Tustin
    Balls of Steel
    5,462
    Posts
    310,646
    Reputation
    May 2008
    NextGenUpdate
    Originally Posted by Smoulougde View Post
    Mmmh, when i put the function in prx.cpp in int main() like this > You must login or register to view this content.
    I launch my game, and the game freez (i lokked the GTA;sprx placed in tmp, and it's blank. 0Ko). Where i must put the function DownloadFile in my sprx ?

    I'm pretty sure you need to create a separate thread to be able to use sockets. If you do that and it still freezes, make sure the port is correct on both your server and your client. Also make sure that the port is open on your server and that there isn't a firewall blocking it. Although keep in mind that trying to overwrite a sprx might not work for you as that's the problem I had with this code. I couldn't give my SPRX permissions to delete/rename other SPRX files for some reason so overwriting your current one might not work either.
  6. 08-01-2017, 09:13 PM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Originally Posted by Tustin View Post
    I'm pretty sure you need to create a separate thread to be able to use sockets. If you do that and it still freezes, make sure the port is correct on both your server and your client. Also make sure that the port is open on your server and that there isn't a firewall blocking it. Although keep in mind that trying to overwrite a sprx might not work for you as that's the problem I had with this code. I couldn't give my SPRX permissions to delete/rename other SPRX files for some reason so overwriting your current one might not work either.


    Ok I understand, but for example I can download a .txt file from the site and write it without permission problem as it is not an SPRX, if I understand well, the only worry is the fact that it is a SPRX so i need one function/bypass for erase the SPRX, right ?
  7. 08-01-2017, 09:16 PM
    Tustin's Avatar
    Tustin
    Balls of Steel
    Tustin's Avatar
    Tustin
    Balls of Steel
    5,462
    Posts
    310,646
    Reputation
    May 2008
    NextGenUpdate
    Originally Posted by Smoulougde View Post
    Ok I understand, but for example I can download a .txt file from the site and write it without permission problem as it is not an SPRX, if I understand well, the only worry is the fact that it is a SPRX so i need one function/bypass for erase the SPRX, right ?

    Yes exactly. You could use this for a menu configuration system or something like that. The error I was running into: You must login or register to view this content.. I explained in that thread of a way around it but it's not an automatic solution.
  8. 08-01-2017, 11:20 PM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Originally Posted by Tustin View Post
    Yes exactly. You could use this for a menu configuration system or something like that. The error I was running into: You must login or register to view this content.. I explained in that thread of a way around it but it's not an automatic solution.


    Ok i see, i will try with .ini / txt files for see if my coding is good or not Winky Winky
    Else i asked a gopro if he knows something about this, because (i'm not sure) but in his sprx for gta5, there is an auto updater.
  9. 08-19-2017, 05:57 PM
    45
    Posts
    311
    Reputation
    Jul 2016
    NextGenUpdate
    Originally Posted by Tustin View Post
    I'm pretty sure you need to create a separate thread to be able to use sockets. If you do that and it still freezes, make sure the port is correct on both your server and your client. Also make sure that the port is open on your server and that there isn't a firewall blocking it. Although keep in mind that trying to overwrite a sprx might not work for you as that's the problem I had with this code. I couldn't give my SPRX permissions to delete/rename other SPRX files for some reason so overwriting your current one might not work either.


    just chmod 777 your sprx with a C++ code ? Smile
  10. 08-19-2017, 06:53 PM
    Tustin's Avatar
    Tustin
    Balls of Steel
    Tustin's Avatar
    Tustin
    Balls of Steel
    5,462
    Posts
    310,646
    Reputation
    May 2008
    NextGenUpdate
    Originally Posted by LAN View Post
    just chmod 777 your sprx with a C++ code ? Smile

    Tried it and it gave the same error I got when I tried unlinking the sprx too.
  11. 08-20-2017, 12:55 AM
    Tustin's Avatar
    Tustin
    Balls of Steel
    Tustin's Avatar
    Tustin
    Balls of Steel
    5,462
    Posts
    310,646
    Reputation
    May 2008
    NextGenUpdate
    Originally Posted by NoRecess View Post
    Wasn't this on the limbo menu a few years ago?

    I'm not totally sure what the Limo menu is