Advertisement
wassimevicw

zagear

Feb 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. builder = "Wassimevicw"
  2. admin = ""
  3. data={}
  4.  
  5. toDespawn={}
  6.  
  7. function randomPlyers(k)
  8. ttt={}
  9. for n in pairs(tfm.get.room.playerList) do
  10. if n ~= k then
  11. table.insert(ttt,n)
  12. end
  13. end
  14. return ttt[math.random(#ttt)]
  15. end
  16.  
  17. function newBuilder(nn)
  18. point_x=nil
  19. point_y=nil
  20. builder=nn
  21. builderTime=os.time()
  22. ui.setShamanName (builder)
  23. for n in pairs(tfm.get.room.playerList)do
  24. if n ~= builder and n ~= admin then
  25. tfm.exec.setNameColor(n,0xFFA700)
  26. end
  27. end
  28. tfm.exec.setNameColor(builder,0x008DFE)
  29. tfm.exec.setNameColor(admin,0x86FF00)
  30. end
  31.  
  32. function refrechBuilder()
  33. ui.setShamanName (builder)
  34. for n in pairs(tfm.get.room.playerList)do
  35. if n ~= builder and n ~= admin then
  36. tfm.exec.setNameColor(n,0xFFA700)
  37. end
  38. end
  39. tfm.exec.setNameColor(builder,0x008DFE)
  40. tfm.exec.setNameColor(admin,0x86FF00)
  41. end
  42.  
  43. newBuilder(builder)
  44.  
  45. look = 0
  46.  
  47. tableK={}
  48. p={}
  49. builderTime=os.time()
  50.  
  51. --[[
  52. 0 = wood
  53. 1 = ice
  54. 2 = tramp
  55. 3 = lava
  56. 4 = choc
  57. ]]
  58.  
  59. custom = false
  60.  
  61. fric = 0.3 -- friction
  62. res = 0.2 -- restitution
  63. col = nil -- color
  64. hei = 10 -- height
  65.  
  66. fric_stored = 0
  67. res_stored = 0
  68. col_stored = nil
  69.  
  70. point_x=nil
  71. point_y=nil
  72.  
  73. gNum = 0
  74.  
  75. for n in pairs (tfm.get.room.playerList) do
  76. for _,v in pairs({32, 8, 49, 50, 51, 52, 53, 54,70,0,2}) do
  77. tfm.exec.bindKeyboard(n, v, true, true)
  78. end
  79. system.bindMouse(n, true)
  80. data[n]={time=0,pointR=1,pointL=1,timeS=0}
  81. p[n]={right=false, left=false}
  82. tfm.exec.setPlayerScore (n,0,false)
  83. end
  84.  
  85. function eventNewPlayer(n)
  86. for _,v in pairs({32, 8, 49, 50, 51, 52, 53, 54,70,0,2}) do
  87. tfm.exec.bindKeyboard(n, v, true, true)
  88. end
  89. refrechBuilder()
  90. data[n]={time=0,pointR=1,pointL=1,timeS=0}
  91. p[n]={right=false, left=false}
  92. system.bindMouse(n, true)
  93. end
  94.  
  95. tfm.exec.disableAutoScore(true)
  96. system.disableChatCommandDisplay("height", true)
  97. system.disableChatCommandDisplay("custom", true)
  98.  
  99. function eventMouse(name, x, y)
  100. if name == builder then
  101. tfm.exec.displayParticle(9, x, y, 0, 0, 0, 0)
  102. if point_x == nil then
  103. point_x = x
  104. point_y = y
  105. else
  106. makeGround(x,y,length(point_x,point_y,x,y), angle(point_x, point_y,x,y))
  107. end
  108. elseif name == admin then
  109. tfm.exec.displayParticle(37,tfm.get.room.playerList[name].x,tfm.get.room.playerList[name].y,0,0,0,0)
  110. tfm.exec.movePlayer(name,x,y,false,0,0,false)
  111. tfm.exec.displayParticle(36,x,y,0,0,0,0)
  112. end
  113. end
  114.  
  115. function eventNewGame()
  116. gNum = 0
  117. point_x=nil
  118. point_y=nil
  119. end
  120.  
  121. function eventChatCommand(name, cmd)
  122. local args = {}
  123. for arg in cmd:gmatch("%S+") do
  124. table.insert(args, arg)
  125. end
  126. if args[1] == "custom" then
  127. ui.addPopup(1, 2, "Restitution:", name, 726, 20, 70)
  128. system.bindMouse(builder, false)
  129. point_x=nil
  130. point_y=nil
  131. col=nil
  132. look = 12
  133. elseif args[1] == "height" then
  134. if args[2] then
  135. hei = tonumber(args[2]) or 0
  136. end
  137. end
  138. if args[1] == "random" and name == admin then
  139. ui.addPopup(1, 0, "تم إزالة الشامان منك بسبب استخادمك للحبس", builder, 350, 170, 188,true)
  140. tfm.exec.killPlayer(builder)
  141. newBuilder(randomPlyers(builder))
  142. end
  143. if args[1] == "mod" and name == admin then
  144. admin = args[2]
  145. refrechBuilder()
  146. end
  147. end
  148.  
  149. function eventPopupAnswer(id, name, answer)
  150. if id == 1 then
  151. res = tonumber(answer)
  152. ui.addPopup(2, 2, "Friction:", name, 726, 20, 70)
  153. elseif id == 2 then
  154. fric = tonumber(answer)
  155. ui.addPopup(3, 2, "Colour eg. FF0000 (if left blank it will be invisible):", name, 646, 20, 150)
  156. elseif id == 3 then
  157. if answer:len() > 5 then
  158. col = '0x'..answer
  159. end
  160. ui.addPopup(4, 1, "Would you like to add this to a hotkey (6)?", name, 551, 20, 245)
  161. elseif id == 4 then
  162. if answer == "yes" then
  163. fric_stored = fric
  164. res_stored = res
  165. col_stored = col
  166. custom = true
  167. end
  168. system.bindMouse(builder, true)
  169. end
  170. end
  171.  
  172. function eventKeyboard(name, key, down, x, y)
  173. if key==2 then
  174. p[name].right=true
  175. p[name].left=false
  176. elseif key==0 then
  177. p[name].right=false
  178. p[name].left=true
  179. end
  180. if key == 70 and data[name].time < os.time()-5000 and name ~= builder then
  181. if p[name].right then
  182. tfm.exec.displayParticle(26,x+20,y)
  183. tfm.exec.displayParticle(26,x+30,y)
  184. tfm.exec.displayParticle(26,x+40,y)
  185. tfm.exec.displayParticle(26,x+50,y)
  186. tfm.exec.movePlayer(name,0,0,true,150,0,false)
  187. else
  188. tfm.exec.displayParticle(26,x-20,y)
  189. tfm.exec.displayParticle(26,x-30,y)
  190. tfm.exec.displayParticle(26,x-40,y)
  191. tfm.exec.displayParticle(26,x-50,y)
  192. tfm.exec.movePlayer(name,0,0,true,-100,0,false)
  193. end
  194. data[name].time=os.time()
  195. end
  196. if key == 32 then
  197. if name == builder then
  198. for i=1,#tableK do
  199. tfm.exec.removePhysicObject(tableK.id)
  200. table.remove(tableK)
  201. end
  202. else
  203. RADIUS=50
  204. if ((tfm.get.room.playerList[builder].x >= x-(RADIUS/2) and tfm.get.room.playerList[builder].x <= x+(RADIUS/2)) and (tfm.get.room.playerList[builder].y >= y-(RADIUS/2) and tfm.get.room.playerList[builder].y <= y+(RADIUS/2))) and builderTime < os.time()-6000 then
  205. tfm.exec.killPlayer(builder)
  206. newBuilder(name)
  207. end
  208. end
  209. end
  210. if name == builder then
  211. if key == 8 then
  212. tfm.exec.removePhysicObject(gNum)
  213. gNum = gNum - 1
  214. elseif key == 49 then
  215. look = 0
  216. fric = 0.3
  217. res = 0.2
  218. col = nil
  219. elseif key == 50 then
  220. look = 1
  221. fric = 0
  222. res = 0.2
  223. col = nil
  224. elseif key == 51 then
  225. look = 2
  226. fric = 0
  227. res = 1.2
  228. col = nil
  229. elseif key == 52 then
  230. look = 3
  231. fric = 0
  232. res = 20
  233. col = nil
  234. elseif key == 53 then
  235. look = 4
  236. fric = 20
  237. res = 0.2
  238. col = nil
  239. elseif key == 54 then
  240. if custom then
  241. look = 12
  242. fric = fric_stored
  243. res = res_stored
  244. col = col_stored
  245. end
  246. end
  247. end
  248. end
  249.  
  250. function makeGround(x,y,length,ang)
  251. gNum = gNum + 1
  252. final_x = ((x + point_x)/2)
  253. final_y = ((y + point_y)/2)
  254. tfm.exec.addPhysicObject(gNum, final_x, final_y, {type=look or 0, width=length, height = hei, angle=ang, color = col ,friction=fric or 0.3, restitution=res or 0.2})
  255. table.insert(tableK,{id=gNum,time=os.time()})
  256. point_x=nil
  257. point_y=nil
  258. end
  259.  
  260. function eventLoop()
  261. for i=1,#tableK do
  262. if tableK ~= nil then
  263. if tableK.time < os.time()-8000 then
  264. tfm.exec.removePhysicObject(tableK.id)
  265. table.remove(tableK,i)
  266. end
  267. end
  268. end
  269. if data[builder].timeS < os.time()-5000 then
  270. tfm.exec.setPlayerScore (builder,math.random(50),true)
  271. data[builder].timeS=os.time()
  272. end
  273. end
  274.  
  275. function length(x1, y1, x2, y2)
  276. lx = (x2 - x1)^2
  277. ly = (y2 - y1)^2
  278. return math.sqrt(lx+ly)
  279. end
  280.  
  281. function angle(x1, y1, x2, y2)
  282. lx = x2 - x1
  283. ly = y2 - y1
  284. return math.deg(math.atan2(ly,lx))
  285. end
  286.  
  287.  
  288. function eventPlayerLeft(name)
  289. if name == builder then
  290. newBuilder(randomPlyers(name))
  291. end
  292. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement