• Print

Author Topic: Download files to clients  (Read 9 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Download files to clients
« on: November 23, 2006, 11:38:14 pm »
Here's some code I whipped up that can download ASCII files to clients:

Code: Lua
  1. function giveFile( userid, contents )
  2.         ULib.cexec( userid, "clear" )
  3.  
  4.         ULib.addTimer( 0.5, 1, function()
  5.                 local lines = ULib.explode( contents, "\r?\n" )
  6.                 for _, line in ipairs( lines ) do
  7.                         ULib.console( userid, line )
  8.                 end
  9.         end )
  10.  
  11.  
  12.         ULib.addTimer( 1.5, 1, function() -- Make sure it all gets through
  13.                 ULib.cexec( userid, "condump" )
  14.         end )
  15.  
  16.         ULib.addTimer( 2, 1, function() -- Make sure it all gets through
  17.                 ULib.console( userid, " _   _   _" )
  18.                 ULib.console( userid, "/|\\ /|\\ /|\\" )
  19.                 ULib.console( userid, " |   |   | " )
  20.                 ULib.console( userid, " |   |   | " )
  21.                 ULib.console( userid, " |   |   | " )
  22.                 ULib.console( userid, "The above line will tell you where the file you downloaded is saved." )
  23.                 ULib.tsay( userid, "Server has downloaded a file to your client! See console for more information." )
  24.         end )
  25. end

As you see, while it's pretty good at giving the file correctly, you have no control over the saving on client-side.
« Last Edit: November 24, 2006, 10:55:40 am by Megiddo »
Experiencing God's grace one day at a time.

  • Print