예제 #1
0
    def _set_team(self, value):
        # Does the player still exist?
        if not _es.exists('userid', self.userid):
            raise ValueError("userid (%s) doesn't exist." % self.userid)

        # Check for valid team values
        try:
            value = int(value)
            if value not in xrange(1, 4):
                raise ValueError
        except (TypeError, ValueError):
            raise ValueError('"%s" is an invalid team' % value)

        # Make sure we are not moving the player to the same team
        if self.team == value:
            return

        # Change the team
        _spe.switchTeam(self.userid, value)

        # No model change needed if going to spectator
        if value == 1:
            return

        # Retrieve a playerlib instance
        pPlayer = _getPlayer(self.userid)

        # Change to Terrorist Models
        if value == 2:
            pPlayer.model = 'player/%s' % choice(('t_arctic', 't_guerilla',
                                                  't_leet', 't_phoenix'))
        # Change to Counter-Terrorist Models
        else:
            pPlayer.model = 'player/%s' % choice(('ct_gign', 'ct_gsg9',
                                                  'ct_sas', 'ct_urban'))
예제 #2
0
    def _set_team(self, value):
        # Does the player still exist?
        if not _es.exists('userid', self.userid):
            raise ValueError("userid (%s) doesn't exist." % self.userid)

        # Check for valid team values
        try:
            value = int(value)
            if value not in xrange(1, 4):
                raise ValueError
        except (TypeError, ValueError):
            raise ValueError('"%s" is an invalid team' % value)

        # Make sure we are not moving the player to the same team
        if self.team == value:
            return

        # Change the team
        _spe.switchTeam(self.userid, value)

        # No model change needed if going to spectator
        if value == 1:
            return

        # Retrieve a playerlib instance
        pPlayer = _getPlayer(self.userid)

        # Change to Terrorist Models
        if value == 2:
            pPlayer.model = 'player/%s' % choice(
                ('t_arctic', 't_guerilla', 't_leet', 't_phoenix'))
        # Change to Counter-Terrorist Models
        else:
            pPlayer.model = 'player/%s' % choice(
                ('ct_gign', 'ct_gsg9', 'ct_sas', 'ct_urban'))
예제 #3
0
 def switchTeam(self, teamnum, tmodel="player/t_arctic.mdl", ctmodel="player/ct_gign.mdl"):
     """switch player's team without killing the player
     It will also change the player's model, and move them to their spawn point.
     teamnum - the team number. 2 - Terrorist; 3 - CT; 1 - Spectator
     tmodel - the model of terrorist to change to. Default: player/t_arctic.mdl
     ctmodel - the model of counter terrorist to change to. Default: player/ct_gign.mdl"""
     spe.switchTeam(self.userid, teamnum)
     if teamnum == 2:
         self.moveToSpawn(2)
         self.model = tmodel
     elif teamnum == 3:
         self.moveToSpawn(3)
         self.model = ctmodel