Ninja_Pig

game1.py

Apr 12th, 2013
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Jail script by PXYC
  3. Edited by Ninja Pig
  4. """
  5.  
  6. from pyspades.common import to_coordinates, coordinates
  7. from commands import add, admin, get_player, join_arguments, name, alias
  8. from pyspades.constants import *
  9.  
  10. jail_location = 0, 0, 0 # Location of game1
  11. jail_coords = [] # e.g. ["B4", "B5"]
  12.  
  13. jail_list = []
  14.  
  15. @name('game')
  16. @alias('g')
  17. @admin
  18. def game1_player(connection, value = None, *args):
  19.     protocol = connection.protocol # Meh
  20.     player = get_player(protocol, value) # Get player
  21.     if player not in protocol.players:
  22.         raise ValueError() # If player doesn't exist, raise error
  23.     else:
  24.         if player.jailed:
  25.             return 'Player ' + player.name + ' Already ingame!' # Player is already jailed!
  26.         elif not player.jailed:
  27.             player.jailed = True # Set player to jailed
  28.             player.reason = reason
  29.             player.squad = None
  30.             player.squad_pref = None
  31.             player.set_location(jail_location) # Move player to jail
  32.             connection.protocol.send_chat("%s has joined game 1!" % (player.name, connection.name, reason)) # Message
  33.             connection.protocol.irc_say("* %s joined game 1" % (connection.name, player.name, reason)) # Message
  34.             jail_list.append(player.name)
  35. add(join_game1) # Add command
  36.  
  37. @name('game1')
  38. def is_jailed(connection, value = None):
  39.     if value is None:
  40.         if not jail_list:
  41.             return 'No players.'
  42.         else:
  43.             return " players: " + ", ".join(jail_list)
  44.     elif value is not None:
  45.         protocol = connection.protocol
  46.         player = get_player(protocol, value)
  47.         if player not in protocol.players:
  48.             raise ValueError()
  49.         else:
  50.             if player.jailed:
  51.                 return 'Player %s is playing game 1' % (player.name, player.reason)
  52.             else:
  53.                 return 'Player %s is not playing.' % (player.name)
  54. @name('quit')
  55. @admin
  56. def quit_from_game(connection, value):
  57.     protocol = connection.protocol # Meh
  58.     player = get_player(protocol, value) # Get player
  59.     if player not in protocol.players:
  60.         raise ValueError() # Errors again
  61.     else:
  62.         if not player.jailed: # If player isn't jailed
  63.             return 'Player ' + player.name + ' is not ingame!' # Message
  64.         elif player.jailed: # If player is jailed
  65.             player.jailed = False # Player is not jailed anymore
  66.             player.kill() # Kill the player
  67.             connection.protocol.send_chat("%s quit the game 1" % (player.name, connection.name)) # Message
  68.             connection.protocol.irc_say('* %s has left game 1' % (player.name, connection.name)) # Message
  69.             jail_list.remove(player.name)
  70.  
  71. @name('quit')
  72. @admin
  73.         def on_disconnect(self):
  74.             if self.jailed:
  75.                 jail_list.remove(self.name)
  76.                 self.jailed = False
  77.             return connection.on_disconnect(self)
  78.     return protocol, JailConnection
RAW Paste Data