Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #forced_attack.py
- from players.constants import PlayerButtons
- from players.helpers import index_from_userid
- from listeners import OnPlayerRunCommand
- from commands import CommandReturn
- from commands.client import ClientCommand
- forced_players = []
- @OnPlayerRunCommand
- def player_run_cmd(player, cmd):
- if player.userid not in forced_players:
- return
- if player.dead:
- return
- # force the player to attack
- # this is basically like typing +attack in console
- cmd.buttons |= PlayerButtons.ATTACK
- def toggle_forced_attack(userid):
- # does this userid exist?
- try:
- index = index_from_userid(userid)
- except:
- print('toggle_forced_attack: invalid userid > {0}'.format(userid))
- return
- # is the userid already in the list?
- if userid in forced_players:
- # if it is, remove it
- forced_players.remove(userid)
- return
- # add the userid to the list
- forced_players.append(userid)
- # toggle_forced_attack <userid>
- @ClientCommand('toggle_forced_attack')
- def _toggle_forced_attack(command, index):
- try:
- userid = int(command[1])
- except:
- print('toggle_forced_attack: bad argument > {0}'.format(command.arg_string))
- return CommandReturn.BLOCK
- toggle_forced_attack(userid)
- return CommandReturn.BLOCK
- @ClientCommand('stop_forcing_all')
- def _stop_forcing_all(command, index):
- forced_players.clear()
- return CommandReturn.BLOCK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement