Advertisement
Guest User

Camera man

a guest
Dec 28th, 2017
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.05 KB | None | 0 0
  1. tfm.exec.disableAutoShaman()
  2. tfm.exec.disableAutoNewGame(true)
  3. local H = os.date("%H")-3
  4.  
  5. Admin = "Rianmojang1"
  6.  
  7. local data, battery = {}, {loop = {20,40}, x = math.random(10,790), y = math.random(200,380)}
  8. local npc = {
  9. time = 50,
  10. damage = math.random(2,5),
  11. position = {x = math.random(10,3000), y = math.random(100,800)},
  12. }
  13. local gameTime = 0
  14.  
  15. function eventNewPlayer(name)
  16. data[name] = {
  17. camera = {
  18. open = false,
  19. seconds = 0,
  20. bars = 4,
  21. },
  22. life = 20,
  23. }
  24.  
  25. tfm.exec.bindKeyboard(name, 32, true, true)
  26. closeCamera(name)
  27. end
  28.  
  29. system.bindMouse(Admin, true)
  30.  
  31. function eventMouse(Admin, x, y)
  32. print(""..x.." e "..y.."")
  33. end
  34.  
  35. function updateLifeBar(name, cameraOpen)
  36. if data[name].life > 0 then
  37. if cameraOpen then
  38. ui.addTextArea(7, "", name, 10, 55, 100, 15, 0xffffff, 0x000000, 1, true)
  39. ui.addTextArea(8, "", name, 10, 55, math.floor(data[name].life*5), 15, 0xff0000, 0x000000, 1, true)
  40. else
  41. ui.addTextArea(7, "", name, 10, 30, 100, 15, 0xffffff, 0x000000, 1, true)
  42. ui.addTextArea(8, "", name, 10, 30, math.floor(data[name].life*5), 15, 0xff0000, 0x000000, 1, true)
  43. end
  44. else
  45. if cameraOpen then
  46. ui.addTextArea(7, "", name, 10, 55, 100, 15, 0xffffff, 0x000000, 1, true)
  47. else
  48. ui.addTextArea(7, "", name, 10, 30, 100, 15, 0xffffff, 0x000000, 1, true)
  49. end
  50. end
  51.  
  52. if data[name].life <= 0 then
  53. tfm.exec.killPlayer(name)
  54. end
  55. end
  56.  
  57. function spawnNpc(x, y)
  58. ui.addTextArea(9, "<p align='center'><b>'-'", nil, x, y, nil, nil, nil, nil, 1, false)
  59. end
  60.  
  61. function generateNpc()
  62. npc = {
  63. time = 50,
  64. damage = math.random(2,10),
  65. position = {x = math.random(10,3000), y = math.random(20,800)},
  66. }
  67. spawnNpc(npc.position.x, npc.position.y)
  68. end
  69.  
  70. function closeCamera(name)
  71. local id, y = 0, 0
  72. data[name].camera.open = false
  73.  
  74. if data[name].camera.bars == 4 then y = 277 elseif data[name].camera.bars == 3 then y = 300 elseif data[name].camera.bars == 2 then y = 323 elseif data[name].camera.bars == 1 then y = 346 end
  75.  
  76. ui.addTextArea(0, "", name, -500, -500, 5000, 5000, 0x000001, 0x000000, 0.99, true)
  77.  
  78. if data[name].camera.bars > 0 then
  79. for i=1,data[name].camera.bars do
  80. id, y = id+1, y+23
  81. ui.addTextArea(id, "", name, 756, y, 39, 11, 0x00ff00, 0x00ff00, 1, true)
  82. end
  83. else
  84. ui.removeTextArea(1, name)
  85. ui.removeTextArea(-1, name)
  86. end
  87.  
  88. ui.addTextArea(6, "<font size=\"13\"><a href=\"event:open_camera\">Open camera </a>", name, 643, 368, 100, 22, 0x112630, 0x112630, 1, true)
  89. updateLifeBar(name)
  90. end
  91.  
  92. function openCamera(name)
  93. local id, y = 0, 0
  94. data[name].camera.open = true
  95.  
  96. if data[name].camera.bars == 4 then y = 277 elseif data[name].camera.bars == 3 then y = 300 elseif data[name].camera.bars == 2 then y = 323 elseif data[name].camera.bars == 1 then y = 346 end
  97.  
  98. if data[name].camera.bars > 0 then
  99. ui.addTextArea(0, "", name, -500, -500, 5000, 5000, 0x000001, 0x000000, 0.4, true)
  100. ui.addTextArea(-1, "<font color='#FF0000' size='20'><b>REC "..os.date("%d/%m/%Y "..H..":%M:%S"), name, 3, 23, 795, 414, 0x000001, 0x000000, 50, true)
  101. for i=1,data[name].camera.bars do
  102. id, y = id+1, y+23
  103. ui.addTextArea(id, "", name, 756, y, 39, 11, 0x00ff00, 0x00ff00, 1, true)
  104. end
  105.  
  106. ui.addTextArea(6, "<font size=\"13\"><a href=\"event:close_camera\">Close camera </a>", name, 643, 368, 100, 22, 0x112630, 0x112630, 1, true)
  107. updateLifeBar(name, true)
  108. else
  109. closeCamera(name)
  110. end
  111. end
  112.  
  113. function refill(name)
  114. local player, i = tfm.get.room.playerList[name], 0
  115. local distX, distY = math.abs(player.x - battery.x), math.abs(player.y - battery.y)
  116.  
  117. if distX <= 35 and distY <= 35 then
  118. i = i+1
  119. if i >= 2 then i = 1 end
  120. if data[name].camera.bars < 4 then
  121. data[name].camera.bars = data[name].camera.bars+i
  122. if data[name].camera.bars >= 4 then data[name].camera.bars = 4 end
  123. if data[name].camera.open then
  124. openCamera(name)
  125. else
  126. closeCamera(name)
  127. end
  128. data[name].seconds = 0
  129. end
  130. ui.removeTextArea(999, nil)
  131. battery.loop, battery.x, battery.y = {20,400}, math.random(10,3000), math.random(100, 500)
  132. end
  133. end
  134.  
  135. function eventKeyboard(name, key, press, x, y)
  136. if key == 32 then
  137. refill(name)
  138. end
  139. end
  140.  
  141. function eventTextAreaCallback(id, name, link)
  142. if link == "open_camera" then
  143. openCamera(name)
  144. elseif link == "close_camera" then
  145. closeCamera(name)
  146. end
  147. end
  148.  
  149. function eventLoop(e,r)
  150. battery.loop[1], battery.loop[2] = battery.loop[1] - 0.5, battery.loop[2] - 0.5
  151. npc.time = npc.time - 0.5
  152. gameTime = gameTime + 0.5
  153.  
  154. if gameTime >= 1.5 then
  155. gameTime = 0
  156. end
  157.  
  158. for k,v in next,tfm.get.room.playerList do
  159. if data[k].camera.open then
  160. data[k].camera.seconds = data[k].camera.seconds + 0.5
  161. openCamera(k)
  162.  
  163. if data[k].camera.seconds == 60 then
  164. data[k].camera.bars = data[k].camera.bars-1
  165. openCamera(k)
  166. data[k].camera.seconds = 0
  167. end
  168. else
  169. data[k].camera.seconds = data[k].camera.seconds -- '-'
  170. end
  171.  
  172. if math.abs(v.x - npc.position.x) <= 50 and math.abs(v.y - npc.position.y) <= 50 then
  173. if gameTime == 1 then
  174. data[k].life = data[k].life - npc.damage
  175. if data[k].camera.open then
  176. updateLifeBar(k, true)
  177. else
  178. updateLifeBar(k)
  179. end
  180. end
  181. end
  182. end
  183.  
  184. if battery.loop[1] <= 0 then
  185. ui.addTextArea(999, "<font size='13'>Pilha", nil, battery.x, battery.y, nil, nil, 0x112630, 0x112630, 1, false)
  186. end
  187.  
  188. if battery.loop[2] <= 0 then
  189. ui.removeTextArea(999, nil)
  190. battery.loop, battery.x, battery.y = {20,40}, math.random(10,3000), math.random(300,600)
  191. end
  192.  
  193. if npc.time <= 0 then
  194. generateNpc()
  195. end
  196. end
  197.  
  198. for k in next,tfm.get.room.playerList do
  199. eventNewPlayer(k)
  200. end
  201.  
  202. tfm.exec.newGame('<C><P F="8" L="3000" Ca="" defilante="0,0,0,1" m="" H="800" /><Z><S><S L="516" X="2443" H="10" Y="766" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="1128" H="45" Y="532" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="700" o="296481" X="2350" c="4" Y="676" T="12" H="250" /><S L="291" H="10" X="1854" Y="767" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="15" X="2163" H="30" Y="785" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="1320" H="302" Y="362" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="2099" H="23" Y="771" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S H="300" L="230" o="756145" X="1200" c="4" Y="364" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="689" H="10" X="787" Y="518" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="180" X="1618" Y="590" T="0" P="0,0,0.3,0.2,40,0,0,0" /><S L="1000" H="10" X="1025" Y="696" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="200" X="1616" Y="730" T="0" P="0,0,0.3,0.2,-70,0,0,0" /><S L="10" X="1164" H="209" Y="587" T="0" P="0,0,20,0.2,-50,0,0,0" /><S L="399" X="197" H="27" Y="526" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="456" H="10" Y="615" T="0" P="0,0,0.3,0.2,50,0,0,0" /><S L="344" X="1828" H="10" Y="518" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="2000" o="245a35" X="1000" c="2" Y="656" T="12" H="289" /><S P="0,0,0.3,0.2,-40,0,0,0" L="45" o="b09d54" X="478" c="2" Y="603" T="12" H="200" /><S P="0,0,0.3,0.2,0,0,0,0" L="37" o="b09d54" X="414" c="2" Y="526" T="12" H="29" /><S P="0,0,0.3,0.2,0,0,0,0" L="1000" o="b09d54" X="1025" c="2" Y="670" T="12" H="45" /><S H="200" L="45" o="b09d54" X="1572" c="2" Y="602" T="12" P="0,0,0.3,0.2,40,0,0,0" /><S H="29" L="37" o="b09d54" X="1636" c="2" Y="526" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,110,0,0,0" L="45" o="b09d54" X="1624" c="2" Y="705" T="12" H="200" /><S P="0,0,0.3,0.2,-50,0,0,0" L="45" o="b09d54" X="1223" c="2" Y="601" T="12" H="200" /><S H="44" L="44" o="b09d54" X="1154" c="2" Y="533" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="302" X="1080" Y="362" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="230" H="10" X="1200" Y="216" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="129" X="1150" H="10" Y="403" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="99" X="1266" H="10" Y="305" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,20,0.2,0,0,0,0" L="46" H="52" c="4" Y="485" T="4" X="1154" /><S P="0,0,0.3,0.2,0,0,0,0" L="294" o="b09d54" X="1853" c="4" Y="738" T="12" H="45" /><S L="200" X="1816" H="283" Y="370" T="0" P="0,0,0.3,0.2,-180,0,0,0" /><S L="47" X="1817" H="70" Y="477" T="4" P="0,0,20,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="40" o="64a5c5" H="40" Y="321" T="12" X="1763" /><S L="40" o="64a5c5" H="40" X="1871" Y="320" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="1483" H="80" Y="471" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="12" X="2195" H="26" Y="546" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="12" X="2361" H="26" Y="544" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="31" X="1478" H="39" Y="490" T="4" P="0,0,20,0.2,0,0,0,0" /><S L="238" X="2284" H="18" Y="528" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,10,0,0,0" L="150" o="245a35" H="453" Y="608" T="12" X="2762" /><S P="0,0,0.3,0.2,0,0,0,0" L="272" o="245a35" H="430" Y="586" T="12" X="2864" /><S L="10" X="3007" H="3000" Y="382" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="10" H="3000" X="-6" Y="100" T="1" P="0,0,0,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="89" o="245a35" H="136" Y="314" T="12" X="2959" /><S L="89" o="245a35" H="136" X="2932" Y="326" T="12" P="0,0,0.3,0.2,20,0,0,0" /><S P="0,0,9999,0.50,0,0,0,0" L="65" o="d8d8d8" H="20" Y="546" T="12" X="2513" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="b01a1a" X="2495" c="4" Y="546" T="12" H="20" /><S H="20" L="10" o="b01a1a" X="2531" c="4" Y="546" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="496" X="128" /><P P="1,0" Y="620" T="1" X="726" /><P X="883" Y="766" T="1" P="1,0" /><P P="1,0" Y="615" T="1" X="1024" /><P X="1194" Y="762" T="1" P="1,0" /><P C="46788e" Y="511" T="24" X="1249" P="1,1" /><P P="1,0" Y="617" T="1" X="1376" /><P X="1147" Y="399" T="17" P="1,0" /><P X="1150" Y="363" T="21" P="1,0" /><P X="2848" Y="377" T="1" P="0,0" /><P X="1297" Y="298" T="33" P="1,0" /><P X="2361" Y="517" T="25" P="0,0" /><P X="2361" Y="517" T="25" P="0,0" /><P X="172" Y="511" T="4" P="0,0" /><P X="1968" Y="512" T="4" P="0,0" /><P X="2796" Y="391" T="17" P="0,0" /><P X="2771" Y="354" T="31" P="0,0" /><P X="2922" Y="358" T="1" P="0,0" /><P X="2986" Y="355" T="1" P="0,0" /></D><O /></Z></C>')
  203. spawnNpc(npc.position.x, npc.position.y)
  204. tfm.exec.setGameTime(900)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement