Advertisement
CrosRoad95

onTransferBoxStateChange

Nov 19th, 2017
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local started=false
  2.  
  3. addEventHandler ( "onTransferBoxStateChange", localPlayer,function(current,total)
  4.   cancelEvent() -- disable current transfer box
  5.   if(not previous or previous~=current)then
  6.     if(not started and current~=total)then
  7.       onStartDownload()
  8.       started=true
  9.     end
  10.     if(finish~=total)then
  11.       onDownload(current,total)
  12.       if(current==total)then
  13.         onFinishDownloading(current,total)
  14.         started=false
  15.         finish=total
  16.       end
  17.     end
  18.   end
  19.   local previous=current
  20. end)
  21.  
  22. function onStartDownload(current,total)
  23.   outputChatBox("START DOWNLOADING")
  24. end
  25. function onDownload(current,total)
  26.   outputChatBox(inspect{"Downloading: ",current,"/",total})
  27. end
  28. function onFinishDownloading(current,total)
  29.   outputChatBox("FINISH DOWNLOADING")
  30. end
  31.  
  32. --[[
  33. example output with script contain 15 files, size of this files: 8 921 880 B ( by windows ):
  34. START DOWNLOADING
  35. { "Downloading: ", 0, "/", 8921880 }
  36. { "Downloading: ", 446094, "/", 8921880 }
  37. { "Downloading: ", 669141, "/", 8921880 }
  38. { "Downloading: ", 1338282, "/", 8921880 }
  39. { "Downloading: ", 1784376, "/", 8921880 }
  40. { "Downloading: ", 3568752, "/", 8921880 }
  41. { "Downloading: ", 8921880, "/", 8921880 }
  42. FINISH DOWNLOADING
  43. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement