Advertisement
NoorTFM

سكربت قرعة رمضان

Apr 29th, 2021
1,333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.47 KB | None | 0 0
  1. local map = [[<C><P DS="m;552,367,69,365,235,367,690,365,407,365" Ca="" MEDATA="2,1;;;;-0;0:::1-"/><Z><S><S T="0" X="0" Y="0" L="10" H="10" P="0,0,0.3,0.2,0,0,0,0" i="5,5,1791faefe1b.png"/><S T="0" X="0" Y="0" L="10" H="10" P="0,0,0.3,0.2,0,0,0,0" N="" i="5,5,1791faf30bb.png"/><S T="14" X="402" Y="409" L="805" H="68" P="0,0,1,0,0,0,0,0"/><S T="14" X="-29" Y="217" L="55" H="472" P="0,0,0,0.2,0,0,0,0"/><S T="14" X="827" Y="219" L="55" H="472" P="0,0,0,0.2,0,0,0,0"/></S><D/><O/><L/></Z></C>]]
  2. local admins = {'Massi#0095',
  3.     'Uvfn#0000', 'Noooooooorr#0000',
  4.     'Kiwi_is_here#0558'
  5. }
  6. local winners = {}
  7. local rolled = false
  8. local rollLoopId = 0
  9. local particlesPlaces = {{155, 326, 5}, {634, 355, 5}, {561, 308, 3}}
  10.  
  11. function addParticles()
  12.     for _, place in next, particlesPlaces do
  13.         if place then
  14.             for i = 1, place[3] do
  15.                 local x, y = place[1], place[2]
  16.                 tfm.exec.displayParticle(4,x,y,math.random(-3,3),math.random(-3,3),0,0,nil)
  17.             end
  18.         end
  19.     end
  20. end
  21.  
  22. function string.toNickname(str)
  23.     return string.gsub(str, '(#%d%d%d%d)', '<font size="8"><g>%1</g></font>')
  24. end
  25.  
  26. function string.split(str, sep)
  27.     if sep == nil then sep = '%s' end
  28.     local tbl = {}
  29.     for a in string.gmatch(str, '([^' .. sep .. ']+)') do
  30.         tbl[#tbl + 1] = a
  31.     end
  32.     return tbl
  33. end
  34.  
  35. function table.has(tbl, k)
  36.     for a, b in next, tbl do
  37.         if (type(a) == 'string' and k == a) or b == k then
  38.             return true
  39.         end
  40.     end
  41.     return false
  42. end
  43.  
  44. function eventNewPlayer(playerName)
  45.     ui.addTextArea(1000, '', playerName, 280, 275, 200, 200, 0, 0)
  46.     tfm.exec.addImage('1754cc9cab3.png', ':2', 690, 25, playerName)
  47.     ui.addTextArea(3000, '', playerName, 710, 45, 80, 170, 0, 0, 1, true)
  48. end
  49.  
  50. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  51.  
  52. function filterPlayers()
  53.     local players = {}
  54.     for k, v in next, tfm.get.room.playerList do
  55.         if not winners[k] and not table.has(admins, k) and not v.isDead and string.sub(k, 1, 1) ~= '*' then
  56.             players[#players + 1] = k
  57.         end
  58.     end
  59.     return players
  60. end
  61.  
  62. function getWinner()
  63.     local ran = {}
  64.     local players = filterPlayers()
  65.     for i = 1, math.random(#players) do
  66.         ran[#ran + 1] = players[i]
  67.     end
  68.     return ran[math.random(#ran)]
  69. end
  70.  
  71. local particleLoop = 0
  72. function eventLoop()
  73.     particleLoop = particleLoop + 1
  74.     local wins = {}
  75.     for k, v  in next, winners do
  76.         wins[#wins + 1] = '<J><font size="9" color="#998e61">' .. k .. '. ' .. string.toNickname(v) .. '</font>'
  77.     end
  78.     ui.updateTextArea(3000, table.concat(wins, '<br>'))
  79.     if particleLoop == 3 then
  80.         addParticles()
  81.         particleLoop = 0
  82.     end
  83. end
  84.  
  85. function rollLoop()
  86.     if rolled == true then
  87.         local players = filterPlayers()
  88.         local randomPlayer = players[math.random(#players)]
  89.         if randomPlayer == nil then
  90.             randomPlayer = 'لم يتم اختيار شخص'
  91.         end
  92.  
  93.         ui.updateTextArea(1000, '<p align="center"><font color="#5f303f" size="19">' .. string.toNickname(randomPlayer) .. '</font></p>')
  94.         local theRandomPlayer = tfm.get.room.playerList[randomPlayer]
  95.         if theRandomPlayer then
  96.             tfm.exec.addShamanObject(0, theRandomPlayer.x, theRandomPlayer.y - 70)
  97.             for k, v in next, tfm.get.room.playerList do
  98.                 if randomPlayer == k then
  99.                     tfm.exec.setNameColor(randomPlayer, 0xFF9500)
  100.                 else
  101.                     tfm.exec.setNameColor(k, 0)
  102.                 end
  103.             end
  104.         end
  105.     end
  106. end
  107.  
  108. function rollWinner()
  109.     system.removeTimer(rollLoopId)
  110.     local winner = getWinner()
  111.     tfm.exec.setUIMapName(('<font color="#cb799f">الــقــرعــة الـرمـضـانـيـة</font> <G>|</G> <N><font color="#FD96F">%s</font> :الفائز'):format(winner and winner or 'ﻻ أحد'))
  112.     if winner == nil then
  113.         ui.updateTextArea(1000, '<p align="center"><font color="#5f303f" size="19">لم يتم اختيار فائِز</font></p>')
  114.         return
  115.     end
  116.     ui.updateTextArea(1000, '<p align="center"><font color="#5f303f" size="19">' .. string.toNickname(winner) .. '</font></p>')
  117.     winners[#winners + 1] = winner
  118.     local player = tfm.get.room.playerList[winner]
  119.     for k, v in next, tfm.get.room.playerList do
  120.         if v.isDead then
  121.             tfm.exec.respawnPlayer(k)
  122.         end
  123.         if k == winner then
  124.             tfm.exec.changePlayerSize(k, 1.5)
  125.             tfm.exec.playEmote(k, 0)
  126.         else
  127.             tfm.exec.playEmote(k, 5)
  128.         end
  129.     end
  130.     for k, v in next, admins do
  131.         tfm.exec.chatMessage('<ROSE>' .. printWinners() .. '</ROSE>', v)
  132.     end
  133.     rolled = false
  134. end
  135.  
  136. function printWinners()
  137.     local res = {}
  138.     for _, k in pairs(winners) do
  139.         res[#res + 1] = '"' .. k .. '"'
  140.     end
  141.     return 'local winners = {' .. table.concat(res, ', ') .. '}'
  142. end
  143.  
  144. function eventChatCommand(playerName, cmd)
  145.     local args={}
  146.     for s in cmd:gmatch("%S+") do
  147.         table.insert(args, s)
  148.     end
  149.     if table.has(admins, playerName) then
  150.         if args[1] == 'roll' then
  151.             rolled = not rolled
  152.             rollLoopId = system.newTimer(rollLoop, 1000, true)
  153.             system.newTimer(rollWinner, 40*1000, false)
  154.         elseif args[1] == "c" then
  155.             tfm.exec.chatMessage("<n> "..cmd:sub(2).." <fc>["..playerName.."]</fc>")
  156.         end
  157.     end
  158. end
  159.  
  160.  
  161. function start()
  162.     tfm.exec.disableAutoShaman(true)
  163.     tfm.exec.newGame(map)
  164.     tfm.exec.setGameTime(60*3)
  165.     tfm.exec.disableAutoNewGame(true)
  166.     tfm.exec.disableAutoTimeLeft(true)
  167.     tfm.exec.disablePhysicalConsumables(true)
  168.     tfm.exec.setUIMapName('<font color="#cb799f">الــقــرعــة الـرمـضـانـيـة</font>')
  169.     system.disableChatCommandDisplay('roll')
  170.     system.disableChatCommandDisplay('c')
  171. end
  172.  
  173. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement