Advertisement
Dudugz-Contistente

Untitled

Aug 24th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.21 KB | None | 0 0
  1. tfm.exec.disableAutoShaman()
  2. tfm.exec.disableAutoNewGame()
  3. tfm.exec.disableAutoScore()
  4. tfm.exec.disableAfkDeath()
  5.  
  6. balls={}
  7.  
  8. textarea=ui.addTextArea
  9. function ui.newAddTxtA(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
  10. textarea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
  11. textarea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
  12. textarea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
  13. end
  14.  
  15.  
  16. math.inSquare = function(x1,y1,r1,x2,y2,r2)
  17. return (x1 + r1 > x2 - r2 and x1 - r1 < x2 + r2) and (y1 + r1 > y2 - r2 and y1 - r1 < y2 + r2)
  18. end
  19.  
  20. function showPlay(id)
  21. local n = ''
  22.  
  23. for i,v in pairs(tfm.get.room.playerList) do if v.id == id then n = i break end end
  24.  
  25. ui.addTextArea(1,'',n,-300,-200,9999,9999,0x0001,0x0001,1,true)
  26. ui.removeTextArea(0,n)
  27. ui.newAddTxtA(2,"",n,350,200,200,100,0x142730,0x142730,nil,true)
  28. ui.addTextArea(3,"<p align='center'><font size='50' color='#6A8FA2' face='Berlin Sans FB'><B>Agar.io</B></font></p>",n,302,102-0.5,300,150,0,0,0,true)
  29. ui.addTextArea(4,"<p align='center'><font size='50' color='#F8F8FF' face='Berlin Sans FB'><B>Agar.io</B></font></p>",n,300,100,300,150,0,0,0,true)
  30. ui.newAddTxtA(5,"<p align='center'><font size='13' color='#F8F8FF'><a href='event:play'>Play game</a></font></p>",n,352,202,100,20,0x324650,0x324650,nil,true)
  31. ui.newAddTxtA(6,"<p align='center'><font size='10' color='#F8F8FF'><a href='event:editName'>"..data[n].n.."</a></font></p>",n,352,235,100,20,0x324650,0x324650,nil,true)
  32. ui.newAddTxtA(7,"<p align='center'><font size='10' color='#F8F8FF'>"..data[n].points.."</font></p>",n,352,270,100,20,0x324650,0x324650,nil,true)
  33. ui.newAddTxtA(8,"<p align='center'><font size='10' color='"..data[n].color2.."'><a href='event:skinColor'>Color Skin</a></font></p>",n,465,202,80,20,0x324650,0x324650,nil,true)
  34. end
  35.  
  36. function positionTest()
  37. local ballsToRemove={}
  38. for n in pairs(tfm.get.room.playerList) do
  39. if not data[n].isDead[1] then
  40. if os.time() > data[n].capture then
  41. data[n].capture = os.time() + 5000
  42.  
  43. for k,v in pairs(balls) do
  44. if math.inSquare(v.x,v.y,v.size,data[n].coord[1],data[n].coord[2],(data[n].size/(data[n].divide/2)) + 4) then
  45. data[n].size = data[n].size + v.size/2
  46. data[n].points = data[n].points + v.size/2 + math.random(-5.0,5.0)
  47. tfm.exec.setPlayerScore(n,math.floor(data[n].points),false)
  48. data[n].speed = data[n].speed + (15/100) * 10
  49.  
  50. local d = math.random(1,4)
  51. if d == 2 or v == d then
  52. data[n].divide=data[n].divide+1
  53. end
  54.  
  55. ui.removeTextArea(v.id,nil)
  56. table.insert(ballsToRemove,k)
  57. end
  58. end
  59.  
  60. for k,v in next,data do
  61. if n ~= getName(v.id) and not data[n].isDead[1] and not v.isDead[1] then
  62. if data[n].size > data[getName(v.id)].size and math.inSquare(v.coord[1],v.coord[2],v.size,data[n].coord[1],data[n].coord[2],(data[n].size/2) + 4) then
  63. data[n].size = data[n].size + v.size/2
  64. data[n].points = data[n].points + v.size/2 + math.random(-5.0,5.0)
  65. tfm.exec.setPlayerScore(n,math.floor(data[n].points),false)
  66. data[n].speed = data[n].speed + (15/100) * v.speed
  67.  
  68. local d = math.random(1,4)
  69. if d == 2 or d == 4 then
  70. data[n].divide=data[n].divide+1
  71. end
  72.  
  73. ui.removeTextArea(v.id,nil)
  74. ui.removeTextArea(-v.id,nil)
  75. ui.removeTextArea(0,v.n)
  76.  
  77. showPlay(v.id)
  78.  
  79. v.isDead = {true,os.time() + 10000}
  80. v.size = 10
  81. v.speed = 5
  82.  
  83. data[n].capture = 0
  84. break
  85. end
  86. end
  87. end
  88. end
  89. end
  90. end
  91.  
  92. for i,v in pairs(ballsToRemove) do
  93. table.remove(balls,v)
  94. end
  95.  
  96. ballsToRemove={}
  97. end
  98.  
  99. data = {}
  100. eventNewPlayer = function(n)
  101. if not data[n] then
  102. data[n] = {
  103. n = n,
  104. id = tfm.get.room.playerList[n].id,
  105. isDead = {true,0},
  106. capture = 0,
  107. size = 10,
  108. speed = 5,
  109. boost = {0,0,0}, -- speed, end, is boosting
  110. color = 0xFFFFFF,
  111. color2 = '#FFFFFF',
  112. coord = {math.random(10,1600),math.random(20,380)},
  113. dir = {0,0},
  114. divide=2,
  115. timeToMove=0,
  116. points=0,
  117. }
  118. end
  119. for k,v in next,{37,38,39,40,65,68,83,87,32,string.byte("POB",1,3)} do
  120. system.bindKeyboard(n,v,true,true)
  121. system.bindKeyboard(n,v,false,true)
  122. end
  123.  
  124. ui.addTextArea(1,'',n,-300,-200,9999,9999,0x0001,0x0001,1,false)
  125. showPlay(data[n].id)
  126. tfm.exec.setPlayerScore(n,data[n].points,false)
  127. end
  128. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  129.  
  130. eventNewGame = function()
  131. --table.foreach(tfm.get.room.playerList,tfm.exec.killPlayer)
  132. tfm.exec.setGameTime(9999999)
  133. end
  134.  
  135. spawnCollectiveBalls=function()
  136. if #balls < 30 then
  137. local id=-#balls
  138. local x=math.random(10,1590)
  139. local y=math.random(20,370)
  140. local size=math.random(5,20)
  141. local color=math.random(0,0xFFFFFF)
  142.  
  143. table.insert(balls,{id=id,x=x,y=y,size=size,color=color})
  144. ui.addTextArea(id,"",nil,x,y,size/2,size/2,color,color,1,false)
  145. end
  146. end
  147.  
  148. function eventPlayerDied(name)
  149. tfm.exec.respawnPlayer(name)
  150. end
  151.  
  152. eventLoop = function(currentTime)
  153. spawnCollectiveBalls()
  154. if currentTime / 1000 > 3 then
  155. UpdateAll()
  156. end
  157. end
  158.  
  159. function UpdateAll()
  160. for k,v in next,data do
  161. if not v.isDead[1] then
  162. v.coord[1] = v.coord[1] + v.dir[1]
  163. v.coord[2] = v.coord[2] + v.dir[2]
  164.  
  165. if data[getName(v.id)] and data[getName(v.id)].timeToMove < os.time()-800 then
  166. local n = getName(v.id)
  167. tfm.exec.movePlayer(n,data[n].coord[1],0,false)
  168. data[n].timeToMove=os.time();
  169. end
  170.  
  171. positionTest()
  172.  
  173. if v.coord[1] < 1 then
  174. v.coord[1] = 1600
  175. elseif v.coord[1] > 1600 then
  176. v.coord[1] = 1
  177. end
  178.  
  179. if v.coord[2] < 1 then
  180. v.coord[2] = 400
  181. elseif v.coord[2] > 400 then
  182. v.coord = 10
  183. end
  184.  
  185. if v.boost[3] == 1 then
  186. if v.boost[2] > 0 then
  187. v.boost[2] = v.boost[2] - .5
  188. else
  189. v.boost[2] = 0
  190. v.boost[3] = 0
  191. v.speed = v.boost[1]
  192. end
  193. else
  194. if v.boost[2] < 4.5 then
  195. v.boost[2] = v.boost[2] + .05
  196. end
  197. end
  198.  
  199. n=getName(v.id)
  200.  
  201. ui.addTextArea(v.id,"",nil,v.coord[1],v.coord[2],v.size/v.divide,v.size/v.divide,v.color,v.color,0.5,false)
  202. ui.addTextArea(-v.id,"<font size='8' color='#E6FF00'>" .. v.n,nil,v.coord[1] - 10 - #v.n,v.coord[2] - (v.size/v.divide) - 15,nil,nil,1,1,0,false)
  203. ui.addTextArea(0,string.format("X: %s\nY: %s\nMass: %s\nSpeed: %s\nBoost: %s\nPoints: %s",v.coord[1],v.coord[2],math.floor(v.size),v.speed,v.boost[2],v.points),n,0,30,120,100,1,1,0,true)
  204. else
  205. n=getName(v.id)
  206. for k,d in next,data do
  207. ui.removeTextArea(d.id,n)
  208. ui.removeTextArea(-d.id,n)
  209. end
  210.  
  211. tfm.exec.setPlayerScore(n,-1,false)
  212. end
  213. end
  214. end
  215.  
  216. function eventPopupAnswer(id,n,answer)
  217. if id == 0 and #answer ~= 0 then
  218. local n2 = ''
  219.  
  220. for i=1,#answer do
  221. if i <= 12 then
  222. n2=n2..answer:sub(i,i)
  223. end
  224. end
  225.  
  226. data[n].n=n2
  227. showPlay(data[n].id)
  228. end
  229. end
  230.  
  231. function eventTextAreaCallback(id,n,link)
  232. if link == "play" then
  233. for i=2,8 do
  234. ui.removeTextArea(i,n)ui.removeTextArea(6969+i,n)ui.removeTextArea(7979+i,n)
  235. end
  236.  
  237. ui.addTextArea(1,'',n,-300,-200,9999,9999,0x0001,0x0001,1,false)
  238.  
  239. for i,v in pairs(balls) do
  240. v.color=math.random(0,0xFFFFFF)
  241. ui.addTextArea(v.id,"",n,v.x,v.y,v.size/2,v.size/2,v.color,v.color,1,false)
  242. end
  243.  
  244. data[n].isDead = {false,0}
  245. data[n].coord = {math.random(10,790),math.random(40,380)}
  246. data[n].size = 10
  247. data[n].points = 0
  248. tfm.exec.movePlayer(n,data[n].coord[1],0,false)
  249. tfm.exec.setPlayerScore(n,data[n].points,false)
  250. end
  251.  
  252. if link == "editName" then
  253. v=data[n]
  254. ui.addPopup(0,2,'<p align="center"><B>Troca de Nome</B></p>Seu nome atual é <B>'..v.n..'</B>.',n,352,202,196,true)
  255. end
  256.  
  257. if link == "skinColor" then
  258. ui.showColorPicker(0,n,data[n].color,"Color Skin")
  259. end
  260. end
  261.  
  262. getName=function(id)
  263. local n = nil
  264. for i,d in pairs(tfm.get.room.playerList) do if d.id == id then n = i break end end
  265. return n
  266. end
  267.  
  268. eventKeyboard = function(n,k,d)
  269. if k == string.byte("B") then
  270. if data[n].boost[2] > .5 then
  271. data[n].boost[3] = d and 1 or 0
  272. if d then
  273. data[n].size=data[n].size-0.01
  274. data[n].boost[1] = data[n].speed
  275. data[n].speed = data[n].speed * 2.5
  276. else
  277. data[n].speed = data[n].boost[1]
  278. end
  279. end
  280. elseif k == string.byte("P") then
  281.  
  282. elseif k == string.byte("O") then
  283. --ui.showColorPicker(0,n,data[n].color,"Square")
  284. else
  285. if k == 37 then
  286. data[n].dir = {-data[n].speed,0}
  287. elseif k == 39 then
  288. data[n].dir = {data[n].speed,0}
  289. elseif k == 38 then
  290. data[n].dir = {0,-data[n].speed}
  291. elseif k == 40 then
  292. data[n].dir = {0,data[n].speed}
  293. end
  294. end
  295. end
  296.  
  297. eventColorPicked = function(i,n,c)
  298. if not c ~= "-1" and c ~= -1 and c ~= "0x0" then
  299. data[n].color = '0x'..string.format("%x", c)
  300. data[n].color2='#'..string.format("%x", c)
  301. showPlay(data[n].id)
  302. end
  303. end
  304.  
  305. tfm.exec.newGame('<C><P L="1600" /><Z><S><S L="3000" o="1" H="10" X="1501" Y="396" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,,0.2,090,0,0,0" L="3000" o="1" X="0" Y="256" T="12" H="10" /><S L="3000" o="1" X="1600" H="10" Y="207" T="12" P="0,0,,0.2,090,0,0,0" /></S><D /><O /></Z></C>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement