Advertisement
suxonov

Untitled

Apr 15th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.02 KB | None | 0 0
  1. --darkroom
  2. --#darkroom
  3.  
  4. tfm.exec.disableAutoScore(true)
  5. tfm.exec.disableAutoShaman(true)
  6. tfm.exec.disableAfkDeath(true)
  7. tfm.exec.disableAutoNewGame(true)
  8. system.disableChatCommandDisplay ("profile", true)
  9. system.disableChatCommandDisplay ("help", true)
  10.  
  11. players = {}
  12.  
  13. mes = {
  14. en = {
  15. welcome = '<J>Welcome to #darkroom, %s! Type !help for more information.';
  16. win = '<V>%s<BL> has won!';
  17. help = '<J>Your main purpose is finding an escape from the labyrinth. Find it first or die. Commands:\n!profile nickname';
  18. };
  19.  
  20. e2 = {
  21. welcome = '<J>Welcome to #darkroom, %s! Type !help for more information.';
  22. win = '<V>%s<BL> has won!';
  23. help = '<J>Your main purpose is finding an escape from the labyrinth. Find it first or die. Commands:\n!profile nickname';
  24. };
  25.  
  26. ru = {
  27. welcome = '<J>Добро пожаловать в #darkroom, %s! Напиши !help, чтобы узнать подробнее.';
  28. win = '<V>%s<BL> выиграл!';
  29. help = '<J>Ваша главная задача - найти выход из лабиринта. Найдите его первым или проиграйте. Команды: \n!profile ник - открывает профиль игрока';
  30. };
  31. }
  32.  
  33. maplist={'@6561339', '@6534430'}
  34.  
  35. Module = {
  36. ['Start'] = function (arg)
  37. tfm.exec.newGame(arg)
  38. for name,player in pairs(tfm.get.room.playerList) do
  39. players[name]={rounds=0; wins = 0}
  40. end
  41. end;
  42.  
  43. ['BlaclistCh'] = function(var, arg)
  44. local flag = true
  45. for i,v in pairs (arg) do
  46. if v == var then
  47. flag = false
  48. break
  49. end
  50. end
  51. return flag
  52. end;
  53.  
  54. ['GetPoints'] = function (xml)
  55. local obj={}
  56. local i= 1
  57. local blacklist={"0","1","2","4","5","6","7","8","10","12","13","14","15","16","17","18","19","20","21","22","23","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","40","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131"}
  58. for w in string.gmatch(xml, "<P.-T.->") do
  59. local tmps=string.sub(w, string.find(w, 'X="[-]?%d+"'))
  60. xO=string.sub(tmps,string.find(tmps,"[-]?%d+"))
  61. tmps=string.sub(w, string.find(w, 'Y="[-]?%d+"'))
  62. yO=string.sub(tmps,string.find(tmps,"[-]?%d+"))
  63. idO=string.gsub(string.sub(w, string.find(w, 'T="%d+"')),"%D","")
  64. if Module.BlaclistCh(idO, blacklist) then
  65. obj[i]={x=xO;y=yO;id=idO}
  66. i=i+1
  67. end end;
  68.  
  69. return obj
  70. end;
  71.  
  72. ['PlacePortals'] = function ()
  73. myVar = Module.GetPoints(xml)
  74. local tmpO=myVar[math.random(#myVar)]
  75. tfm.exec.addShamanObject (27, tmpO.x, tmpO.y-50, 0, 0, 0, false)
  76. tfm.exec.addShamanObject (26, 830, 334, 0, 0, 0, false)
  77. end;
  78.  
  79. --players--
  80.  
  81. ['OpenProfile'] = function (a, r)
  82. local ratio = players[a].wins / players[a].rounds
  83. ui.addTextArea(1, "", r, 301, 90, 220, 184, 0x1d1d1d, 0x1d1d1d)
  84. ui.addTextArea(2, "<V><font size='20'><p align='center'>"..a.."</p></font>", r, 315, 109, 192, 33, 0x324650, 0x425661)
  85. ui.addTextArea(3, "Total rounds played: <V>"..players[a].rounds.."<N>;<br><br>Wins: <V>"..players[a].wins.."<N>;<br>Ratio: <V>"..ratio..'<N>;', r, 315, 176, 192, 80, 0x324650, 0x425661)
  86. ui.addTextArea(4, "<a href='event:closeProfile'><p align='center'>Закрыть</p><a>", r, 301, 292, 220, 26, 0x1d1d1d, 0x1d1d1d)
  87. end;
  88.  
  89. ['CloseProfile'] = function ()
  90. for i,key in ipairs({1,2,3,4}) do
  91. ui.removeTextArea(i)
  92. end end;
  93. }
  94.  
  95. MsgBox = {
  96. ['SendMessage'] = function (message, name)
  97. --print(message)
  98. tfm.exec.chatMessage(message, name)
  99. end;
  100. ['LanguageSwitcher'] = function (name)
  101. lang = tfm.get.room.playerList[name].community
  102. if mes[lang]~=nil then
  103. end end;
  104.  
  105. }
  106.  
  107. function eventNewGame()
  108. for name,player in pairs(tfm.get.room.playerList) do
  109. players[name].rounds = players[name].rounds + 1
  110. xml = tfm.get.room.xmlMapInfo.xml
  111. Module.PlacePortals()
  112. ui.removeTextArea(6)
  113. end end
  114.  
  115.  
  116. -- player win
  117. function eventPlayerWon(name)
  118. players[name].wins = players[name].wins + 1
  119. ui.addTextArea(6, "", name, 6, 25, 788, 366, 0xe0e0e, 0xe0e0e)
  120. tfm.exec.setGameTime(2)
  121. if MsgBox.LanguageSwitcher(name) then
  122. MsgBox.SendMessage(string.format(mes[lang].win, name), nil)
  123. end end
  124.  
  125. --new player
  126. function eventNewPlayer(name)
  127. players[name] = {rounds = 0; wins = 0}
  128. if MsgBox.LanguageSwitcher(name) then
  129. MsgBox.SendMessage(string.format(mes[lang].welcome, name), name)
  130. else MsgBox.SendMessage(string.format(mes.en.welcome, name), name)
  131. tfm.exec.respawnPlayer(name)
  132. end end
  133.  
  134.  
  135. function eventChatCommand(name, c)
  136. local atr = {}
  137. for argument in c:gmatch("[^%s]+") do
  138. table.insert(atr,argument)
  139. end
  140. if atr[1] == 'help' then if MsgBox.LanguageSwitcher(name) then
  141. MsgBox.SendMessage(mes[lang].help, name) else MsgBox.SendMessage(mes.en.help, name) end
  142.  
  143. elseif atr[1] == 'profile' and atr[2]~= nil and players[atr[2]] ~= nil then
  144. Module.OpenProfile(atr[2], name) end end
  145.  
  146. function eventTextAreaCallback(id, name, callback)
  147. if callback == 'closeProfile' then Module.CloseProfile() end end
  148.  
  149.  
  150. function eventLoop(t1, t2)
  151. if t2<=0 then tfm.exec.newGame(maplist[math.random(#maplist)]) end end
  152.  
  153. Module.Start(maplist[math.random(#maplist)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement