MaXwEllDeN

Scroll

Jul 13th, 2013
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. --[[
  2.  * Nome: Scroll Messages
  3.  * Author: Skyen Hasus
  4.  * Version: 1.00.18
  5.  
  6.  * From:
  7.  * www.otserv.com.br
  8.  
  9.  * Syntax: doScrollMessage(uid, message)
  10.  * Example: doScrollMessage(cid, "Welcome!")
  11. ]]--
  12.  
  13. --[[ Config: ]]--
  14. --[[ Display: string lenght]]--
  15. local display = 60
  16.  
  17. --[[ Delay: Time in milliseconds ]]--
  18. local delay = 100
  19.  
  20. function doScrollMessage(uid, message)
  21.  
  22.     if message == nil or uid == nil then
  23.         return true
  24.     end
  25.  
  26.     local chars = {}
  27.  
  28.     for i = 1, display do
  29.         table.insert(chars, " ")
  30.     end
  31.  
  32.     for i = 1, string.len(message) do
  33.         table.insert(chars, string.sub(message, i, i))
  34.     end
  35.  
  36.     for i = 1, display + 1 do
  37.         table.insert(chars, " ")
  38.     end
  39.  
  40.     local function doScroll(uid, message, i, j)
  41.         if isPlayer(uid) then
  42.           f = display + i
  43.             if f > #chars then
  44.                 f = display + string.len(message)
  45.             end
  46.  
  47.             doPlayerSendCancel(uid, table.concat(chars, "", i, f))
  48.  
  49.             if i <= j then
  50.                 addEvent(doScroll, delay, uid, message, i+1, j)
  51.             end
  52.         end
  53.     end
  54.  
  55.     doScroll(uid, chars, 1, display + string.len(message))
  56.     return true
  57. end
Advertisement
Add Comment
Please, Sign In to add comment