Advertisement
Guest User

Tribewar Deathmatch!

a guest
Dec 20th, 2015
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.86 KB | None | 0 0
  1.  
  2. admin="Mousetat" --put your own username
  3.  
  4.  
  5.  
  6. blueready=false
  7. redready=false
  8. redteamname="Red Team"
  9. blueteamname="Blue Team"
  10.  
  11.  
  12. tfm.exec.disableAutoNewGame(true)
  13. tfm.exec.disableAutoShaman(true)
  14. tfm.exec.disableAfkDeath(true)
  15. tfm.exec.disableAutoTimeLeft(true)
  16. colors = { 0xff0000, 0x0000ff }
  17. players={}
  18. toDespawn={}
  19. 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}
  20. disco={1612690,3920302,3333999,3926952,3334000,2121577}
  21. selection=true
  22. ffa=false
  23. tfm.exec.newGame("@6396471")
  24. cheese="nothing"
  25. redpoints=0
  26. bluepoints=0
  27. long="nothing"
  28. win=false
  29. discobool=false
  30. 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)
  31.  
  32. function eventNewPlayer(name)
  33.     for i,key in ipairs({32,40,83,37,39,65,68}) do
  34.         tfm.exec.bindKeyboard(name,key,true,true)
  35.     end
  36.     players[name]={
  37.     timestamp=os.time(),
  38.     offsets={x=2, y=10},
  39.     team="white",
  40.     idplayer=0
  41.     }
  42. end
  43.  
  44. function eventKeyboard(name,key,down,x,y)
  45.     local id=0
  46.     if (key==32 or key==40 or key==83) and not tfm.get.room.playerList[name].isDead and started and ffa==true and win==false then
  47.         if players[name].timestamp < os.time()-1000 then
  48.             if players[name].isFacingRight then
  49.                 id=tfm.exec.addShamanObject(17, x+2 , y+10, 90 )
  50.             else
  51.                 id=tfm.exec.addShamanObject(17, x-2 , y+10, 270)
  52.             end
  53.             players[name].timestamp=os.time()
  54.             table.insert(toDespawn,{os.time(),id})
  55.         end
  56.     end
  57.     if key==37 or key==65 then
  58.     players[name].isFacingRight = false
  59.     elseif key==39 or key==68 then
  60.     players[name].isFacingRight=true
  61.     end
  62. end
  63.  
  64. function eventChatCommand(name,command)
  65.     if name==admin and command=="new" then
  66.         selection=true
  67.         ffa=false
  68.         discobool=false
  69.         starterino=false
  70.         tfm.exec.newGame("@6396471")
  71.         redpoints=0
  72.         bluepoints=0
  73.         blueready=false
  74.         redready=false
  75.         redteamname="Red Team"
  76.         blueteamname="Blue Team"
  77.         local i=1
  78.         while i<10 do
  79.             ui.removeTextArea(i,nil)
  80.             i=i+1
  81.         end
  82.         win=false
  83.         for name,player in pairs(tfm.get.room.playerList) do
  84.             eventNewPlayer(name)
  85.         end
  86.     end
  87.     if name==admin and command=="start" then
  88.         ffa=true
  89.         selection=false
  90.         redpoints=0
  91.         bluepoints=0
  92.         tfm.exec.newGame(maps[math.random(#maps)])
  93.     end
  94.     if name==admin and command=="skip" then
  95.         tfm.exec.newGame(maps[math.random(#maps)])
  96.     end
  97.     if command=="help" then
  98.         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)
  99.     end
  100. end
  101.  
  102. function eventNewGame()
  103.     if selection==true then
  104.         tfm.exec.setGameTime(30, false)
  105.         local i=10
  106.         local y=30
  107.         while i<19 do
  108.             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)
  109.             i=i+1
  110.             y=y+40
  111.         end
  112.         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)
  113.         y=30
  114.         i=20
  115.         while i<29 do
  116.             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)
  117.             i=i+1
  118.             y=y+40
  119.         end
  120.         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)
  121.         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)
  122.         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)
  123.         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)
  124.         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)
  125.         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)
  126.         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)
  127.     end
  128.     if ffa==true then
  129.         if bluepoints==10 then
  130.             tfm.exec.setGameTime(30)
  131.             win=true
  132.             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)
  133.             cheese="blue"
  134.         elseif redpoints==10 then
  135.             tfm.exec.setGameTime(30)
  136.             win=true
  137.             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)
  138.             cheese="red"
  139.         end
  140.         local i=10
  141.         while i<60 do
  142.         ui.removeTextArea(i,nil)
  143.         i=i+1
  144.         end
  145.         ui.removeTextArea(0,nil)
  146.         for name, player in pairs(tfm.get.room.playerList) do
  147.             if players[name].team=="blue" or players[name].team=="bluecaptain" then
  148.                 tfm.exec.setNameColor(name, 0x0000ff)
  149.             elseif players[name].team=="red" or players[name].team=="redcaptain" then
  150.                 tfm.exec.setNameColor(name, 0xff0000)
  151.             elseif players[name].team=="white" then
  152.                 tfm.exec.killPlayer(name)
  153.             end
  154.         end
  155.         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>"
  156.         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>"
  157.         ui.addTextArea(7,bluestring,nil,95,25,300,70,0x0000ff,0x0000ff,0.2,true)
  158.         ui.addTextArea(9,redstring,nil,405,25,300,70,0xff0000,0xff0000,0.2,true)
  159.         started=false
  160.     end
  161. end
  162.  
  163. function eventTextAreaCallback(i, name, callback)
  164.     if callback=="join" or callback=="captain" then
  165.         if players[name].idplayer>0 then
  166.             if players[name].idplayer<19 then
  167.                 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)
  168.             elseif players[name].idplayer==19 then
  169.                 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)
  170.             elseif players[name].idplayer<29 then
  171.                 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)
  172.             elseif players[name].idplayer==29 then
  173.                 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)
  174.             end
  175.         end
  176.         if i<20 then
  177.             tfm.exec.movePlayer(name,100,45+(i-10)*40,false,0,0,false)
  178.             tfm.exec.setNameColor(name, 0x0000ff)
  179.             ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#0000FF'>"..name.."</font></p></b>",nil)
  180.             players[name].team="blue"
  181.             players[name].idplayer=i
  182.             if callback=="captain" then
  183.                 ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#0000FF'>*"..name.."*</font></p></b>",nil)
  184.                 players[name].team="bluecaptain"
  185.             end
  186.         elseif i<30 and i>=20 then
  187.             tfm.exec.movePlayer(name,700,45+(i-20)*40,false,0,0,false)
  188.             tfm.exec.setNameColor(name, 0xff0000)
  189.             ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#FF0000'>"..name.."</font></p></b>",nil)
  190.             players[name].team="red"
  191.             players[name].idplayer=i
  192.             if callback=="captain" then
  193.                 ui.updateTextArea(i,"<b><p align='center'><font face='arial' size='20' color='#FF0000'>*"..name.."*</font></p></b>",nil)
  194.                 players[name].team="redcaptain"
  195.             end
  196.         end
  197.     elseif callback=="spectate"then
  198.         if players[name].idplayer>0 then
  199.             if players[name].idplayer<19 then
  200.                 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)
  201.             elseif players[name].idplayer==19 then
  202.                 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)
  203.             elseif players[name].idplayer<29 then
  204.                 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)
  205.             elseif players[name].idplayer==29 then
  206.                 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)
  207.             end
  208.         end
  209.         players[name].team="white"
  210.         players[name].idplayer=0
  211.         tfm.exec.movePlayer(name,400,405,false,0,0,false)
  212.         tfm.exec.setNameColor(name, 0)
  213.     elseif callback=="blueready" and players[name].team=="bluecaptain" then
  214.         ui.updateTextArea(50,"<a href='event:bluenotready'><b><p align='center'><font face='arial' size='20' color='#0000FF'>Ready</font></p></b></a>" ,nil)
  215.         blueready=true
  216.     elseif callback=="redready" and players[name].team=="redcaptain" then
  217.         ui.updateTextArea(51,"<a href='event:rednotready'><b><p align='center'><font face='arial' size='20' color='#FF0000'>Ready</font></p></b></a>" ,nil)
  218.         redready=true
  219.     elseif callback=="bluenotready" and players[name].team=="bluecaptain" then
  220.         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)
  221.         blueready=false
  222.     elseif callback=="rednotready" and players[name].team=="redcaptain" then
  223.         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)
  224.         redready=false
  225.     elseif callback=="bluename" and players[name].team=="bluecaptain" then
  226.         ui.addPopup(1, 2,"What do you want your team name to be?", name, 200, 100, 400, true)
  227.     elseif callback=="redname" and players[name].team=="redcaptain" then
  228.         ui.addPopup(2, 2,"What do you want your team name to be?", name, 200, 100, 400, true)
  229.     end
  230. end
  231. starterino=false
  232.  
  233. function eventPopupAnswer(id, name, answer)
  234.     if id==1 then
  235.         blueteamname=string.sub(answer, 1, 25)
  236.         ui.updateTextArea(53,"<a href='event:bluename'><b><p align='center'><font face='arial' size='20' color='#0000FF'>"..blueteamname.."</font></p></b></a>",nil)
  237.     elseif id==2 then
  238.         redteamname=string.sub(answer, 1, 25)
  239.         ui.updateTextArea(54,"<a href='event:redname'><b><p align='center'><font face='arial' size='20' color='#FF0000'>"..redteamname.."</font></p></b></a>",nil)
  240.     end
  241. end
  242.  
  243. function eventLoop(time,remaining)
  244.     if selection==true then
  245.         if blueready==true and redready==true and starterino==false then
  246.             starterino=true
  247.             tfm.exec.setGameTime(3)
  248.         elseif blueready==false or redready==false then
  249.             ui.removeTextArea(52)
  250.             starterino=false
  251.         end
  252.         if remaining>=3000 and blueready==true and redready==true and starterino==true then
  253.             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)
  254.         elseif remaining>=2000 and blueready==true and redready==true and starterino==true then
  255.             ui.updateTextArea(52,"<b><p align='center'><font face='arial' size='20' color='#FFFFFF'>Starting Game in 2</font></p></b>" ,nil)
  256.         elseif remaining>=1000 and blueready==true and redready==true and starterino==true then
  257.             ui.updateTextArea(52,"<b><p align='center'><font face='arial' size='20' color='#FFFFFF'>Starting Game in 1</font></p></b>" ,nil)
  258.         elseif remaining<=0 and blueready==true and redready==true and starterino==true then
  259.             ffa=true
  260.             selection=false
  261.             tfm.exec.newGame(maps[math.random(#maps)])
  262.         end
  263.     end
  264.     if ffa==true and win==false then
  265.         if time>=8000 then
  266.             ui.removeTextArea(4)
  267.         elseif time >=7000 then
  268.             ui.removeTextArea(2)
  269.             ui.addTextArea(4,"<b><font face='arial' size='50' color='#00FF00'>GO</font></b>" ,nil,355,330,100,60,0x324650,0x212F36,0,true)
  270.             if not started then
  271.                 started=true
  272.             end
  273.         elseif time>=6000 then
  274.             ui.removeTextArea(3)
  275.             ui.addTextArea(2,"<b><font face='arial' size='50' color='#FF0000'>1</font></b>" ,nil,385,330,35,60,0x324650,0x212F36,0,true)
  276.         elseif time>=5000 then
  277.             ui.removeTextArea(1)
  278.             ui.addTextArea(3,"<b><font face='arial' size='50' color='#FF0000'>2</font></b>" ,nil,385,330,35,60,0x324650,0x212F36,0,true)
  279.         elseif time>=4000 then 
  280.             ui.removeTextArea(9999)
  281.             ui.addTextArea(1,"<b><font face='arial' size='50' color='#FF0000'>3</font></b>" ,nil,385,330,35,60,0x324650,0x212F36,0,true)
  282.         elseif time>=0 then
  283.             ui.addTextArea(9999,"<b><font face='Impact' size='50' color='#FFFF00'>Get Ready</font></b>" ,nil,295,330,350,60,0x324650,0x212F36,0,true)
  284.         end
  285.         if remaining<=0 then
  286.             if bluepoints==10 or redpoints==10 then
  287.                 tfm.exec.newGame(disco[math.random(#disco)])
  288.             else
  289.                 tfm.exec.newGame(maps[math.random(#maps)])
  290.             end
  291.         end
  292.         for i,cannon in ipairs(toDespawn) do
  293.             if cannon[1] <= os.time()-3000 then
  294.                 tfm.exec.removeObject(cannon[2])
  295.                 table.remove(toDespawn,i)
  296.             end
  297.         end
  298.     end
  299.     if win==true then
  300.         if time>=3000 then
  301.             if cheese=="red" then
  302.                 for name,player in pairs(tfm.get.room.playerList) do
  303.                     if players[name].team=="red" or players[name].team=="redcaptain" then
  304.                         tfm.exec.playEmote(name, 0)
  305.                     else
  306.                         tfm.exec.playEmote(name, 2)
  307.                     end
  308.                 end
  309.             elseif cheese=="blue" then
  310.                 for name,player in pairs(tfm.get.room.playerList) do
  311.                     if players[name].team=="blue" or players[name].team=="bluecaptain"then
  312.                         tfm.exec.playEmote(name, 0)
  313.                     else
  314.                         tfm.exec.playEmote(name, 2)
  315.                     end
  316.                 end
  317.             end
  318.         end
  319.         if remaining<=0 then
  320.             selection=true
  321.             ffa=false
  322.             discobool=false
  323.             starterino=false
  324.             tfm.exec.newGame("@6396471")
  325.             tfm.exec.newGame("@6396471")
  326.             redpoints=0
  327.             bluepoints=0
  328.             blueready=false
  329.             redready=false
  330.             redteamname="Red Team"
  331.             blueteamname="Blue Team"
  332.             local i=1
  333.             while i<10 do
  334.                 ui.removeTextArea(i,nil)
  335.                 i=i+1
  336.             end
  337.             win=false
  338.         end
  339.     end
  340. end
  341.  
  342.  
  343. function eventPlayerDied(name)
  344.     if ffa==true and win==false then
  345.         local i=0
  346.         local n
  347.         for pname,player in pairs(tfm.get.room.playerList) do
  348.             if not player.isDead then
  349.                 i=i+1
  350.                 n=pname
  351.             end
  352.         end
  353.         if i==0 and win==false then
  354.             tfm.exec.newGame(maps[math.random(#maps)])
  355.         end
  356.         local redalive=0
  357.         local bluealive=0
  358.         for name, player in pairs(tfm.get.room.playerList) do
  359.             if players[name].team=="red" or players[name].team=="redcaptain" then
  360.                 if not player.isDead then
  361.                     redalive=redalive+1
  362.                 end
  363.             elseif players[name].team=="blue" or players[name].team=="bluecaptain" then
  364.                 if not player.isDead then
  365.                     bluealive=bluealive+1
  366.                 end
  367.             end
  368.         end
  369.         if redalive==0 then
  370.             bluepoints=bluepoints+1
  371.             for name, player in pairs(tfm.get.room.playerList) do
  372.                 if players[name].team=="blue" or players[name].team=="bluecaptain" then
  373.                     if not player.isDead then
  374.                         tfm.exec.giveCheese(name)
  375.                         tfm.exec.playerVictory(name)
  376.                     end
  377.                 end
  378.             end
  379.             tfm.exec.setGameTime(5)
  380.         elseif bluealive==0 then
  381.             redpoints=redpoints+1
  382.             for name, player in pairs(tfm.get.room.playerList) do
  383.                 if players[name].team=="red" or players[name].team=="redcaptain" then
  384.                     if not player.isDead then
  385.                         tfm.exec.giveCheese(name)
  386.                         tfm.exec.playerVictory(name)
  387.                     end
  388.                 end
  389.             end
  390.             tfm.exec.setGameTime(5)
  391.         end
  392.     end
  393. end
  394.  
  395. for name,player in pairs(tfm.get.room.playerList) do
  396.     eventNewPlayer(name)
  397. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement