Mousetat

Tribewar deathmatch

Jan 7th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. admin="Trapin" --put your own username
  2. blueready=false
  3. redready=false
  4. redteamname="Red Team"
  5. blueteamname="Blue Team"
  6.  
  7.  
  8. tfm.exec.disableAutoNewGame(true)
  9. tfm.exec.disableAutoShaman(true)
  10. tfm.exec.disableAfkDeath(true)
  11. tfm.exec.disableAutoTimeLeft(true)
  12. colors = { 0xff0000, 0x0000ff }
  13. players={}
  14. toDespawn={}
  15. maps={521833,401421,541917,541928,541936,541943,527935,559634,559644,888052,878047,885641,770600,770656,772172,891472,589736,589800,589708,900012,901062,754380,901337,901411,907870,910078,1190467,1252043,1124380,1016258,1252299,1255902,1256808,986790,1285380,1271249,1255944,1255983,1085344,1273114,1276664,1279258,1286824,1280135,1280342,1284861,1287556,1057753,1196679,1288489,1292983,1298164,1298521,1293189,1296949,1308378,1311136,1314419,1314982,1318248,1312411,1312589,1312845,1312933,1313969,1338762,1339474,1349878,1297154,644588,1351237,1354040,1354375,1362386,1283234,1370578,1306592,1360889,1362753,1408124,1407949,1407849,1343986,1408028,1441370,1443416,1389255,1427349,1450527,1424739,869836,1459902,1392993,1426457,1542824,1533474,1561467,1563534,1566991,1587241,1416119,1596270,1601580,1525751,1582146,1558167,1420943,1466487,1642575,1648013,1646094,1393097,1643446,1545219,1583484,1613092,1627981,1633374,1633277,1633251,1585138,1624034,1616785,1625916,1667582,1666996,1675013,1675316,1531316,1665413,1681719,1699880,1688696,623770,1727243,1531329,1683915,1689533,1738601,3756146,912118,3326933,3722005,3566478,1456622,1357994,1985670,1884075,1708065,1700322,2124484,3699046,4057963,4019126,3335202,2050466}
  16. disco={1612690,3920302,3333999,3926952,3334000,2121577}
  17. selection=true
  18. ffa=false
  19. tfm.exec.newGame("@6396471")
  20. cheese="nothing"
  21. redpoints=0
  22. bluepoints=0
  23. long="nothing"
  24. win=false
  25. discobool=false
  26. ui.addPopup(0, 0, "<p align = 'center'><b><font size='30' face='arial' color='#FFFFFF'>Welcome to Tribe War: Deathmatch!</font></b></p>Created by Mousetat, credits to Gekkeiju<p align = 'left'><font size='15' face='arial' color='#FFFF00'>\nRules:\nThe Captains of both teams choose when their team is ready. He/she can click on 'Blue Team' if he/she is blue team captain, or 'Red Team' if he/she is red team captain, to change the Team Name. The *Captain* will have '*' on both sides of their name. When both captains are ready, the game will begin. Spectators will die every round and are unable to participate. Each time a team wins i.e.survive the round, they will win 1 point. The first team to score 10 points wins the game!</font></p>\n<p align='center'><b><i><font size='30' face='arial' color='#FF0000'>Commands(admin only)</p></b></i></font>!skip - skips a map to start a new map.\n!start - start/restart FFA with 0 points for both teams.\n!new - goes back to selection menu to reselect teams.\nCurrent Admin is <font size='25' color='#0000FF'>"..admin.."</font>.\n<p align='left'><b><i><font size='20'>Type !help to see this popup again.</p></b><i></font>", nil, 100, 30, 600, true)
  27.  
  28. function eventNewPlayer(name)
  29. for i,key in ipairs({32,0,1,2,3}) do
  30. tfm.exec.bindKeyboard(name,key,true,true)
  31. end
  32. players[name]={
  33. timestamp=os.time(),
  34. offsets={x=-20, y=20},
  35. team="white",
  36. idplayer=0
  37. }
  38. end
  39.  
  40. function eventKeyboard(name,key,down,x,y)
  41. local id=0
  42. if (key==32 or key==3 ) and not tfm.get.room.playerList[name].isDead and started and ffa==true and win==false then
  43. if players[name].timestamp < os.time()-1000 then
  44. if players[name].isFacingRight then
  45. id=tfm.exec.addShamanObject(17, x+players[name].offsets.x , y+players[name].offsets.y, 90 )
  46. else
  47. id=tfm.exec.addShamanObject(17, x-players[name].offsets.x , y+players[name].offsets.y, 270)
  48. end
  49. players[name].timestamp=os.time()
  50. table.insert(toDespawn,{os.time(),id})
  51. end
  52. end
  53. if key==0 then
  54. players[name].isFacingRight = false
  55. elseif key==2 then
  56. players[name].isFacingRight=true
  57. end
  58. end
  59.  
  60. function eventChatCommand(name,command)
  61. local arg={}
  62. for argument in string.gmatch(command,"[^%s]+") do
  63. table.insert(arg,argument)
  64. end
  65. if arg[1]=="off" then
  66. if tonumber(arg[2]) and tonumber(arg[3]) then
  67. players[name].offsets.x=tonumber(arg[2])
  68. players[name].offsets.y=tonumber(arg[3])
  69. else
  70. players[name].offsets.x=2
  71. players[name].offsets.y=10
  72. end
  73. ui.addTextArea(6996, "Offsets changed to X:"..players[name].offsets.x.." Y:"..players[name].offsets.y, name, 250, 370, 300, 20, 0x324650, 0x0, 0.3, true)
  74. end
  75. if name==admin and command=="new" then
  76. selection=true
  77. ffa=false
  78. discobool=false
  79. starterino=false
  80. tfm.exec.newGame("@6396471")
  81. redpoints=0
  82. bluepoints=0
  83. blueready=false
  84. redready=false
  85. redteamname="Red Team"
  86. blueteamname="Blue Team"
  87. local i=1
  88. while i<10 do
  89. ui.removeTextArea(i,nil)
  90. i=i+1
  91. end
  92. win=false
  93. for name,player in pairs(tfm.get.room.playerList) do
  94. eventNewPlayer(name)
  95. end
  96. end
  97. if name==admin and command=="start" then
  98. ffa=true
  99. selection=false
  100. redpoints=0
  101. bluepoints=0
  102. tfm.exec.newGame(maps[math.random(#maps)])
  103. end
  104. if name==admin and command=="skip" then
  105. tfm.exec.newGame(maps[math.random(#maps)])
  106. end
  107. if command=="help" then
  108. ui.addPopup(0, 0, "<p align = 'center'><b><font size='30' face='arial' color='#FFFFFF'>Welcome to Tribe War: Deathmatch!</font></b></p><p align = 'left'><font size='15' face='arial' color='#FFFF00'>Rules:\nThe Captains of both teams choose when their team is ready. The Captain will have '*' on both sides of their name. When both captains are ready, the game will begin. Each time a team wins i.e.survive the round, they will win 1 point. The first team to score 10 points wins the game!</font></p>\n\n<p align='center'><b><i><font size='30' face='arial' color='#FF0000'>Commands(admin only)</p></b></i></font>!skip - skips a map to start a new map.\n!start - start/restart FFA with 0 points for both teams.\n!new - goes back to selection menu to reselect teams.\nCurrent Admin is <font size='25' color='#0000FF'>"..admin.."</font>.\n<p align='left'><b><i><font size='20'>Type !help to see this popup again.</p></b><i></font>", name, 100, 50, 600, true)
  109. end
  110. end
  111.  
  112. function eventNewGame()
  113. if selection==true then
  114. tfm.exec.setGameTime(30, false)
  115. local i=10
  116. local y=30
  117. while i<19 do
  118. ui.addTextArea(i,"<a href='event:join'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Join</font></p></b></a>" ,nil,5,y,200,30,0x0000ff,0x212F36,0.2,false)
  119. i=i+1
  120. y=y+40
  121. end
  122. ui.addTextArea(19,"<a href='event:captain'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Become Captain</font></p></b></a>" ,nil,5,y,200,30,0x0000ff,0x212F36,0.2,false)
  123. y=30
  124. i=20
  125. while i<29 do
  126. ui.addTextArea(i,"<a href='event:join'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Join</font></p></b></a>" ,nil,605,y,200,30,0xff0000,0x212F36,0.2,false)
  127. i=i+1
  128. y=y+40
  129. end
  130. ui.addTextArea(29,"<a href='event:captain'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Become Captain</font></p></b></a>" ,nil,605,y,200,30,0xff0000,0x212F36,0.2,false)
  131. ui.addTextArea(0,"<a href='event:spectate'><b><p align='center'><font face='arial' size='20' color='#FFFFFF'>Spectate</font></p></b></a>" ,nil,300,205,200,30,0xffffff,0x212F36,0.2,false)
  132. ui.addTextArea(50,"<a href='event:blueready'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Not Ready</font></p></b></a>" ,nil,260,385,120,30,0x0000ff,0x212F36,0.2,false)
  133. ui.addTextArea(51,"<a href='event:redready'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Not Ready</font></p></b></a>" ,nil,420,385,120,30,0xff0000,0x212F36,0.2,false)
  134. ui.addTextArea(53,"<a href='event:bluename'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Blue Team</font></p></b></a>" ,nil,260,65,280,30,0x0000ff,0x212F36,0.2,false)
  135. ui.addTextArea(55,"<b><p align='center'><font face='arial' size='20' color='#000000'>VS</font></p></b>" ,nil,375,105,50,30,0xffffff,0x212F36,0.2,false)
  136. ui.addTextArea(54,"<a href='event:redname'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Red Team</font></p></b></a>" ,nil,260,145,280,30,0xff0000,0x212F36,0.2,false)
  137. end
  138. if ffa==true then
  139. if bluepoints==10 then
  140. tfm.exec.setGameTime(30)
  141. win=true
  142. ui.addTextArea(8,"<p align='center'><b><font face='arial' size='40' color='#0000FF'>"..blueteamname.." WON!!</font></b></p>" ,nil,0,120,800,60,0x0000ff,0x212F36,0.2,true)
  143. cheese="blue"
  144. elseif redpoints==10 then
  145. tfm.exec.setGameTime(30)
  146. win=true
  147. ui.addTextArea(8,"<p align='center'><b><font face='arial' size='40' color='#FF0000'>"..redteamname.." WON!!</font></b></p>" ,nil,0,120,800,60,0xff0000,0x212F36,0.2,true)
  148. cheese="red"
  149. end
  150. local i=10
  151. while i<60 do
  152. ui.removeTextArea(i,nil)
  153. i=i+1
  154. end
  155. ui.removeTextArea(0,nil)
  156. for name, player in pairs(tfm.get.room.playerList) do
  157. if players[name].team=="blue" or players[name].team=="bluecaptain" then
  158. tfm.exec.setNameColor(name, 0x0000ff)
  159. elseif players[name].team=="red" or players[name].team=="redcaptain" then
  160. tfm.exec.setNameColor(name, 0xff0000)
  161. elseif players[name].team=="white" then
  162. tfm.exec.killPlayer(name)
  163. end
  164. end
  165. bluestring="<p align='center'><b><font face='arial' size='20' color='#0000FF'>"..blueteamname.."</font></b></p>".."<p align='center'><b><font face='arial' size='30' color='#0000FF'>"..tostring(bluepoints).."</font></b></p>"
  166. redstring="<p align='center'><b><font face='arial' size='20' color='#FF0000'>"..redteamname.."</font></b></p>".."<p align='center'><b><font face='arial' size='30' color='#FF0000'>"..tostring(redpoints).."</font></b></p>"
  167. ui.addTextArea(7,bluestring,nil,95,25,300,70,0x0000ff,0x0000ff,0.2,true)
  168. ui.addTextArea(9,redstring,nil,405,25,300,70,0xff0000,0xff0000,0.2,true)
  169. started=false
  170. end
  171. end
  172.  
  173. function eventTextAreaCallback(i, name, callback)
  174. if callback=="join" or callback=="captain" then
  175. if players[name].idplayer>0 then
  176. if players[name].idplayer<19 then
  177. ui.updateTextArea(players[name].idplayer,"<a href='event:join'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Join</font></p></b></a>",nil)
  178. elseif players[name].idplayer==19 then
  179. ui.updateTextArea(players[name].idplayer,"<a href='event:captain'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Become Captain</font></p></b></a>",nil)
  180. elseif players[name].idplayer<29 then
  181. ui.updateTextArea(players[name].idplayer,"<a href='event:join'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Join</font></p></b></a>",nil)
  182. elseif players[name].idplayer==29 then
  183. ui.updateTextArea(players[name].idplayer,"<a href='event:captain'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Become Captain</font></p></b></a>",nil)
  184. end
  185. end
  186. if i<20 then
  187. tfm.exec.movePlayer(name,100,45+(i-10)*40,false,0,0,false)
  188. tfm.exec.setNameColor(name, 0x0000ff)
  189. ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#0000FF'>"..name.."</font></p></b>",nil)
  190. players[name].team="blue"
  191. players[name].idplayer=i
  192. if callback=="captain" then
  193. ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#0000FF'>*"..name.."*</font></p></b>",nil)
  194. players[name].team="bluecaptain"
  195. end
  196. elseif i<30 and i>=20 then
  197. tfm.exec.movePlayer(name,700,45+(i-20)*40,false,0,0,false)
  198. tfm.exec.setNameColor(name, 0xff0000)
  199. ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#FF0000'>"..name.."</font></p></b>",nil)
  200. players[name].team="red"
  201. players[name].idplayer=i
  202. if callback=="captain" then
  203. ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#FF0000'>*"..name.."*</font></p></b>",nil)
  204. players[name].team="redcaptain"
  205. end
  206. end
  207. elseif callback=="spectate"then
  208. if players[name].idplayer>0 then
  209. if players[name].idplayer<19 then
  210. ui.updateTextArea(players[name].idplayer,"<a href='event:join'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Join</font></p></b></a>",nil)
  211. elseif players[name].idplayer==19 then
  212. ui.updateTextArea(players[name].idplayer,"<a href='event:captain'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Become Captain</font></p></b></a>",nil)
  213. elseif players[name].idplayer<29 then
  214. ui.updateTextArea(players[name].idplayer,"<a href='event:join'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Join</font></p></b></a>",nil)
  215. elseif players[name].idplayer==29 then
  216. ui.updateTextArea(players[name].idplayer,"<a href='event:captain'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Become Captain</font></p></b></a>",nil)
  217. end
  218. end
  219. players[name].team="white"
  220. players[name].idplayer=0
  221. tfm.exec.movePlayer(name,400,405,false,0,0,false)
  222. tfm.exec.setNameColor(name, 0)
  223. elseif callback=="blueready" and players[name].team=="bluecaptain" then
  224. ui.updateTextArea(50,"<a href='event:bluenotready'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Ready</font></p></b></a>" ,nil)
  225. blueready=true
  226. elseif callback=="redready" and players[name].team=="redcaptain" then
  227. ui.updateTextArea(51,"<a href='event:rednotready'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Ready</font></p></b></a>" ,nil)
  228. redready=true
  229. elseif callback=="bluenotready" and players[name].team=="bluecaptain" then
  230. ui.updateTextArea(50,"<a href='event:blueready'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Not Ready</font></p></b></a>" ,nil)
  231. blueready=false
  232. elseif callback=="rednotready" and players[name].team=="redcaptain" then
  233. ui.updateTextArea(51,"<a href='event:redready'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Not Ready</font></p></b></a>" ,nil)
  234. redready=false
  235. elseif callback=="bluename" and players[name].team=="bluecaptain" then
  236. ui.addPopup(1, 2,"What do you want your team name to be?", name, 200, 100, 400, true)
  237. elseif callback=="redname" and players[name].team=="redcaptain" then
  238. ui.addPopup(2, 2,"What do you want your team name to be?", name, 200, 100, 400, true)
  239. end
  240. end
  241. starterino=false
  242.  
  243. function eventPopupAnswer(id, name, answer)
  244. if id==1 then
  245. blueteamname=string.sub(answer, 1, 25)
  246. ui.updateTextArea(53,"<a href='event:bluename'><b><p align='center'><font face='arial' size='20' color='#0000FF'>"..blueteamname.."</font></p></b></a>",nil)
  247. elseif id==2 then
  248. redteamname=string.sub(answer, 1, 25)
  249. ui.updateTextArea(54,"<a href='event:redname'><b><p align='center'><font face='arial' size='20' color='#FF0000'>"..redteamname.."</font></p></b></a>",nil)
  250. end
  251. end
  252.  
  253. function eventLoop(time,remaining)
  254. if selection==true then
  255. if blueready==true and redready==true and starterino==false then
  256. starterino=true
  257. tfm.exec.setGameTime(3)
  258. elseif blueready==false or redready==false then
  259. ui.removeTextArea(52)
  260. starterino=false
  261. end
  262. if remaining>=3000 and blueready==true and redready==true and starterino==true then
  263. ui.addTextArea(52,"<b><p align='center'><font face='arial' size='20' color='#FFFFFF'>Starting Game in 3</font></p></b>" ,nil,300,300,200,30,0xffffff,0x212F36,0.2,false)
  264. elseif remaining>=2000 and blueready==true and redready==true and starterino==true then
  265. ui.updateTextArea(52,"<b><p align='center'><font face='arial' size='20' color='#FFFFFF'>Starting Game in 2</font></p></b>" ,nil)
  266. elseif remaining>=1000 and blueready==true and redready==true and starterino==true then
  267. ui.updateTextArea(52,"<b><p align='center'><font face='arial' size='20' color='#FFFFFF'>Starting Game in 1</font></p></b>" ,nil)
  268. elseif remaining<=0 and blueready==true and redready==true and starterino==true then
  269. ffa=true
  270. selection=false
  271. tfm.exec.newGame(maps[math.random(#maps)])
  272. end
  273. end
  274. if ffa==true and win==false then
  275. if time>=8000 then
  276. ui.removeTextArea(4)
  277. elseif time >=7000 then
  278. ui.removeTextArea(2)
  279. ui.addTextArea(4,"<b><font face='arial' size='50' color='#00FF00'>GO</font></b>" ,nil,355,330,100,60,0x324650,0x212F36,0,true)
  280. if not started then
  281. started=true
  282. end
  283. elseif time>=6000 then
  284. ui.removeTextArea(3)
  285. ui.addTextArea(2,"<b><font face='arial' size='50' color='#FF0000'>1</font></b>" ,nil,385,330,35,60,0x324650,0x212F36,0,true)
  286. elseif time>=5000 then
  287. ui.removeTextArea(1)
  288. ui.addTextArea(3,"<b><font face='arial' size='50' color='#FF0000'>2</font></b>" ,nil,385,330,35,60,0x324650,0x212F36,0,true)
  289. elseif time>=4000 then
  290. ui.removeTextArea(9999)
  291. ui.addTextArea(1,"<b><font face='arial' size='50' color='#FF0000'>3</font></b>" ,nil,385,330,35,60,0x324650,0x212F36,0,true)
  292. elseif time>=0 then
  293. ui.addTextArea(9999,"<b><font face='Impact' size='50' color='#FFFF00'>Get Ready</font></b>" ,nil,295,330,350,60,0x324650,0x212F36,0,true)
  294. end
  295. if remaining<=0 then
  296. if bluepoints==10 or redpoints==10 then
  297. tfm.exec.newGame(disco[math.random(#disco)])
  298. else
  299. tfm.exec.newGame(maps[math.random(#maps)])
  300. end
  301. end
  302. for i,cannon in ipairs(toDespawn) do
  303. if cannon[1] <= os.time()-1000 then
  304. tfm.exec.removeObject(cannon[2])
  305. table.remove(toDespawn,i)
  306. end
  307. end
  308. end
  309. if win==true then
  310. if time>=3000 then
  311. if cheese=="red" then
  312. for name,player in pairs(tfm.get.room.playerList) do
  313. if players[name].team=="red" or players[name].team=="redcaptain" then
  314. tfm.exec.playEmote(name, 0)
  315. else
  316. tfm.exec.playEmote(name, 2)
  317. end
  318. end
  319. elseif cheese=="blue" then
  320. for name,player in pairs(tfm.get.room.playerList) do
  321. if players[name].team=="blue" or players[name].team=="bluecaptain"then
  322. tfm.exec.playEmote(name, 0)
  323. else
  324. tfm.exec.playEmote(name, 2)
  325. end
  326. end
  327. end
  328. end
  329. if remaining<=0 then
  330. selection=true
  331. ffa=false
  332. discobool=false
  333. starterino=false
  334. tfm.exec.newGame("@6396471")
  335. tfm.exec.newGame("@6396471")
  336. redpoints=0
  337. bluepoints=0
  338. blueready=false
  339. redready=false
  340. redteamname="Red Team"
  341. blueteamname="Blue Team"
  342. local i=1
  343. while i<10 do
  344. ui.removeTextArea(i,nil)
  345. i=i+1
  346. end
  347. win=false
  348. end
  349. end
  350. end
  351.  
  352.  
  353. function eventPlayerDied(name)
  354. if ffa==true and win==false then
  355. local i=0
  356. local n
  357. for pname,player in pairs(tfm.get.room.playerList) do
  358. if not player.isDead then
  359. i=i+1
  360. n=pname
  361. end
  362. end
  363. if i==0 and win==false then
  364. tfm.exec.newGame(maps[math.random(#maps)])
  365. end
  366. local redalive=0
  367. local bluealive=0
  368. for name, player in pairs(tfm.get.room.playerList) do
  369. if players[name].team=="red" or players[name].team=="redcaptain" then
  370. if not player.isDead then
  371. redalive=redalive+1
  372. end
  373. elseif players[name].team=="blue" or players[name].team=="bluecaptain" then
  374. if not player.isDead then
  375. bluealive=bluealive+1
  376. end
  377. end
  378. end
  379. if redalive==0 then
  380. bluepoints=bluepoints+1
  381. for name, player in pairs(tfm.get.room.playerList) do
  382. if players[name].team=="blue" or players[name].team=="bluecaptain" then
  383. if not player.isDead then
  384. tfm.exec.giveCheese(name)
  385. tfm.exec.playerVictory(name)
  386. end
  387. end
  388. end
  389. tfm.exec.setGameTime(5)
  390. elseif bluealive==0 then
  391. redpoints=redpoints+1
  392. for name, player in pairs(tfm.get.room.playerList) do
  393. if players[name].team=="red" or players[name].team=="redcaptain" then
  394. if not player.isDead then
  395. tfm.exec.giveCheese(name)
  396. tfm.exec.playerVictory(name)
  397. end
  398. end
  399. end
  400. tfm.exec.setGameTime(5)
  401. end
  402. end
  403. end
  404.  
  405. for name,player in pairs(tfm.get.room.playerList) do
  406. eventNewPlayer(name)
  407. end
Add Comment
Please, Sign In to add comment