Advertisement
NoorTFM

[TFM] April fool!

Mar 30th, 2021 (edited)
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.31 KB | None | 0 0
  1. local TFM = tfm.exec
  2. local ROOM = tfm.get.room
  3. local p = {}
  4.  
  5. local module = {
  6.     admins = {"Noooooooorr#0000", ({pcall(nil)})[2]:match".-#%d+"},
  7.     images = {
  8.         {"17869d1e79b.png", 580/2, 380/2},
  9.         {"17869d22f39.jpg", 550/2, 352/2},
  10.         {"17869d30f0a.png", 580/2, 382/2},
  11.         {"17869d267dd.jpg", 550/2, 352/2},    
  12.         {"17869d11fdb.png", 580/2, 380/2},
  13.         mice = {
  14.             --Here you can put your mouse as the gift giver
  15.             --{"img", x, y, "The mouse's name(don't forget the tag!!!!!)"},
  16.             {"1786b2603f8.png", 32, 28, "Noooooooorr#0000"},
  17.             {"17879ef7618.png", 40, 32, "Snowvlokje#4925"},
  18.         },
  19.         gifts = {
  20.             --Here you can add more items to the fake gift
  21.             --The script will choose a random item to make it as a gift
  22.             --{"the item image", x, y, isAfur}
  23.             {"178799ff930.png", 21, 23.5, true},
  24.             {"17879a020ba.png", 21.5, 23.5, true},
  25.         },
  26.     }
  27. }
  28.  
  29. ---translations source: https://projects.fewfre.com/a801/tools/translation_fetcher
  30. local translations = {
  31.     ar = {
  32.         readMessage = "البطاقة قراءة",
  33.         thank = "شكر", --Remercier
  34.         close = "إغلاق", --bouton.fermer  
  35.         getBadge = "لقد فزت بوسام جديد", --GainBadge
  36.  
  37.         alreadyPranked = "<bl>تم مقلبته بالفعل <g>%s</g> اللاعب</bl>",
  38.         april_fool  = "<font color='#912b79'>لقد وقعت بالفخ ، إنها كذبة أبريل\nXD</font>"
  39.     },
  40.     br = {
  41.         readMessage = "Ler a mensagem",
  42.         thank = "Agradecer",
  43.         close = "Fechar",
  44.         getBadge = "Você ganhou uma nova medalha!",
  45.     },
  46.     en = {
  47.         readMessage = "Read the card",
  48.         thank = "Reply",
  49.         close = "Close",    
  50.         getBadge = "You won a new badge!",
  51.  
  52.         alreadyPranked = "<bl>You have already tricked <g>%s</g></bl>",
  53.         april_fool  = "<font color='#912b79'>It's April Fool !!! \nSorry for that XD</font>"
  54.     },
  55.     fr = {
  56.         readMessage = "Voir le message",
  57.         thank = "Remercier",
  58.         close = "Fermer",
  59.         getBadge = "Vous avez gagné un nouveau badge !",
  60.     },
  61. }
  62.  
  63. local translate = function (id, name)
  64.     if p[name] then
  65.         if translations[p[name].langue] then
  66.             if translations[p[name].langue][id] then
  67.                 return translations[p[name].langue][id]
  68.             else
  69.                 return translations["en"][id]
  70.             end
  71.         elseif translations["en"] then
  72.             return translations["en"][id]
  73.         else
  74.             return "error"
  75.         end
  76.     end
  77. end
  78.  
  79. local loadImagesForLaggers = function (name)
  80.     for i = 1,5 do
  81.         local img = module.images[i]
  82.         TFM.addImage(img[1], "?0", 0, 0, name, 0.01, 0.01)
  83.     end
  84. end
  85.  
  86. local nameInTextAreawithBorder = function (id, x, y, theName, borderColor, name)
  87.     local hashtagFormat = string.find(theName, "(%d%d%d%d)")
  88.     local hashtag, mainName = string.sub(theName, hashtagFormat, #theName), string.sub(theName, 1, hashtagFormat - 1)
  89.     ui.addTextArea(100 + id, "<p align='center'><b><font color = '#"..borderColor.."'>"..mainName.."<font size = '8'><i> #</i></font><font size = '10'>"..hashtag.."</font></g>", name, x - 44, y - 26, 150, 60, 0x0121, 0x0121, 0, true)    
  90.     ui.addTextArea(200 + id, "<p align='center'><b><font color = '#"..borderColor.."'>"..mainName.."<font size = '8'><i> #</i></font><font size = '10'>"..hashtag.."</font></g>", name, x - 46, y - 26, 150, 60, 0x0121, 0x0121, 0, true)    
  91.     ui.addTextArea(300 + id, "<p align='center'><b><font color = '#"..borderColor.."'>"..mainName.."<font size = '8'><i> #</i></font><font size = '10'>"..hashtag.."</font></g>", name, x - 46, y - 24, 150, 60, 0x0121, 0x0121, 0, true)    
  92.     ui.addTextArea(400 + id, "<p align='center'><b><font color = '#"..borderColor.."'>"..mainName.."<font size = '8'><i> #</i></font><font size = '10'>"..hashtag.."</font></g>", name, x - 44, y - 24, 150, 60, 0x0121, 0x0121, 0, true)    
  93.     ui.addTextArea(500 + id, "<p align='center'><b>"..mainName.."<g><font size = '8'><i> #</i></font><font size = '10'>"..hashtag.."</font></g>", name, x - 45, y - 25, 150, 60, 0x0121, 0x0121, 0, true)  
  94. end
  95.  
  96. local removeNameTextarea = function (id, name)
  97.     for i = 1,5 do
  98.         ui.removeTextArea((i*100) + id, name)
  99.     end
  100. end
  101.  
  102. local closeGift = function (name)
  103.     removeNameTextarea (1, name)
  104.     if p[name].imgs then
  105.         for i = 1, #p[name].imgs do
  106.             if p[name].imgs[i] then
  107.                 TFM.removeImage(p[name].imgs[i])
  108.                 ui.removeTextArea(i, name)
  109.             end
  110.         end
  111.     end
  112. end
  113.  
  114. local gift = function (name, openGift)
  115.     if not p[name].gotPranked then
  116.         closeGift (name)
  117.         for i = 1,3 do
  118.             local img, callback = module.images[i], "openGift"
  119.             if i == 2 and openGift then img = module.images[4] elseif openGift then callback = "readMessage" end
  120.             p[name].imgs[i] = TFM.addImage(img[1], ":1", 400 - img[2], 210 - img[3], name)
  121.             ui.addTextArea(2, "<p align='center'><a href='event:" .. callback .. "'><font size = '60'>\n\n\n\n\n\n\n", name, 125, 24, 550, 500, 0x0121, 0x0121, 0, true)    
  122.             ui.addTextArea(1, "<p align='center'>" .. translate("readMessage", name), name, 350, 365, 100, 50, 0x0, 0x0, 0, true)
  123.         end
  124.         if openGift then
  125.             local furIMG = module.images.gifts[math.random(#module.images.gifts)]
  126.             p[name].imgs[#p[name].imgs+1] = TFM.addImage(furIMG[1], ":1", 395 - furIMG[2], 175 - furIMG[3], name)
  127.             if furIMG[4] then
  128.                 TFM.chatMessage("<j>" .. translate("getBadge", name), name)
  129.             end
  130.         end
  131.         if not p[name].gifter then p[name].gifter = module.images.mice[math.random(#module.images.mice)] end
  132.         local x, y = 158 + p[name].gifter[2] , 204 + p[name].gifter[3]
  133.         p[name].imgs[#p[name].imgs + 1] = TFM.addImage(p[name].gifter[1], "&5", x, y, name)
  134.         nameInTextAreawithBorder (1, x  , y+10, p[name].gifter[4], "000000", name)
  135.     end
  136. end
  137.  
  138. local letter = function (name)
  139.     closeGift (name)
  140.     local img = module.images[5]
  141.     p[name].imgs[1] = TFM.addImage(img[1], ":1", 400 - img[2], 210 - img[3], name)
  142.     TFM.chatMessage(translate("april_fool", name), name)
  143.     ui.addTextArea(1, "<p align='center'>" .. translate("april_fool", name), name, 300, 200, 200, 50, 0x0, 0x0, 0, true)
  144.     ui.addTextArea(2, "<p align='center'><a href='event:close'>" .. translate("thank", name), name, 230, 365, 100, 50, 0x0, 0x0, 0, true)
  145.     ui.addTextArea(3, "<p align='center'><a href='event:close'>" .. translate("close", name), name, 465, 365, 100, 50, 0x0, 0x0, 0, true)
  146. end
  147.  
  148. local isAdmin = function (name)
  149.     for _,admin in next, module.admins do
  150.         if admin == name then
  151.             return true
  152.         end
  153.     end
  154. end
  155.  
  156. eventTextAreaCallback = function (id, name, cb)
  157.     if cb == "openGift" then
  158.         gift (name, true)
  159.     elseif cb == "readMessage" then
  160.         letter (name)
  161.     elseif cb == "close" then
  162.         closeGift (name)
  163.         p[name].gotPranked = true
  164.     end
  165. end
  166.  
  167. eventNewPlayer = function(name)
  168.     loadImagesForLaggers(name)
  169.     if not p[name] then
  170.         p[name] = {imgs = {}, langue = ROOM.playerList[name].community, gifter = nil, gotPranked = false}
  171.     end
  172. end
  173.  
  174. eventChatCommand = function (name, c)
  175.     local arg = {}
  176.     for argument in c:gmatch("[^%s]+") do
  177.         table.insert(arg, argument)
  178.     end
  179.     if isAdmin(name) then
  180.         if arg[1] == "fool" then
  181.             if arg[2] then
  182.                 if tfm.get.room.playerList[arg[2]] then
  183.                     if not p[arg[2]].gotPranked then
  184.                         gift(arg[2], false)
  185.                     else
  186.                         TFM.chatMessage(string.format(translate("alreadyPranked", name) , arg[2]), name)
  187.                         print(string.format(translate("alreadyPranked", name) , arg[2]))
  188.                     end
  189.                 end
  190.             else
  191.                 for player in pairs(tfm.get.room.playerList) do
  192.                     gift(player, false)
  193.                 end
  194.             end
  195.         end
  196.     end
  197. end
  198.  
  199. local main = function ()
  200.     system.disableChatCommandDisplay()
  201.     for name in pairs(ROOM.playerList) do
  202.         eventNewPlayer(name)
  203.     end
  204. end
  205.  
  206. main()
  207.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement