Advertisement
tjone270

slaphappy.py (modified)

Mar 1st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import minqlx
  2. from time import sleep
  3.  
  4. class slaphappy(minqlx.Plugin):
  5.  
  6.     def __init__(self):
  7.         self.add_command("slaphappy", self.cmd_slaphappy, 2, usage="<id> <number of slaps> <delay between slaps> [damage]")
  8.  
  9.     def cmd_slaphappy(self, player, msg, channel):
  10.         if len(msg) < 3:
  11.             return minqlx.RET_USAGE
  12.        
  13.         try:
  14.             slapee = self.player(int(msg[1]))
  15.             if not (0 <= int(msg[1]) < 64) or not slapee:
  16.                 raise ValueError
  17.         except ValueError:
  18.             channel.reply("Invalid ID.")
  19.             return minqlx.RET_STOP_ALL
  20.  
  21.         if not int(msg[4]):
  22.             damage = 0
  23.         else:
  24.             damage = int(msg[4])
  25.        
  26.         counter = 0
  27.         channel.reply("SLAPHAPPY ACTIVATED ON {}^7!".format(slapee.name))
  28.  
  29.         @minqlx.thread
  30.         def f():
  31.             while counter < int(msg[2]):
  32.                 slapee.health = (slapee.health - damage)
  33.                 slapee.velocity(z=50)
  34.                 time.sleep(float(msg[3]))
  35.                 counter += 1
  36.             f()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement