Advertisement
suxonov

Untitled

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