Advertisement
Guest User

Untitled

a guest
Aug 15th, 2014
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. tagger=nil
  2. math.randomseed(os.time())
  3. despawn = 0
  4. map = 2643833
  5. playersAlive = 0
  6.  
  7. function main()
  8.     tfm.exec.disableAutoShaman(true)
  9.     tfm.exec.disableAutoNewGame(true)
  10.     tfm.exec.disableAutoScore(true)
  11.     tfm.exec.newGame(map)
  12.     system.disableChatCommandDisplay("new", true)
  13. end
  14.  
  15. function checkTagger()
  16.     local players={}
  17.     for name,_ in pairs(tfm.get.room.playerList) do
  18.         table.insert(players, name)
  19.     end
  20.     for player in pairs(players) do
  21.         if player==tagger then
  22.             return true
  23.         elseif tagger==nil or name~=tagger then
  24.             return players[math.random(#players)]
  25.         end
  26.     end
  27. end
  28.  
  29. function eventKeyboard(name, key, down, x, y)
  30.     if key == 32 and name == tagger then
  31.         for name, player in pairs(tfm.get.room.playerList) do
  32.             if tagger ~= name then
  33.                 if pythag(x, y, player.x, player.y, 30) == true then
  34.                     tfm.exec.killPlayer(name)
  35.                 end
  36.             end
  37.         end
  38.     end
  39. end
  40.  
  41. function eventLoop(time, remaining)
  42.     if text then
  43.         despawn = despawn + 0.5
  44.         if despawn == 4 then
  45.             ui.removeTextArea(1)
  46.             ui.removeTextArea(2)
  47.             despawn = 0
  48.             text = not text
  49.         end
  50.     end
  51.     if remaining <= 0 or playersAlive == 0 then
  52.         tfm.exec.newGame(map)
  53.     end
  54. end
  55.  
  56. function eventChatCommand(name, cmd)
  57.     if cmd == "new" then
  58.         tfm.exec.newGame(map)
  59.     end
  60. end
  61.  
  62. function eventNewGame()
  63.     playersAlive=0
  64.     text=true
  65.     tagger=nil
  66.     tagger=checkTagger()
  67.     ui.addTextArea(1, "<b><R>You are the tagger!", tagger, 335, 23, 130)
  68.     for name in pairs(tfm.get.room.playerList) do
  69.         playersAlive = playersAlive + 1
  70.         if name~=tagger then
  71.             ui.addTextArea(2, "<V><b><p align = 'center'>"..tagger.." <N>is the tagger, run away!", name, 275, 23, 250)
  72.         end
  73.     end
  74. end
  75.  
  76. function eventPlayerDied(name)
  77.     playersAlive = playersAlive - 1
  78. end
  79.  
  80. function pythag(x1,y1,x2,y2,r)
  81.     local x=x2-x1
  82.     local y=y2-y1
  83.     local r=r+r
  84.     return x*x+y*y<r*r
  85. end
  86.  
  87. function eventNewPlayer(name)
  88.     tfm.exec.bindKeyboard(name, 32, true, true)
  89. end
  90.  
  91. for i,p in pairs(tfm.get.room.playerList) do
  92.     eventNewPlayer(i)
  93. end
  94.  
  95. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement