Advertisement
Dudugz-Contistente

Untitled

Jan 3rd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.19 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame()
  2. tfm.exec.disableAutoShaman()
  3. tfm.exec.disableAutoTimeLeft()
  4. tfm.exec.disableAutoScore()
  5.  
  6. colors = {
  7. bar = 0x696969,
  8. hot_unselected = 0x7a7a7a,
  9. hot_selected = 0x878787
  10. }
  11.  
  12. shop = {
  13. {n="Varinha",img="1596513dd70.png",price=10,dmg=5},
  14. {n="Taco de baseball",img="1596513ff8c.png",price=32,dmg=7},
  15. {n="Taco de golf",img="159651429a0.png",price=56,dmg=9},
  16. {n="Espada",img="15965145722.png",price=78,dmg=12},
  17. {n="Picareta",img="15965148ea9.png",price=122,dmg=15},
  18. {n="Machado",img="1596514b69b.png",price=143,dmg=18},
  19. {n="Pé de cabra",img="1596514d4d6.png",price=168,dmg=27},
  20. }
  21.  
  22. keys = {48,49,50,51,52,53,54,55,56,57}
  23.  
  24. local npcs={}
  25. local time_spawn = os.time();
  26. local p = {}
  27.  
  28. local mapas = {"@6978537",'<C><P L="3000" D="x_deadmeat/x_zone/x_200.jpg,1541,-461;x_deadmeat/x_campement/repos_fond.jpg,-378,-280" Ca="" /><Z><S><S L="3000" H="10" X="1457" Y="404" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="3000" X="1" H="10" Y="316" T="14" P="0,0,0,0,90,0,0,0" /></S><D /><O /></Z></C>'}
  29.  
  30. local zombies={
  31. {"15922b9ad4d.png", "15923a3e2d4.png", 115, 23, 92, "Zombie", 20, 3,4},
  32. {"159237ccbfd.png", "15923a3555b.png", 115, 23, 92, "Zombie", 30, 6,8},
  33. {"159237ce30f.png", "15923a37f86.png", 115, 23, 92, "Zombie", 40, 12,12},
  34. {"159238d77a9.png", "15923a3a9a7.png", 50, 23, 25, "Drekke", 60, 18,16},
  35. {"15927206568.png", "15927208310.png", 50, 21, 42,"Ghost", 80, 10,22}
  36. }
  37.  
  38. textarea=ui.addTextArea
  39. function ui.addTextArea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss,black_marcation,ground_marcation)
  40. --if not backgroundColor then backgroundColor=0x324650 end
  41. --if not borderColor then borderColor=0x000001 end
  42. if black_marcation then
  43. textarea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
  44. end
  45.  
  46. if ground_marcation then
  47. textarea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
  48. end
  49. textarea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
  50. end
  51.  
  52. function eventNewPlayer(name)
  53. p[name]={
  54. damage=5,
  55. delete="",
  56. delete2="",
  57. tempo = os.time(),
  58. life = 50,
  59. maxLife = 50,
  60. img = '',
  61. hot_selected = {1,152,"15926ee8777.png"},
  62. hot_items = {},
  63. coins = 0
  64. }
  65.  
  66.  
  67. p[name].hot_items[0]={img="",dmg=0}
  68. p[name].hot_items[1]={img="15926ee8777.png",dmg=3}
  69. p[name].hot_items[2]={img="",dmg=0}
  70. p[name].hot_items[3]={img="",dmg=0}
  71. p[name].hot_items[4]={img="",dmg=0}
  72. p[name].hot_items[5]={img="",dmg=0}
  73. p[name].hot_items[6]={img="",dmg=0}
  74. p[name].hot_items[7]={img="",dmg=0}
  75. p[name].hot_items[8]={img="",dmg=0}
  76. p[name].hot_items[9]={img="",dmg=0}
  77.  
  78. ui.addTextArea(-1,"",name,150,28,500,35,colors.bar,colors.bar,80,true)
  79. ui.addTextArea(0,"<p align='left'><font color='#000000'>0",name,609,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  80. ui.addTextArea(1,"<p align='left'><font color='#000000'>1",name,152,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  81. ui.addTextArea(2,"<p align='left'><font color='#000000'>2",name,203,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  82. ui.addTextArea(3,"<p align='left'><font color='#000000'>3",name,254,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  83. ui.addTextArea(4,"<p align='left'><font color='#000000'>4",name,305,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  84. ui.addTextArea(5,"<p align='left'><font color='#000000'>5",name,355,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  85. ui.addTextArea(6,"<p align='left'><font color='#000000'>6",name,406,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  86. ui.addTextArea(7,"<p align='left'><font color='#000000'>7",name,457,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  87. ui.addTextArea(8,"<p align='left'><font color='#000000'>8",name,508,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  88. ui.addTextArea(9,"<p align='left'><font color='#000000'>9",name,558,30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  89.  
  90. ui.addTextArea(p[name].hot_selected[1],"<p align='left'><font color='#ffffff'>"..p[name].hot_selected[1],name,p[name].hot_selected[2],30,40,32,colors.hot_selected,colors.hot_unselected,80,true)
  91. tfm.exec.setPlayerScore(name, 0, false)
  92. n = name
  93.  
  94. tfm.exec.addImage(p[n].hot_items[0].img, "&0", 609, 32,n);
  95. tfm.exec.addImage(p[n].hot_items[1].img, "&1", 152, 32,n);
  96. tfm.exec.addImage(p[n].hot_items[2].img, "&2", 203, 32,n);
  97. tfm.exec.addImage(p[n].hot_items[3].img, "&3", 254, 32,n);
  98. tfm.exec.addImage(p[n].hot_items[4].img, "&4", 305, 32,n);
  99. tfm.exec.addImage(p[n].hot_items[5].img, "&5", 355, 32,n);
  100. tfm.exec.addImage(p[n].hot_items[6].img, "&6", 406, 32,n);
  101. tfm.exec.addImage(p[n].hot_items[7].img, "&7", 457, 32,n);
  102. tfm.exec.addImage(p[n].hot_items[8].img, "&8", 508, 32,n);
  103. tfm.exec.addImage(p[n].hot_items[9].img, "&9", 558, 32,n);
  104. ui.addTextArea(50,"<p align='center'><VI><a href='event:shop'><B><I>Loja</a>",name,725,370,65,20,nil,0x324645,nil,true,true)
  105.  
  106. system.bindKeyboard(name,32,true,true) system.bindKeyboard(name,37,true,true) system.bindKeyboard(name,39,true,true)
  107. system.bindKeyboard(name,48,true,true) system.bindKeyboard(name,49,true,true) system.bindKeyboard(name,50,true,true)
  108. system.bindKeyboard(name,51,true,true) system.bindKeyboard(name,52,true,true) system.bindKeyboard(name,53,true,true)
  109. system.bindKeyboard(name,54,true,true) system.bindKeyboard(name,55,true,true) system.bindKeyboard(name,56,true,true)
  110. system.bindKeyboard(name,57,true,true)
  111.  
  112. lifeBar(name)
  113. tfm.exec.chatMessage("<CE>Bem-vindo ao Dead Challenge</CE><br><J>Em manutenção...</J>",name)
  114. end
  115.  
  116. function eventTextAreaCallback(id,name,link)
  117. if link == "shop" then
  118. ui.addTextArea(51,"",name,150,75,500,300,nil,0x324650,nil,true,true)
  119. ui.addTextArea(52,"<p align='center'><J><font size='15'><B>Loja",name,148,77,504,22,nil,0x324645,nil,true,true)
  120. ui.addTextArea(53,"<font size='13'><p align='center'><R><B><a href='event:close'>Fechar</a>",name,152,352,496,20,0x1a2b30,0x1a2b30,nil,true,true)
  121. ui.addTextArea(54,"<p align='center'><J><font size='12'><B><VP>"..p[name].coins.." R$",name,542,318,100,22,nil,0x324645,nil,true,true)
  122. grids(name)
  123. end
  124.  
  125. if link == "close" then
  126. for i,v in pairs({51,52,53,54}) do
  127. ui.removeTextArea(v,name)
  128. ui.removeTextArea(6969+v,name)
  129. ui.removeTextArea(7979+v,name)
  130. end
  131.  
  132. for i,v in pairs(ids) do
  133. ui.removeTextArea(v,name)
  134. ui.removeTextArea(6969+v,name)
  135. ui.removeTextArea(7979+v,name)
  136. end
  137.  
  138. for i,v in pairs(images_grid) do
  139. tfm.exec.removeImage(v)
  140. end
  141. end
  142.  
  143. for i,v in pairs(shop) do
  144. if link == "info-"..v.n then
  145. ui.addPopup(0,3,"<p align='center'><B><I><font color='#ffcc00'>Informações do(a) "..v.n.."</font><br><font color='#C53DFF'>Preço:</font> "..v.price.." R$<br><font color='#2ECF73'>Dano de Attack:</font> "..v.dmg,name,151,170,499,true)
  146. end
  147. end
  148. end
  149.  
  150. function grids(name)
  151. x_ = 104
  152. c = 0
  153. y_ = 115
  154. v = 0
  155.  
  156. images_grid = {}
  157.  
  158. ids={}
  159. for i,v in pairs(shop) do
  160. x_ = x_+50
  161. c = c+1
  162.  
  163. addGrid(c,v.img,"Buy",x_,y_,name,v.n)
  164. end
  165. end
  166.  
  167. function addGrid(id,img,buttonText,x,y,name,item)
  168. id = 8989+id
  169. id2 = 4949+id
  170. id3 = 3939+id
  171. ui.addTextArea(id,"",name,x,y,80,78,0x0b161c,0x0b161c,nil,true)
  172. ui.addTextArea(id2,"<p align='center'><B><J>"..buttonText,name,x+1,y+61,30,16,0x38516b,0x38516b,nil,true)
  173. ui.addTextArea(id3,"<p align='center'><B><V><a href='event:info-"..item.."'>Info<</a>",name,x+42,y+61,37,16,0x38516b,0x38516b,nil,true)
  174. img = tfm.exec.addImage(img, "&0", x+15, y+8,name);
  175.  
  176. table.insert(images_grid,img)
  177. x_=x_+52
  178.  
  179. v=v+1
  180. if v == 5 then
  181. x_ = 104
  182. y_ = y_+100
  183. v=0
  184. end
  185.  
  186. table.insert(ids,id)
  187. table.insert(ids,id2)
  188. table.insert(ids,id3)
  189. end
  190.  
  191. function eventPlayerDied(name)
  192. vivos=vivos-1;
  193.  
  194. if vivos == 0 then
  195. tfm.exec.newGame(mapas[math.random(#mapas)])
  196. end
  197. end
  198.  
  199. function eventNewGame()
  200. tfm.exec.setGameTime(9999999)
  201. npcs = {}
  202.  
  203. for id=200,400 do
  204. ui.removeTextArea(id,nil)
  205. end
  206.  
  207. vivos = 0
  208.  
  209. for n, i in pairs(tfm.get.room.playerList) do
  210. p[n].life = p[n].maxLife
  211. lifeBar(n)
  212. vivos=vivos+1;
  213. end
  214.  
  215. end
  216.  
  217. function eventKeyboard(name,key,down,x,y)
  218. if key == 32 and p[name].tempo < os.time()-800 then
  219. for n,v in pairs(npcs) do
  220. if x >= tfm.get.room.objectList[v.id].x - 25 and x <= tfm.get.room.objectList[v.id].x + 25 and y >= tfm.get.room.objectList[v.id].y - 25 and y <= tfm.get.room.objectList[v.id].y + 25 and not tfm.get.room.playerList[name].isDead then
  221. itm = p[name].hot_selected[1]
  222. v.life = v.life-p[name].hot_items[itm].dmg
  223. p[name].tempo = os.time();
  224.  
  225. if v.life < 1 then
  226. tfm.exec.setPlayerScore(name,math.random(12),true)
  227. p[name].delete = v.id
  228. p[name].delete2 = n
  229. if p[name].life < p[name].maxLife then
  230. p[name].life = p[name].life+math.random(5,20)
  231. end
  232.  
  233. if p[name].life > p[name].maxLife then
  234. p[name].life = p[name].maxLife
  235. end
  236.  
  237. lifeBar(name)
  238. end
  239. end
  240. end
  241. end
  242.  
  243. if p[name].delete ~= '' then
  244. ui.removeTextArea(p[name].delete,nil)
  245. table.remove(npcs,p[name].delete2)
  246. tfm.exec.removeObject(p[name].delete)
  247. p[name].delete = ''
  248. end
  249.  
  250. if key_def(key) then
  251. ui.addTextArea(p[name].hot_selected[1],"<p align='left'><font color='#000000'>"..p[name].hot_selected[1],name,p[name].hot_selected[2],30,40,32,colors.hot_unselected,colors.hot_unselected,80,true)
  252. p[name].hot_selected = {key_number(key),key_x(key_number(key)),initial_item}
  253. ui.addTextArea(p[name].hot_selected[1],"<p align='left'><font color='#ffffff'>"..p[name].hot_selected[1],name,p[name].hot_selected[2],30,40,32,colors.hot_selected,colors.hot_unselected,80,true)
  254. end
  255. end
  256.  
  257. -- Sistema de vida por Fofinhoppp
  258. -- 21/12/2016
  259. function lifeBar(player)
  260. if not p[player] then return end
  261. local mLife = p[player].maxLife
  262. local life = p[player].life
  263. ui.addTextArea(10, '', player, -13, 25, 10, 370, 0xFF0000, 0xFF0000, 1, true)
  264. ui.addTextArea(11, '', player, -13, 395-(370/mLife)*life, 10, (370/mLife)*life, 0x00FF00, 0x00FF00, 1, true)
  265. ui.addTextArea(12, '', player, -15, 0, 10, 440, 0x6a7595, 0x6a7595, 1, true)
  266. end
  267.  
  268. function eventLoop()
  269. if time_spawn < os.time()-3000 and #npcs < 20 then
  270. local monster = tfm.exec.addShamanObject(6300,math.random(10,3000),math.random(20,360))
  271. local imagem = zombies[math.random(#zombies)]
  272. local image = tfm.exec.addImage(imagem[math.random(1,2)], "#"..monster, -imagem[4], -imagem[5])
  273. local vida = math.random(10,imagem[7])
  274.  
  275.  
  276. table.insert(npcs,{id=monster,maxLife=vida,life=vida,damage=math.random(1,imagem[8]),img=image,textareaHeight=imagem[3],name=imagem[6],type = imagem,coins=math.random(1,imagem[9])})
  277. time_spawn = os.time();
  278. end
  279.  
  280. for i,v in pairs(npcs) do
  281. for n,pi in pairs(tfm.get.room.playerList) do
  282. if pi.x >= tfm.get.room.objectList[v.id].x - 12 and pi.x <= tfm.get.room.objectList[v.id].x + 12 and pi.y >= tfm.get.room.objectList[v.id].y - 25 and pi.y <= tfm.get.room.objectList[v.id].y + 25 and not tfm.get.room.playerList[n].isDead then
  283. p[n].life = p[n].life-v.damage
  284. lifeBar(n)
  285. if p[n].life < 1 then
  286. p[n].life = 0
  287. tfm.exec.killPlayer(n)
  288. end
  289. end
  290.  
  291. if pi.x >= tfm.get.room.objectList[v.id].x - 180 and pi.x <= tfm.get.room.objectList[v.id].x + 180 and pi.y >= tfm.get.room.objectList[v.id].y - 50 and pi.y <= tfm.get.room.objectList[v.id].y + 50 and not tfm.get.room.playerList[n].isDead then
  292. if pi.x > tfm.get.room.objectList[v.id].x then
  293. tfm.exec.moveObject(v.id,0,0,false,10,0,true)
  294. tfm.exec.removeImage(v.img)
  295. tfm.exec.addImage(v.type[2], '#'..v.id, -v.type[4], -v.type[5])
  296. elseif pi.x < tfm.get.room.objectList[v.id].x then
  297. tfm.exec.moveObject(v.id,0,0,false,-10,0,true)
  298. tfm.exec.removeImage(v.img)
  299. tfm.exec.addImage(v.type[1], '#'..v.id, -v.type[4], -v.type[5])
  300. end
  301.  
  302. if pi.x < tfm.get.room.objectList[v.id].y then
  303. tfm.exec.moveObject(v.id,0,0,false,0,-15,true)
  304. end
  305.  
  306. pular = math.random(0,5)
  307.  
  308. if pular == 2 then
  309. tfm.exec.moveObject(v.id,0,0,false,0,-30,true)
  310. end
  311.  
  312. ui.addTextArea(v.id,"<V>"..v.name.."<br><VI><font color='#FF0000'>♥ </font>"..v.life.."/"..v.maxLife.."</CR>",n,tfm.get.room.objectList[v.id].x-30,tfm.get.room.objectList[v.id].y-v.textareaHeight,50,nil,nil,0,70,false)
  313. else
  314. ui.removeTextArea(v.id,n)
  315. end
  316. end
  317. end
  318. end
  319.  
  320. function key_def(key)
  321. returno = false
  322. for i,v in pairs(keys) do
  323. if key == v then
  324. retorno = true
  325. end
  326. end
  327.  
  328. if key == 32 or key == 37 or key == 39 then
  329. retorno = false
  330. end
  331.  
  332. return retorno
  333. end
  334.  
  335. function key_number(key)
  336. keys_num = {}
  337. keys_num[48] = 0
  338. keys_num[49] = 1
  339. keys_num[50] = 2
  340. keys_num[51] = 3
  341. keys_num[52] = 4
  342. keys_num[53] = 5
  343. keys_num[54] = 6
  344. keys_num[55] = 7
  345. keys_num[56] = 8
  346. keys_num[57] = 9
  347. return keys_num[key]
  348. end
  349.  
  350. function key_x(key)
  351. keys_x = {}
  352. keys_x[0] = 609
  353. keys_x[1] = 152
  354. keys_x[2] = 203
  355. keys_x[3] = 254
  356. keys_x[4] = 305
  357. keys_x[5] = 355
  358. keys_x[6] = 406
  359. keys_x[7] = 457
  360. keys_x[8] = 508
  361. keys_x[9] = 558
  362. return keys_x[key]
  363. end
  364.  
  365. for all in pairs(tfm.get.room.playerList) do
  366. eventNewPlayer(all)
  367. end
  368.  
  369. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement