Kickjkee

Untitled

Aug 14th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ["help"].forEach(function (command) {
  2.     nm.System.DisableChatCommandDisplay(command, true)
  3. })
  4.  
  5. nm.DisableAutoShaman()
  6. nm.DisableAutoNewGame()
  7. nm.DisableAutoTimeLeft()
  8.  
  9. var first = false
  10.  
  11. var players = {}
  12. var options = {
  13.     Keys: [0x28, 0x53, 0x20],
  14. }
  15. var maps = ["@4075355", "@4074458", "@4074459", "@4074460", "@4074461", "@4074464", "@4074438", "@4074439", "@4074483", "@4074496", "@4074494",
  16.     "@4074493", "@4076664,4076668", "@4076666", "@4076781", "@4076772", "@4076764", "@4076748", "@4074583", "@4074586", "@4074587", "@4076836",
  17.     "@4076839", "@4076840", "@4076850", "@4076951", "@4077869", "@4077505", "@4078343", "@4078349", "@4077872", "@4077953", "@4077521", "@4076872",
  18.     "@4076962", "@4077854", "@4077468", "@4077503", "@4077970", "@4077049", "@4078272", "@4077962", "@4077518", "@4076852", "@4077876", "@4077500",
  19.     "@4077967", "@4078347", "@4077875", "@4077861", "@4078273", "@4076855", "@4077974", "@4077883", "@4076853", "@5000723", "@5000540", "@5000524",
  20.     "@5000527", "@5000530", "@4077881", "@4078344", "@4077648", "@5001225", "@5000761", "@5000756", "@5000757", "@5003258", "@5002857", "@5001668",
  21.     "@5001664", "@5001717", "@5001661", "@5001408", "@5001401"]
  22. var state = {
  23.     Started: false,
  24. }
  25.  
  26. function EventNewGame() {
  27.     state.Started = false
  28.  
  29.     nm.SetUIMapName("<N>Deathmatch")
  30.  
  31.     for (var playerName in players) {
  32.         var player = players[playerName]
  33.  
  34.         player.PreviousCannonID = 0
  35.         player.ShootAt = Date.now()
  36.     }
  37. }
  38.  
  39. function EventNewPlayer(playerName) {
  40.     nm.SetUIMapName("<N>Deathmatch", playerName)
  41.  
  42.     players[playerName] = {
  43.         Offset: {
  44.             x: 2,
  45.             y: 10,
  46.         },
  47.         PreviousCannonID: 0,
  48.         ShootAt: Date.now(),
  49.  
  50.         canShoot: function () {
  51.             if (this.ShootAt < (Date.now() - 800)) {
  52.                 return true
  53.             }
  54.             return false
  55.         }
  56.     }
  57.  
  58.     for (var i in options.Keys) {
  59.         var key = options.Keys[i]
  60.  
  61.         nm.BindKeyboard(playerName, key, true, true);
  62.     }
  63. }
  64.  
  65.  
  66. function EventPlayerDied(playerName) {
  67.     if (players[playerName] == undefined) {
  68.         return
  69.     }
  70.     var alivePlayers = getAlivePlayers()
  71.  
  72.     nm.SetUIMapName("<N>Deathmatch: <V>" + alivePlayers.length.toString() + "</V> в живых")
  73. }
  74.  
  75. function EventPlayerLeft(playerName) {
  76.     delete players[playerName]
  77. }
  78.  
  79. function EventKeyboard(playerName, keyCode, down, x, y) {
  80.     if (!state.Started || players[playerName] == undefined) {
  81.         return
  82.     }
  83.     var player = players[playerName]
  84.     var mouse = nm.Room.GetPlayer(playerName)
  85.     if (mouse.IsDead) {
  86.         return
  87.     }
  88.  
  89.     if (keyCode == 0x28 || keyCode == 0x53 || keyCode == 0x20) {
  90.         if (player.canShoot()) {
  91.             player.ShootAt = Date.now()
  92.  
  93.             if (player.PreviousCannonID !== 0) {
  94.                 nm.RemoveObject(player.PreviousCannonID)
  95.             }
  96.  
  97.             var posX = mouse.Turn == 0 ? (x - player.Offset.x) : (x + player.Offset.x)
  98.             var posY = y + player.Offset.y
  99.             var angle = mouse.Turn == 0 ? 270 : 90
  100.  
  101.             player.PreviousCannonID = nm.AddShamanObject(17, posX, posY, angle, 0, 0, false)
  102.         }
  103.     }
  104. }
  105.  
  106. function EventChatCommand(playerName, command) {
  107.     if (players[playerName] == undefined) {
  108.         return
  109.     }
  110.     var player = players[playerName]
  111.  
  112.     var args = command.split(" ")
  113.     switch (args[0]) {
  114.         case "offset":
  115.         case "off":
  116.             if (args.length == 0) {
  117.                 nm.ChatMessage("<J># <BL>Офссет: X " + player.Offset.x + " | Y " + player.Offset.y, playerName)
  118.                 break
  119.             }
  120.             if (args.length !== 3) {
  121.                 nm.ChatMessage("<J># <BL>Используйте: !off x y", playerName)
  122.                 break
  123.             }
  124.             player.Offset.x = Number(args[1])
  125.             player.Offset.y = Number(args[2])
  126.  
  127.             nm.ChatMessage("<J># <BL>Новый оффсет: X " + player.Offset.x + " | Y " + player.Offset.y, playerName)
  128.             break;
  129.         case "help":
  130.             nm.ChatMessage("<J># <BL>- Help", playerName)
  131.             nm.ChatMessage("<J># <BL>Используйте: !off x y", playerName)
  132.             break;
  133.     }
  134. }
  135.  
  136. function EventLoop(time, remaining) {
  137.     if (!first) {
  138.         nm.Room.GetPlayers().forEach(function (player, i) {
  139.             EventNewPlayer(player.Name);
  140.         });
  141.  
  142.         nm.NewGame(maps[Math.floor(Math.random() * maps.length)])
  143.  
  144.         first = true
  145.         return
  146.     }
  147.  
  148.     if (time >= 3000 && !state.Started) {
  149.         state.Started = true
  150.     }
  151.  
  152.     if (remaining >= 500000 || remaining <= 0) {
  153.         nm.NewGame(maps[Math.floor(Math.random() * maps.length)])
  154.         return
  155.     }
  156.  
  157.     if (remaining > 10000 && getAlivePlayers().length <= 1) {
  158.         nm.SetGameTime(10)
  159.     }
  160. }
  161.  
  162. function getAlivePlayers() {
  163.     var alivePlayers = []
  164.  
  165.     nm.Room.GetPlayers().forEach(function (player, i) {
  166.         if (!player.IsDead) {
  167.             alivePlayers.push(player)
  168.         }
  169.     });
  170.  
  171.     return alivePlayers
  172. }
Advertisement
Add Comment
Please, Sign In to add comment