Advertisement
Guest User

Untitled

a guest
Apr 9th, 2015
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 41.78 KB | None | 0 0
  1. --Error at getRegDate()
  2. Box={type=12, width=2000, height=10, foreground=true, friction=0.3, restitution=0.2, angle=0, color="0x6a7495", miceCollision=true, groundCollision=false}
  3. Admins={}
  4. Mods={}
  5. data={}
  6. EN={[1]="Choose two objects, which you will use.",
  7. [2]="Little box</font> and <font color='#BABD2F'>Large plank",
  8. [3]="Big box</font> and <font color='#BABD2F'>Little plank",
  9. [4]="Choose an object, which you want to buy.      <b><font color='#CB546B'><a href='event:closeStore'>X</b></a></font><br>You have: ",
  10. [5]="Ball",
  11. [6]="Little box",
  12. [7]="Big box",
  13. [8]="Large plank",
  14. [9]="Little plank",
  15. [10]="Choose an object",
  16. [11]="Registration date: ",
  17. [12]="Wins: ",
  18. [13]="Loses: ",
  19. [14]="Rounds played: ",
  20. [15]="Transforms: ",
  21. [16]="Unlocked titles:",
  22. [17]="Full list",
  23. [18]="Awards:",
  24. [19]="Current object:",
  25. [20]="Close",
  26. [21]="Help",
  27. [22]="Store",
  28. [23]="<font size='12'>Choose an object",
  29. [24]="Do you want to buy a",
  30. [25]="Ball",
  31. [26]="Little box",
  32. [27]="Big box",
  33. [28]="Big plank",
  34. [29]="Little plank",
  35. [30]="Anvil",
  36. [31]="Cannon ball",
  37. [32]="Apple",
  38. [33]="Ice cube",
  39. [34]="You do not have enough money to buy this object",
  40. [35]="Skill: ",
  41. [36]="for",
  42. [37]="coins?"--do you want to buy a ball for 100 coins?
  43. }
  44. RU={
  45. [1]="Выберите два объекта, которые Вы будете использовать.",
  46. [2]="Маленький ящик</font> и <font color='#BABD2F'>Большая палка",
  47. [3]="Большой ящик</font> и <font color='#BABD2F'>Маленькая палка",
  48. [4]="Выберите объект, который хотите купить.      <b><font color='#CB546B'><a href='event:closeStore'>X</b></a></font><br>У вас ",
  49. [5]="Мяч",
  50. [6]="Мал. ящик",
  51. [7]="Бол. ящик",
  52. [8]="Бол. палка",
  53. [9]="Мал. палка",
  54. [10]="Выберите объект.",
  55. [11]="Дата регистрации: ",
  56. [12]="Побед: ",
  57. [13]="Проигрышей: ",
  58. [14]="Раундов сыграно: ",
  59. [15]="Превращений: ",
  60. [16]="Открытые титулы:",
  61. [17]="Полный список",
  62. [18]="Награды:",
  63. [19]="Текущий объект:",
  64. [20]="Закрыть",
  65. [21]="Помощь",
  66. [22]="Магазин",
  67. [23]="<font size='13'>Выбор объекта",
  68. [24]="Купить объект",
  69. [25]="Мячик",
  70. [26]="Маленький ящик",
  71. [27]="Большой ящик",
  72. [28]="Большая палка",
  73. [29]="Маленькая палка",
  74. [30]="Наковальня",
  75. [31]="Ядро",
  76. [32]="Яблоко",
  77. [33]="Куб льда",
  78. [34]="У вас недостаточно монет",
  79. [35]="Навык: ",
  80. [36]="за",--------v
  81. [37]="монет?"--Купить объект мячик за 100 монет?
  82. }
  83. lng={}
  84. Obj={}
  85. obj={}
  86. x={}
  87. y={}
  88. checkCoords={}
  89. wait={}
  90. titles={[1]="Little mouse", [2]="Newbie", [3]="Fifty cent", [4]="Helpful mouse", [5]="Keeper of cheese", [6]="Hard worker", [7]="Cheese hunter", [8]="Proud"}
  91. tfm.exec.disableAutoShaman(true)
  92.  
  93. table.IndexOf=function(t, value)
  94.         for i, v in ipairs(t) do
  95.                 if v==value then
  96.                         return i
  97.                 end
  98.         end
  99. return false
  100. end
  101.  
  102. function table.contains(t,element)
  103. if element==nil then
  104. return false
  105. end
  106. for key,value in pairs(t) do
  107. if value==element then
  108. return true
  109. end
  110. end
  111. return false
  112. end
  113.  
  114. function isStaff(playerName, tbl)
  115. if table.contains(tbl, playerName)==true then
  116. return true
  117. else
  118. return false
  119. end
  120. end
  121. --395 -185
  122. --function u(a,b,c,d,e,f,g,h,i,j,k)
  123. --ui.addTextArea(a, b, c, d, e, f, g, h, i, j, k)
  124. --end
  125. --[[titles:
  126. Colourful mouse - customize an object
  127. icemouse - buy a frozen mouse
  128. Cutie - buy a ball
  129.  
  130. if data[playerName].wins>=10 and table.contains(data[playerName].titles, "2")==false then
  131.         giveTitle(playerName, 2)
  132. end
  133. if data[playerName].wins>=50 and table.contains(data[playerName].titles, "3")==false then
  134.         giveTitle(playerName, 3)
  135. end
  136. if data[playerName].wins>=100 and table.contains(data[playerName].titles, "4")==false then
  137.         giveTitle(playerName, 4)
  138. end
  139. if data[playerName].wins>=150 and table.contains(data[playerName].titles, "5")==false then
  140.         giveTitle(playerName, 5)
  141. end
  142. if data[playerName].wins>=200 and table.contains(data[playerName].titles, "6")==false then
  143.         giveTitle(playerName, 6)
  144. end
  145. if data[playerName].wins>=250 and table.contains(data[playerName].titles, "7")==false then
  146.         giveTitle(playerName, 7)
  147. end
  148. if data[playerName].wins>=300 and table.contains(data[playerName].titles, "8")==false then
  149.         giveTitle(playerName, 8)
  150. end
  151.  
  152.  
  153. Proud - 300 wins
  154. Cheese hunter - 250 wins
  155. Hard worker - 200 wins
  156. Keeper of cheese - 150 wins
  157. Helpful Mouse - 100 wins
  158. Fifty cent - 50 wins
  159. Newbie - 10 wins
  160. Little mouse - new player
  161.  
  162. Unlucky mouse - 100 deaths(loses)
  163. Reckless mouse - 250 deaths(loses)
  164. Hopeless - 400 deaths(loses)
  165. Mouse ghost - 600 deaths(loses)
  166. ]]
  167.  
  168. function updateMap()
  169. tfm.exec.addPhysicObject(1, 396, -166, Box)
  170. tfm.exec.addPhysicObject(2, 396, -210, Box)
  171. Box.angle=90
  172. Box.width=30
  173. tfm.exec.addPhysicObject(3, 0, -185, Box)
  174. if mBorder2~=nil then
  175. tfm.exec.addPhysicObject(4, mBorder2, -186, Box)
  176. else
  177. tfm.exec.addPhysicObject(4, 1000, -186, Box)
  178. end
  179. Box.angle=0
  180. Box.width=3000
  181. Box.height=150
  182. Box.miceCollision=false
  183. tfm.exec.addPhysicObject(5, 420, -229, Box)
  184. Box.miceCollision=true
  185. Box.width=3000
  186. Box.height=10
  187. tfm.exec.setUIMapName("#<R>Transform<J>ice!<N>")
  188. end
  189.  
  190. function buyObj(playerName)
  191. if data[playerName].obj[1]==nil then
  192. ui.addTextArea(31,"<p align='center'><font size='14'>"..lng[playerName][1].."</font></p>",playerName,205,101,400,150,0x6a7495,0x000000,1,true)
  193. ui.addTextArea(32,"<p align='center'><a href='event:sbox+plank'> <font size='15'><font color='#BABD2F'>"..lng[playerName][2].."</font></font></a></p>",playerName,255,151,300,25,0x000033,0x000000,0.3,true)
  194. ui.addTextArea(33,"<p align='center'><a href='event:bbox+plank'> <font size='15'><font color='#BABD2F'>"..lng[playerName][3].."</font></font></a></p>",playerName,255,201,300,25,0x000033,0x000000,0.3,true)
  195. end
  196. if data[playerName].obj[1]~=nil then
  197.         ui.addTextArea(1,"<p align='center'><font size='15'>     "..lng[playerName][4].."<font color='#BABD2F'>"..data[playerName].money.."</font> монет</font></p>",playerName,205,101,400,200,0x6a7495,0x000000,1,true)
  198.         if table.contains(data[playerName].obj, "6")~=true then
  199.                 ui.addTextArea(2,"<p align='center'><a href='event:ball'> <font size='15'>"..lng[playerName][5].."</font></a></p>",playerName,215,151,100,25,0x000033,0x000000,0.3,true)
  200.         end
  201.         if table.contains(data[playerName].obj, "1")~=true then
  202.                 ui.addTextArea(3,"<p align='center'><a href='event:small box'> <font size='15'>"..lng[playerName][6].."</font></a></p>",playerName,355,151,100,25,0x000033,0x000000,0.3,true)
  203.         end
  204.         if table.contains(data[playerName].obj, "2")~=true then
  205.                 ui.addTextArea(4,"<p align='center'><a href='event:big box'> <font size='15'>"..lng[playerName][7].."</font></a></p>",playerName,495,151,100,25,0x000033,0x000000,0.3,true)
  206.         end
  207.         if table.contains(data[playerName].obj, "4")~=true then
  208.                 ui.addTextArea(5,"<p align='center'><a href='event:big plank'> <font size='15'>"..lng[playerName][8].."</font></a></p>",playerName,215,201,100,25,0x000033,0x000000,0.3,true)
  209.         end
  210.         if table.contains(data[playerName].obj, "3")~=true then
  211.                 ui.addTextArea(6,"<p align='center'><a href='event:small plank'> <font size='15'>"..lng[playerName][9].."</font></a></p>",playerName,355,201,100,25,0x000033,0x000000,0.3,true)
  212.         end
  213.         if table.contains(data[playerName].obj, "10")~=true then
  214.                 ui.addTextArea(7,"<p align='center'><a href='event:anvil'> <font size='14'>"..lng[playerName][30].."</font></a></p>",playerName,495,201,100,25,0x000033,0x000000,0.3,true)
  215.         end
  216.         if table.contains(data[playerName].obj, "17")~=true then
  217.                 ui.addTextArea(8,"<p align='center'><a href='event:cannon ball'> <font size='15'>"..lng[playerName][31].."</font></a></p>",playerName,215,251,100,25,0x000033,0x000000,0.3,true)
  218.         end
  219.         if table.contains(data[playerName].obj, "39")~=true then
  220.                 ui.addTextArea(9,"<p align='center'><a href='event:apple'> <font size='15'>"..lng[playerName][32].."</font></a></p>",playerName,355,251,100,25,0x000033,0x000000,0.3,true)
  221.         end
  222.         if table.contains(data[playerName].obj, "54")~=true then
  223.                 ui.addTextArea(10,"<p align='center'><a href='event:icemice'> <font size='15'>"..lng[playerName][33].."</font></a></p>",playerName,495,251,100,25,0x000033,0x000000,0.3,true)
  224.         end
  225. end
  226. end
  227.  
  228. function inventory(playerName)
  229. ui.addTextArea(1,"<p align='center'><font size='15'>"..lng[playerName][10].."</p></font>",playerName,205,101,400,200,0x6a7495,0x000000,1,true)--14
  230. ui.addTextArea(34,"<p align='center'><font size='15'><b><font color='#CB546B'><a href='event:closeStore'>X</a></b></font></font></p>",playerName,585,101,20,20,0,0,1,true)
  231.         if table.contains(data[playerName].obj, "1")==true then
  232.                 ui.addTextArea(3,"<p align='center'><a href='event:small box'> <font size='15'>"..lng[playerName][6].."</font></a></p>",playerName,355,151,100,25,0x000033,0x000000,0.3,true)
  233.         end
  234.         if table.contains(data[playerName].obj, "2")==true then
  235.                 ui.addTextArea(4,"<p align='center'><a href='event:big box'> <font size='15'>"..lng[playerName][7].."</font></a></p>",playerName,495,151,100,25,0x000033,0x000000,0.3,true)
  236.         end
  237.         if table.contains(data[playerName].obj, "3")==true then
  238.                 ui.addTextArea(6,"<p align='center'><a href='event:small plank'> <font size='15'>"..lng[playerName][9].."</font></a></p>",playerName,355,201,100,25,0x000033,0x000000,0.3,true)
  239.         end
  240.         if table.contains(data[playerName].obj, "4")==true then
  241.                 ui.addTextArea(5,"<p align='center'><a href='event:big plank'> <font size='15'>"..lng[playerName][8].."</font></a></p>",playerName,215,201,100,25,0x000033,0x000000,0.3,true)
  242.         end
  243.         if table.contains(data[playerName].obj, "6")==true then
  244.                 ui.addTextArea(2,"<p align='center'><a href='event:ball'> <font size='15'>"..lng[playerName][5].."</font></a></p>",playerName,215,151,100,25,0x000033,0x000000,0.3,true)
  245.         end
  246.         if table.contains(data[playerName].obj, "10")==true then
  247.                 ui.addTextArea(7,"<p align='center'><a href='event:anvil'> <font size='14'>"..lng[playerName][30].."</font></a></p>",playerName,495,201,100,25,0x000033,0x000000,0.3,true)
  248.         end
  249.         if table.contains(data[playerName].obj, "17")==true then
  250.                 ui.addTextArea(8,"<p align='center'><a href='event:cannon ball'> <font size='15'>"..lng[playerName][31].."</font></a></p>",playerName,215,251,100,25,0x000033,0x000000,0.3,true)
  251.         end
  252.         if table.contains(data[playerName].obj, "39")==true then
  253.                 ui.addTextArea(9,"<p align='center'><a href='event:apple'> <font size='15'>"..lng[playerName][32].."</font></a></p>",playerName,355,251,100,25,0x000033,0x000000,0.3,true)
  254.         end
  255.         if table.contains(data[playerName].obj, "54")==true then
  256.                 ui.addTextArea(10,"<p align='center'><a href='event:icemice'> <font size='15'>"..lng[playerName][33].."</font></a></p>",playerName,495,251,100,25,0x000033,0x000000,0.3,true)
  257.         end
  258. end
  259. function isAdmin(playerName)
  260. a=0
  261. if table.contains(Mods, playerName)==true then
  262.         a=1
  263. end
  264. if table.contains(Admins, playerName)==true then
  265.         a=2
  266. end
  267. return a
  268. --[[
  269. if a==1 then playerName is mod
  270. if a==2 then playerName is admin
  271. ]]
  272. end
  273.  
  274. function openProfile(playerName, s1, name)
  275. Obj[playerName].titles=playerName
  276. if Obj[playerName].id==3 or Obj[playerName].id==4 then
  277. Obj[playerName].sizeY=1
  278. s2=1
  279. else
  280. Obj[playerName].sizeY=Obj[playerName].size
  281. s2=s1
  282. end
  283. if Obj[playerName].size>=200 then
  284. Obj[playerName].size=140
  285. s1=Obj[playerName].size
  286. end
  287. s1=295-(s1/2)
  288. s2=325-(s2/2)
  289. ui.addTextArea(11, "", name, 200, 35, 400, 350, 0x324650, 0x324650, 1, true)
  290. ui.addTextArea(12, "<p align='center'><b><font face='soopafresh' size='24'>"..playerName.."</font></b></p>", name, 200, 35, 400, 30, 0x324650, 0x324650, 1, true)
  291. ui.addTextArea(13, "<p align='center'><b><font face='soopafresh' size='16'>"..data[playerName].cTitle.."</font></b></p>", name, 200, 70, 400, 25, 0x324650, 0x324650, 1, true)
  292. ui.addTextArea(14, "<p align='left'>"..lng[playerName][11].."<font size='9'><font color='#CB546B'>"..data[playerName].regDate.."</font></font><br><b>"..lng[playerName][12]..""..data[playerName].wins.."<br><br>"..lng[playerName][13]..""..data[playerName].loses.."<br><br>"..lng[playerName][14]..""..data[playerName].rounds.."<br><br>"..lng[playerName][15]..""..data[playerName].transforms.."<br><br>"..lng[playerName][35]..""..data[playerName].skill.."</b></p>", name, 200, 110, 220, 220, 0x324650, 0x324650, 1, true)--14 15 16 17 18 19
  293. --[[ui.addTextArea(14, "<p align='left'><b>Дата регистрации: <font size='9'>"..data[playerName].regDate.."</font></b></p>", name, 200, 110, 220, 20, 0x324650, 0x324650, 1, true)--15
  294. --ui.addTextArea(15, "<p align='left'><b>Побед: "..data[playerName].wins.."</b></p>", name, 200, 140, 200, 20, 0x324650, 0x324650, 1, true)--16
  295. --ui.addTextArea(16, "<p align='left'><b>Проигрышей: "..data[playerName].loses.."</b></p>", name, 200, 170, 200, 20, 0x324650, 0x324650, 1, true)--17
  296. --ui.addTextArea(17, "<p align='left'><b>Раундов сыграно: "..data[playerName].rounds.."</b></p>", name, 200, 200, 200, 20, 0x324650, 0x324650, 1, true)--18
  297. --ui.addTextArea(18, "<p align='left'><b>Превращений: "..data[playerName].transforms.."</b></p>", name, 200, 230, 200, 20, 0x324650, 0x324650, 1, true)--19]]
  298. ui.addTextArea(19, "<p align='center'><b>"..lng[playerName][16].."</p><p align='left'>"..getTitles(playerName, 7).."</p><p align='center'><font size='12'><a href='event:full list'>"..lng[playerName][17].."</font></a></p></b>", name, 410, 110, 190, 135, 0x324650, 0x324650, 1, true)--20 21
  299. ui.addTextArea(20, "<p align='center'><b><a href='event:all awards'>"..lng[playerName][18].."</a></b></p>", name, 400, 260, 200, 20, 0x324650, 0x324650, 1, true)--22
  300. ui.addTextArea(21, "<p align='center'><b>"..lng[playerName][19].."</b><br><font size='10' color='#A4CF9E'>"..Obj[playerName].name.."</font></p>", name, 200, 260, 190, 40, 0x324650, 0x324650, 1, true)--23
  301. ui.addTextArea(22, "", name, s1, s2, Obj[playerName].size, Obj[playerName].sizeY, 0xffffff, 0xffffff, 0.5, true)
  302. ui.addTextArea(23, "<p align='center'><b></b></p>", name, 400, 110, 1, 260, 0x405763, 0x405763, 1, true)
  303. ui.addTextArea(24, "<p align='center'><b></b></p>", name, 200, 255, 400, 1, 0x405763, 0x405763, 1, true)
  304. ui.addTextArea(25, "<p align='center'><b></b></p>", name, 200, 105, 400, 1, 0x405763, 0x405763, 1, true)
  305. ui.addTextArea(26, "<p align='center'><a href='event:closeProfile'><b>"..lng[playerName][20].."</b></a></p>", name, 200, 370, 400, 17, 0x324650, 0x405763, 1, true)--24
  306.  
  307. --[[ui.addTextArea(35, "", name, 430, 280, 30, 30, 0xffffff, 0xffffff, 0.5, true)
  308. ui.addTextArea(36, "", name, 490, 280, 30, 30, 0xffffff, 0xffffff, 0.5, true)
  309. ui.addTextArea(37, "", name, 550, 280, 30, 30, 0xffffff, 0xffffff, 0.5, true)
  310. ui.addTextArea(38, "", name, 430, 325, 30, 30, 0xffffff, 0xffffff, 0.5, true)
  311. ui.addTextArea(39, "", name, 490, 325, 30, 30, 0xffffff, 0xffffff, 0.5, true)
  312. ui.addTextArea(40, "", name, 550, 325, 30, 30, 0xffffff, 0xffffff, 0.5, true)]]
  313. if playerName==name then
  314.         ui.addTextArea(27, "", name, 25, 55, 150, 100, 0x324650, 0x324650, 1, true)
  315.         ui.addTextArea(28, "<font size='13'><p align='center'><a href='event:help'><b><font color='#CB546B'>"..lng[playerName][21].."</font></a></font></p></b>", name, 35, 60, 130, 18, 0x324650, 0x405763, 1, true)--25
  316.         ui.addTextArea(29, "<font size='13'><p align='center'><a href='event:store'><b>"..lng[playerName][22].."</a></font></p></b>", name, 35, 95, 130, 18, 0x324650, 0x405763, 1, true)--26
  317.         ui.addTextArea(30, "<p align='center'><a href='event:inventory'><b>"..lng[playerName][23].."</a></font></p></b>", name, 35, 131, 130, 18, 0x324650, 0x405763, 1, true)--27
  318. end
  319. end
  320.  
  321. function giveTitle(playerName, numb)
  322. table.insert(data[playerName].titles, tostring(numb))
  323. end
  324. function showTitles(playerName, name)
  325. ui.addPopup(10, 0, "<p align='center'>"..lng[playerName][16].."</p><p align='left'><font color='#6C77C1'>"..getTitles(playerName).."</font></p>", name, 300, 100, 200, true)--21
  326. end
  327.  
  328. function showAwards(playerName, name, count)
  329.         if count<=3 then
  330.                 ySz=60
  331.         elseif count<=6 and count>3 then
  332.                 ySz=110
  333.         elseif count>6 and count<=9 then
  334.                 ySz=160
  335.         end
  336. ui.addTextArea(35, "", name, 300, 100, 200, ySz, 0x324650, 0x324650, 1, true)
  337. xtext=275
  338. ytext=115
  339. n=0
  340. while n<count do
  341. xtext=xtext+55
  342. if n==3 or n==6 or n==9 then
  343. xtext=330
  344. ytext=ytext+50
  345. end
  346. n=n+1
  347. --tfm.exec.addImage("imageName.png", "!n", xtext, ytext, name)
  348. ui.addTextArea(35+n, "", name, xtext, ytext, 30, 30, 0xffffff, 0xffffff, 1, true)
  349. end
  350. end
  351.  
  352. function setObj(playerName, id, size)
  353. Obj[playerName].id=id
  354. Obj[playerName].size=size
  355. closeObj(playerName)
  356. end
  357.  
  358. function getSkill(wins, loses, rounds)
  359. sk={}
  360. --print(48/2 + 48/50 - 0,04/10*100 + 50/100)
  361. LW=loses/wins
  362. --print(LW)
  363. if wins>1 and loses and rounds>=1 then
  364. Skill = (wins/loses + wins/rounds - LW/10) * 100 + rounds/100
  365. else
  366. Skill=0
  367. end
  368. for argument in string.gmatch(tostring(Skill), "[^%p]+") do
  369.                 table.insert(sk,argument)
  370. end
  371. Skill=tonumber(sk[1], 10)
  372. if Skill<=0 then
  373. Skill=0
  374. end
  375. return Skill
  376. end
  377.  
  378. function getTitles(playerName, count)
  379. if count==nil then
  380. count=99999
  381. end
  382. n=0
  383. str={}
  384. for k, v in pairs(titles) do
  385.         n=n+1
  386.         if table.contains(data[playerName].titles, tostring(k))~=false then
  387.                 if n<=count then
  388.                         table.insert(str, "• "..v.."<br>")
  389.                         --print(str)
  390.                 end
  391.         end
  392. end
  393. return table.concat(str)
  394. end
  395.  
  396. function closeObj(playerName)
  397.         if Obj[playerName].size==140 and Obj[playerName].id==4 then
  398.                 Obj[playerName].size=200
  399.         end
  400.         for i,id in ipairs({1,2,3,4,5,6,7,8,9,10,31,32,33,34}) do
  401.                 ui.removeTextArea(id, playerName)
  402.         end
  403. end
  404.  
  405. function closeProfile(playerName)
  406. Obj[playerName].sizeY=nil
  407.         for i,id in ipairs({11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30}) do
  408.                 ui.removeTextArea(id, playerName)
  409.         end
  410. end
  411.  
  412. function transform(playerName, x, y)
  413. tfm.exec.movePlayer(playerName, x, -185)
  414. obj[playerName]=tfm.exec.addShamanObject(Obj[playerName].id, x, y, 0, 0, 0, false)
  415. checkCoords[playerName]=true
  416. data[playerName].transforms=data[playerName].transforms+1
  417. end
  418.  
  419. function getRegDate()
  420. --[[function getMonth()
  421.         for i, k in pairs(months) do
  422.                 month=string.match(date, i)
  423.                 if month~=nil then
  424.                         month=k
  425.                         return month
  426.                 end
  427.         end
  428. end
  429. months={["Jan"]="01",["Feb"]="02",["Mar"]="03",["Apr"]="04",["May"]="05",["Jun"]="06",["Jul"]="07",["Aug"]="08",["Sep"]="09",["Oct"]="10",["Nov"]="11",["Dec"]="12"}
  430. date=os.date("!*t")
  431. day=string.sub(date, string.find(date, "([%d]+)"))
  432. month1=getMonth()
  433. year=string.match(date, "%d%d%d%d")
  434. newDate=day.."/"..month1.."/"..year]]
  435. newDate="Err#"
  436. return newDate
  437. end
  438.  
  439. function eventPlayerWon(playerName, timeElapsed, timeElapsedSinceRespawn)
  440. data[playerName].won=true
  441. data[playerName].wins=data[playerName].wins+1
  442. data[playerName].money=data[playerName].money+1
  443. if data[playerName].wins>=10 and table.contains(data[playerName].titles, "2")==false then
  444.         giveTitle(playerName, 2)
  445. elseif data[playerName].wins>=50 and table.contains(data[playerName].titles, "3")==false then
  446.         giveTitle(playerName, 3)
  447. elseif data[playerName].wins>=100 and table.contains(data[playerName].titles, "4")==false then
  448.         giveTitle(playerName, 4)
  449. elseif data[playerName].wins>=150 and table.contains(data[playerName].titles, "5")==false then
  450.         giveTitle(playerName, 5)
  451. elseif data[playerName].wins>=200 and table.contains(data[playerName].titles, "6")==false then
  452.         giveTitle(playerName, 6)
  453. elseif data[playerName].wins>=250 and table.contains(data[playerName].titles, "7")==false then
  454.         giveTitle(playerName, 7)
  455. elseif data[playerName].wins>=300 and table.contains(data[playerName].titles, "8")==false then
  456.         giveTitle(playerName, 8)
  457. end
  458. end
  459.  
  460. function eventPlayerDied(playerName)
  461. data[playerName].loses=data[playerName].loses+1
  462. data[playerName].won=true
  463. end
  464.  
  465. function eventTextAreaCallback(id,name,callback)--1 2 3 4 6 10 17 39 54
  466.         if callback=="sbox+plank" then
  467.                 Obj[name].id=1
  468.                 table.insert(data[name].obj, "1")
  469.                 Obj[name].id=4
  470.                 table.insert(data[name].obj, "4")
  471.                 Obj[name].size=200
  472.                 Obj[name].name=lng[name][28]--34
  473.                 closeObj(name)
  474.         end
  475.         if callback=="bbox+plank" then
  476.                 Obj[name].id=2
  477.                 table.insert(data[name].obj, "2")
  478.                 Obj[name].id=3
  479.                 table.insert(data[name].obj, "3")
  480.                 Obj[name].size=100
  481.                 Obj[name].name=lng[name][29]--35
  482.                 closeObj(name)
  483.         end
  484.         if callback=="ball" then
  485.                 if table.contains(data[name].obj, "6")~=true then
  486.                         ui.addPopup(1, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][25].."\"</font> "..lng[name][36].." 100 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 31
  487.                 else
  488.                 setObj(name, 6, 30)
  489.                 Obj[name].name=lng[name][25]--31
  490.                 end
  491.         end
  492.         if callback=="small box" then
  493.                         print(table.concat(data[name].obj))
  494.                 if table.contains(data[name].obj, "1")~=true then
  495.                         ui.addPopup(2, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][26].."\"</font> "..lng[name][36].." 50 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 32
  496.                 else
  497.                 setObj(name, 1, 30)
  498.                 Obj[name].name=lng[name][26]--32
  499.                 end
  500.         end
  501.         if callback=="big box" then
  502.                 if table.contains(data[name].obj, "2")~=true then
  503.                         ui.addPopup(3, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][27].."\"</font> "..lng[name][36].." 60 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 33
  504.                 else
  505.                 setObj(name, 2, 60)
  506.                 Obj[name].name=lng[name][27]--33
  507.                 end
  508.         end
  509.         if callback=="big plank" then
  510.                 if table.contains(data[name].obj, "4")~=true then
  511.                         ui.addPopup(4, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][28].."\"</font> "..lng[name][36].." 70 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 34
  512.                 else
  513.                 setObj(name, 4, 200)
  514.                 Obj[name].name=lng[name][28]--34
  515.                 end
  516.         end
  517.         if callback=="small plank" then
  518.                 if table.contains(data[name].obj, "3")~=true then
  519.                         ui.addPopup(5, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][29].."\"</font> "..lng[name][36].." 50 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 35
  520.                 else
  521.                 setObj(name, 3, 100)
  522.                 Obj[name].name=lng[name][29]--35
  523.                 end
  524.         end
  525.         if callback=="anvil" then
  526.                 if table.contains(data[name].obj, "10")~=true then
  527.                         ui.addPopup(6, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][30].."\"</font> "..lng[name][36].." 50 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 36
  528.                 else
  529.                 setObj(name, 10, 30)
  530.                 Obj[name].name=lng[name][30]--36
  531.                 end    
  532.         end
  533.         if callback=="cannon ball" then
  534.                 if table.contains(data[name].obj, "17")~=true then
  535.                         ui.addPopup(7, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][31].."\"</font> "..lng[name][36].." 60 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 37
  536.                 else
  537.                 setObj(name, 17, 30)
  538.                 Obj[name].name=lng[name][31]--37
  539.                 end    
  540.         end
  541.         if callback=="apple" then
  542.                 if table.contains(data[name].obj, "39")~=true then
  543.                         ui.addPopup(8, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][32].."\"</font> "..lng[name][36].." 150 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 38
  544.                 else
  545.                 setObj(name, 39, 30)
  546.                 Obj[name].name=lng[name][32]--38
  547.                 end
  548.         end
  549.         if callback=="icemice" then
  550.                 if table.contains(data[name].obj, "54")~=true then
  551.                         ui.addPopup(9, 1, "<p align='center'><b>"..lng[name][24].." <font color='#BABD2F'>\""..lng[name][33].."\"</font> "..lng[name][36].." 80 "..lng[name][37].."</b></p<", name, 300, 150, 200, true)--28 39
  552.                 else
  553.                 setObj(name, 54, 60)
  554.                 Obj[name].name=lng[name][33]--39
  555.                 end    
  556.         end
  557.         if callback=="closeProfile" then
  558.                 closeProfile(name)
  559.                 Obj[name].profile=false
  560.         end
  561.         if callback=="inventory" then
  562.                 inventory(name)
  563.                 closeProfile(name)
  564.         end
  565.         if callback=="store" then
  566.                 buyObj(name)
  567.                 closeProfile(name)
  568.         elseif callback=="closeStore" then
  569.                 closeObj(name)
  570.         end
  571.         if callback=="full list" then
  572.                 showTitles(Obj[name].titles, name)
  573.         end
  574.         if callback=="all awards" then
  575.        
  576.         end
  577. end
  578.  
  579. function eventPopupAnswer(id, playerName, answer)
  580.         if id==1 and answer=="yes" then
  581.                 if data[playerName].money>=100 then
  582.                         table.insert(data[playerName].obj, "6")
  583.                         data[playerName].money=data[playerName].money-100
  584.                         setObj(playerName, 6, 30)
  585.                                                 buyObj(playerName)
  586.                         Obj[playerName].name=lng[playerName][25]--31
  587.                 else
  588.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  589.                 end
  590.         end
  591.         if id==2 and answer=="yes" then
  592.                 if data[playerName].money>=50 then
  593.                         table.insert(data[playerName].obj, "1")
  594.                         data[playerName].money=data[playerName].money-50
  595.                         setObj(playerName, 1, 30)
  596.                                                 buyObj(playerName)
  597.                         Obj[playerName].name=lng[playerName][26]--32
  598.                 else
  599.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  600.                 end
  601.         end
  602.         if id==3 and answer=="yes" then
  603.                 if data[playerName].money>=50 then
  604.                         table.insert(data[playerName].obj, "2")
  605.                         data[playerName].money=data[playerName].money-50
  606.                         setObj(playerName, 2, 60)
  607.                                                 buyObj(playerName)
  608.                         Obj[playerName].name=lng[playerName][27]--33
  609.                 else
  610.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  611.                 end
  612.         end
  613.         if id==4 and answer=="yes" then
  614.                 if data[playerName].money>=70 then
  615.                         table.insert(data[playerName].obj, "4")
  616.                         data[playerName].money=data[playerName].money-70
  617.                         setObj(playerName, 4, 200)
  618.                                                 buyObj(playerName)
  619.                         Obj[playerName].name=lng[playerName][28]--34
  620.                 else
  621.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  622.                 end
  623.         end
  624.         if id==5 and answer=="yes" then
  625.                 if data[playerName].money>=50 then
  626.                         table.insert(data[playerName].obj, "3")
  627.                         data[playerName].money=data[playerName].money-50
  628.                         setObj(playerName, 3, 100)
  629.                                                 buyObj(playerName)
  630.                         Obj[playerName].name=lng[playerName][29]--35
  631.                 else
  632.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  633.                 end
  634.         end
  635.         if id==6 and answer=="yes" then
  636.                 if data[playerName].money>=50 then
  637.                         table.insert(data[playerName].obj, "10")
  638.                         data[playerName].money=data[playerName].money-50
  639.                         setObj(playerName, 10, 30)
  640.                                                 buyObj(playerName)
  641.                         Obj[playerName].name=lng[playerName][30]--36
  642.                 else
  643.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  644.                 end
  645.         end
  646.         if id==7 and answer=="yes" then
  647.                 if data[playerName].money>=60 then
  648.                         table.insert(data[playerName].obj, "17")
  649.                         data[playerName].money=data[playerName].money-60
  650.                         setObj(playerName, 17, 30)
  651.                                                 buyObj(playerName)
  652.                         Obj[playerName].name=lng[playerName][31]--37
  653.                 else
  654.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  655.                 end
  656.         end
  657.         if id==8 and answer=="yes" then
  658.                 if data[playerName].money>=150 then
  659.                         table.insert(data[playerName].obj, "39")
  660.                         data[playerName].money=data[playerName].money-150
  661.                         setObj(playerName, 39, 30)
  662.                                                 buyObj(playerName)
  663.                         Obj[playerName].name=lng[playerName][32]--38
  664.                 else
  665.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  666.                 end
  667.         end
  668.         if id==9 and answer=="yes" then
  669.                 if data[playerName].money>=80 then
  670.                         table.insert(data[playerName].obj, "54")
  671.                         data[playerName].money=data[playerName].money-80
  672.                         setObj(playerName, 54, 60)
  673.                                                 buyObj(playerName)
  674.                         Obj[playerName].name=lng[playerName][33]--39
  675.                 else
  676.                         ui.addPopup(1, 0, "<p align='center'><font color='#CB546B'>"..lng[playerName][34].."</font></p>", playerName, 300, 150, 200, true)--40
  677.                 end
  678.         end
  679. --ui.addPopup(1, 1, "<p align='center'><b></b></p<", playerName, x, y, 200, false)
  680. end
  681.  
  682. function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
  683.         if keyCode==32 and xPosition~=0 and yPosition~=0 and Obj[playerName].id~=nil and checkCoords[playerName]~=true and os.time() - wait[playerName] >= 1000 and tfm.get.room.playerList[playerName].isDead==false then
  684.                 if xPosition>mBorder1 and xPosition<mBorder2+10 then
  685.                         transform(playerName, xPosition, yPosition)
  686.                         wait[playerName]=os.time()
  687.                 end
  688.         elseif keyCode==32 and xPosition~=0 and yPosition~=0 and checkCoords[playerName]==true and os.time() - wait[playerName] >= 1000 then
  689.                 x[playerName] = tfm.get.room.objectList[obj[playerName]].x
  690.                 y[playerName] = tfm.get.room.objectList[obj[playerName]].y
  691.                 tfm.exec.removeObject(obj[playerName])
  692.                 tfm.exec.movePlayer(playerName, x[playerName], y[playerName])
  693.                 x[playerName]=nil
  694.                 y[playerName]=nil
  695.                 checkCoords[playerName]=nil
  696.                 obj[playerName]=nil
  697.                 wait[playerName]=os.time()
  698.         end
  699.         if keyCode==80 and Obj[playerName].size~=nil then
  700.                 Obj[playerName].sizeY=nil
  701.                 openProfile(playerName, Obj[playerName].size, playerName)
  702.         end
  703. end
  704.  
  705. function eventChatCommand(playerName, msg)
  706. local args={}
  707.         for argument in msg:gmatch("[^%s]+") do
  708.                 table.insert(args,argument)
  709.     end
  710.         if args[1]=="profile" and args[2]~=nil and data[args[2]]~=nil and args[3]==nil then
  711.                 openProfile(args[2], Obj[args[2]].size, playerName)
  712.         end
  713.         if args[1]=="title" and args[2]==nil then
  714.                 for k, v in pairs(data[playerName].titles) do
  715.                                 print("!title "..v.." -> "..titles[tonumber(v,10)])
  716.                 end
  717.         elseif args[1]=="title" and args[2]~=nil then
  718.                 if table.contains(data[playerName].titles, args[2])~=false then
  719.                         data[playerName].cTitle=titles[tonumber(args[2], 10)]
  720.                 end
  721.         end
  722.                 if args[1]=="lng" and args[2]=="en" then
  723.                         lng[playerName]=EN
  724.                 elseif args[2]=="ru" then
  725.                         lng[playerName]=RU
  726.                 end
  727.         if isAdmin(playerName)~=0 then
  728.         elseif args[1]=="b" and args[2]~=nil and args[3]~=nil and data[args[2]]~=nil then
  729.                 data[args[2]].isBanned=args[3].." "..getRegDate()
  730.                 print("<ROSE>"..args[2].." забанен "..getRegDate().." причина: "..args[3])--50
  731.         end
  732. end
  733.  
  734. function eventNewPlayer(playerName)
  735. updateMap()
  736. if data[playerName]==nil then
  737. data[playerName]={}
  738. data[playerName].regDate=getRegDate()
  739. data[playerName].name=playerName
  740. data[playerName].wins=0
  741. data[playerName].loses=0
  742. data[playerName].rounds=0
  743. data[playerName].transforms=0
  744. data[playerName].money=874
  745. data[playerName].skill=getSkill(data[playerName].wins, data[playerName].loses, data[playerName].rounds)
  746. data[playerName].isBanned=0
  747. data[playerName].titles={"1"}
  748. data[playerName].cTitle=titles[1]
  749. data[playerName].awards=nil
  750. data[playerName].obj={}
  751. lng[playerName]=EN
  752. print(data[playerName].skill)
  753. print("Skill: "..getSkill(data[playerName].wins, data[playerName].loses, data[playerName].rounds))
  754. Obj[playerName]={}
  755. buyObj(playerName)
  756. end
  757. -------------------------------------------------
  758. data[playerName].won=true
  759. tfm.exec.bindKeyboard(playerName, 32, true, true)
  760. tfm.exec.bindKeyboard(playerName, 80, true, true)
  761. wait[playerName]=os.time()
  762. end
  763. function getBorders()
  764. mBorder1=0
  765.         if tfm.get.room.xmlMapInfo.xml then
  766.                 --print("ok")
  767.                 if string.find(tfm.get.room.xmlMapInfo.xml, "<S>") and string.match(tfm.get.room.xmlMapInfo.xml:sub(0,string.find(tfm.get.room.xmlMapInfo.xml, "<S>")), "L=\"%d+\"") then
  768.                         mBorder2=string.match(tfm.get.room.xmlMapInfo.xml:sub(0,string.find(tfm.get.room.xmlMapInfo.xml, "<S>")), "L=\"%d+\"")
  769.                         --print(mBorder2)
  770.                         mBorder2=string.match(mBorder2, "%d+")
  771.                         mBorder2=tonumber(mBorder2, 10)
  772.                         if mBorder2<=800 then
  773.                                 mBorder2=805
  774.                         end
  775.                 else
  776.                 mBorder2=805
  777.                 end
  778.         end
  779.         if tfm.get.room.xmlMapInfo.xml==nil then
  780.                 mBorder2=805
  781.         end
  782. tfm.get.room.xmlMapInfo.xml=nil
  783. return mBorder2
  784. end
  785. function eventNewGame()
  786.         if tfm.get.room.xmlMapInfo then
  787.                 getBorders()
  788.         end
  789.         for name, p in pairs(tfm.get.room.playerList) do
  790.                                 data[name].skill=getSkill(data[name].wins, data[name].loses, data[name].rounds)
  791.                 data[name].rounds=data[name].rounds+1
  792.                 if data[name].won==true then
  793.                         data[name].won=false
  794.                 else
  795.                         data[name].loses=data[name].loses+1
  796.                 end
  797.                 wait[name]=os.time()+3000
  798.                 x[name]=nil
  799.                 y[name]=nil
  800.                 checkCoords[name]=nil
  801.                 obj[name]=nil
  802.         end
  803.                 updateMap()
  804. end
  805.  
  806. function eventLoop(tLeft, tRem)
  807.                 for name, p in pairs(tfm.get.room.playerList) do
  808.                                 if obj[name]~=nil and tfm.get.room.objectList[obj[name]].y~=nil and tfm.get.room.objectList[obj[name]].x~=nil and tfm.get.room.playerList[name].isDead==false then
  809.                 --print(tfm.get.room.objectList[obj[name]].y)
  810.                                                 if obj[name]~=nil then
  811.                                                                 if tfm.get.room.objectList[obj[name]].y>=405 then
  812.                                                                                 tfm.exec.killPlayer(name)
  813.                                                                                 tfm.get.room.objectList[obj[name]].y=nil
  814.                                                                                 tfm.get.room.objectList[obj[name]].x=nil
  815.                                                                                 tfm.exec.removeObject(obj[name])
  816.                                                                                 x[name]=nil
  817.                                                                                 y[name]=nil
  818.                                                                                 checkCoords[name]=nil
  819.                                                                                 obj[name]=nil
  820.                                                                                 wait[name]=os.time()
  821.                                                                 end
  822.                                                 end
  823.                                                 if obj[name]~=nil then
  824.                                                                 if tfm.get.room.objectList[obj[name]].x<mBorder1 then
  825.                                                                                 tfm.exec.movePlayer(name, 5, tfm.get.room.objectList[obj[name]].y)
  826.                                                                                 tfm.get.room.objectList[obj[name]].y=nil
  827.                                                                                 tfm.get.room.objectList[obj[name]].x=nil
  828.                                                                                 tfm.exec.removeObject(obj[name])
  829.                                                                                 x[name]=nil
  830.                                                                                 y[name]=nil
  831.                                                                                 checkCoords[name]=nil
  832.                                                                                 obj[name]=nil
  833.                                                                                 wait[name]=os.time()
  834.                                                                 end
  835.                                                 end
  836.                                                 if obj[name]~=nil then
  837.                                                                 if tfm.get.room.objectList[obj[name]].x>mBorder2 then
  838.                                                                                 tfm.exec.movePlayer(name, mBorder2-5, tfm.get.room.objectList[obj[name]].y)
  839.                                                                                 tfm.get.room.objectList[obj[name]].y=nil
  840.                                                                                 tfm.get.room.objectList[obj[name]].x=nil
  841.                                                                                 tfm.exec.removeObject(obj[name])
  842.                                                                                 x[name]=nil
  843.                                                                                 y[name]=nil
  844.                                                                                 checkCoords[name]=nil
  845.                                                                                 obj[name]=nil
  846.                                                                                 wait[name]=os.time()
  847.                                                                 end
  848.                                                 end
  849.                                 end
  850.                                 if data[name].isBanned~=0 then
  851.                         tfm.exec.killPlayer(name)
  852.                 end
  853.                 end
  854. end
  855. for name, p in pairs(tfm.get.room.playerList) do
  856.         eventNewPlayer(name)
  857. end
  858. system.disableChatCommandDisplay("profile", true)
  859. system.disableChatCommandDisplay("title", true)
  860. tfm.exec.newGame()
  861. --showAwards(nil, "Bushmeister", 3)
  862. --print(isAdmin("Bushmeister"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement