Advertisement
zigwin

snowballs

Dec 30th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1.  
  2. -- Options
  3. spawnCooldown = 1000
  4. snowballPower = 10
  5. canPlayerRespawn = false -- false or true
  6. --
  7.  
  8. tfm.exec.snow(1,snowballPower)
  9.  
  10. tfm.exec.disableAutoTimeLeft(true)
  11. tfm.exec.disableAutoNewGame(true)
  12. tfm.exec.disableAutoScore(true)
  13. tfm.exec.disableAfkDeath(true)
  14. tfm.exec.disableAutoShaman(true)
  15.  
  16. function eventPlayerDied(playerName)
  17. if canPlayerRespawn then    tfm.exec.respawnPlayer (playerName) end
  18. end
  19.  
  20. -- by zigwin
  21. --system.bindMouse(admin, true)
  22. playerData={}
  23. function eventNewPlayer(playerName)
  24.     system.bindMouse(playerName, true)
  25.     tfm.exec.respawnPlayer (playerName)
  26.     playerData[playerName]={cooldown=3000}
  27. end
  28.  
  29. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  30.  
  31. function radiusPointFromMouse(xMousePosition, yMousePosition, radius, playerName)
  32.     local angle = 0
  33.  
  34.     if tfm.get.room.playerList[playerName].y >= yMousePosition then
  35.         angle = angle+180
  36.     end
  37.  
  38.     xMousePosition = xMousePosition - tfm.get.room.playerList[playerName].x
  39.     yMousePosition = -(yMousePosition - tfm.get.room.playerList[playerName].y)
  40.     if not radius then radius = 50 end
  41.  
  42.     angle = angle + math.atan(xMousePosition / yMousePosition) / math.pi * 180
  43.  
  44.     return radius*xMousePosition/math.ceil(math.sqrt(xMousePosition^2 + yMousePosition^2)), radius*yMousePosition/math.ceil(math.sqrt(xMousePosition^2 + yMousePosition^2)), angle
  45. end
  46. function eventMouse(playerName, xMousePosition, yMousePosition)
  47.     if os.time() > playerData[playerName].cooldown then
  48.         playerData[playerName].cooldown = os.time() + spawnCooldown
  49.  
  50.         local x, y, angle = radiusPointFromMouse(xMousePosition, yMousePosition, 50, playerName)
  51.    
  52.         y = -y
  53.    
  54.         xSpeed = (xMousePosition - tfm.get.room.playerList[playerName].x)/10
  55.         ySpeed = (yMousePosition - tfm.get.room.playerList[playerName].y)/10
  56.    
  57.         tfm.exec.addShamanObject(34, x+tfm.get.room.playerList[playerName].x, y+tfm.get.room.playerList[playerName].y, angle, xSpeed, ySpeed)
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement