Exemplo n.º 1
0
def login(cn, user):
	if isLoggedIn(cn):
		raise StateError('You are already logged in')
	player(cn).user = user
	player(cn).logged_in = True
	triggerServerEvent('player_logged_in', (cn,))
	sbserver.message(info(green(sbserver.playerName(cn)) + ' is verified'))
Exemplo n.º 2
0
Arquivo: mute.py Projeto: pguenth/xsbs
def onMuteCommand(cn, args):
    '''@description Mute a player
	   @usage cn'''
    try:
        args = args.split(' ')
        tcn = int(args[0])
        if len(args) > 1:
            raise KeyError
        try:
            p = player(tcn)
        except ValueError:
            raise StateError('Invalid player cn')
        else:
            try:
                muted = p.is_muted
            except AttributeError:
                muted = False
            if muted:
                raise StateError('Player is already muted.')
            else:
                p.is_muted = True
                name = p.name()
                muter = player(cn).name()
                sbserver.message(
                    info(
                        muted_temp.substitute(colordict,
                                              muted_name=name,
                                              muter=muter)))
    except KeyError:
        raise UsageError()
Exemplo n.º 3
0
Arquivo: duel.py Projeto: pguenth/xsbs
def onDuelCommand(cn, args):
    if args == '':
        sbserver.playerMessage(
            cn, error('Usage: #duel <mapname> (mode) (cn) (cn)'))
    args = args.split(' ')
    players = sbserver.players()
    if len(players) != 2:
        sbserver.playerMessage(
            cn,
            error(
                'There must be only two unspectated players to enter duel mode.'
            ))
    else:
        if len(args) == 2:
            map = args[0]
            mode = int(args[1])
        elif len(args) == 1:
            map = args[0]
            mode = sbserver.gameMode()
        else:
            sbserver.playerMessage(cn, error('Usage: #duel <mapname> (mode)'))
            return
        duelers[0] = players[0]
        duelers[1] = players[1]
        prev_mastermode = sbserver.masterMode()
        sbserver.setMasterMode(2)
        sbserver.message(green('Duel begins in...'))
        duelCountdown(5, map, mode)
Exemplo n.º 4
0
	def check_domination(self):
		if self.last_victim == self.current_victim:
			self.domination_count += 1
		else:
			self.domination_count = 0
		if self.domination_count in dommessages.keys():
			sbserver.message(info(dommessages[self.domination_count].substitute(killername=player(self.playercn).name(), victimname=player(self.last_victim).name())))
Exemplo n.º 5
0
def onMuteCommand(cn, args):
	'''@description Mute a player
	   @usage cn'''
	try:
		args = args.split(' ')
		tcn = int(args[0])
		if len(args) > 1:
			raise KeyError
		try:	
			p = player(tcn)
		except ValueError:
			raise StateError('Invalid player cn')
		else:
			try:
				muted = p.is_muted
			except AttributeError:
			 	muted = False
			if muted:
				raise StateError('Player is already muted.')
			else:
				p.is_muted = True
				name = p.name()
				muter = player(cn).name()
				sbserver.message(info(muted_temp.substitute(colordict, muted_name=name, muter=muter)))
	except KeyError:
		raise UsageError()
Exemplo n.º 6
0
def onMapVote(cn, mapname, mapmode):
    p = player(cn)
    if sbserver.mapName() == '':
        setMap(mapname, mapmode)
    elif isAtLeastMaster(cn) and sbserver.masterMode() > 0:
        setMap(mapname, mapmode)
    elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote):
        p.message(error('You cannot vote for a new game mode'))
    else:
        try:
            vote = player(cn).gamevars['mapvote']
            allow_vote = vote[0] != mapname and vote[1] != mapmode
        except KeyError:
            allow_vote = True
        if allow_vote:
            sbserver.message(
                info(
                    request_temp.substitute(
                        colordict,
                        user=p.name(),
                        modename=sbserver.modeName(mapmode),
                        mapname=mapname)))
            p.gamevars['mapvote'] = (mapname, mapmode)
        else:
            sbserver.playerMessage(
                cn, error('You have already requested this map.'))
    countVotes()
Exemplo n.º 7
0
Arquivo: mute.py Projeto: pguenth/xsbs
def onUnmuteCommand(cn, args):
    '''@description Unmute a player
	   @usage cn'''
    try:
        args = args.split(' ')
        tcn = int(args[0])
        if len(args) > 1:
            raise KeyError
        try:
            p = player(tcn)
            if p.is_muted:
                p.is_muted = False
                muter = player(cn).name()
                sbserver.message(
                    info(
                        unmuted_temp.substitute(colordict,
                                                muted_name=p.name(),
                                                muter=muter)))
            else:
                raise StateError('Specified player is not crrently muted')
        except AttributeError:
            raise StateError('Specified player is not currently muted.')
    except KeyError:
        raise UsageError('No cn specified')
    except ValueError:
        raise ArgumentValueError('Invalid player cn')
Exemplo n.º 8
0
Arquivo: ctl.py Projeto: pguenth/xsbs
def playerIp(cn, args):
	'''@description Get string representation of client ip
	   @usage cn
	   @master'''
	if args == '':
		raise UsageError()
	else:
		sbserver.message(info(player(int(args)).ipString()))
Exemplo n.º 9
0
def playerIp(cn, args):
	'''@description Get string representation of client ip
	   @usage cn
	   @master'''
	if args == '':
		raise UsageError()
	else:
		sbserver.message(info(player(int(args)).ipString()))
Exemplo n.º 10
0
def serverMessage(cn, args):
	'''@description Broadcast message to all clients in server
	   @usage message
	   @master'''
	if args == '':
		raise UsageError()
	else:
		msg = servermsg_template.substitute(colordict, sender=sbserver.playerName(cn), message=args)
		sbserver.message(msg)
Exemplo n.º 11
0
Arquivo: ctl.py Projeto: pguenth/xsbs
def serverMessage(cn, args):
	'''@description Broadcast message to all clients in server
	   @usage message
	   @master'''
	if args == '':
		raise UsageError()
	else:
		msg = servermsg_template.substitute(colordict, sender=sbserver.playerName(cn), message=args)
		sbserver.message(msg)
Exemplo n.º 12
0
Arquivo: mute.py Projeto: pguenth/xsbs
def onUnMuteSpectatorsCmd(cn, args):
    '''@description Unmute spectators
	   @usage'''
    if args == '':
        if mute_spectators[0] == False:
            raise StateError('Spectators are not currently muted')
        else:
            mute_spectators[0] = False
            sbserver.message(notice('Spectators are no longer muted'))
    else:
        raise ExtraArgumentError()
Exemplo n.º 13
0
Arquivo: mute.py Projeto: pguenth/xsbs
def onMuteSpectatorsCmd(cn, args):
    '''@description Mute all spectators
	   @usage'''
    if args == '':
        if mute_spectators[0] == True:
            raise StateError('Spectators are arleady muted')
        else:
            mute_spectators[0] = True
            sbserver.message(notice('Spectators are now muted'))
    else:
        raise ExtraArgumentError()
Exemplo n.º 14
0
def persistentTeamsCmd(cn, args):
    '''@description Keep current teams as they are across multiple games.
	   @usage on/off'''
    if args == 'on':
        persistentTeams(True)
        sbserver.message(notice('Persistent teams enabled'))
    elif args == 'off':
        persistentTeams(False)
        sbserver.message(notice('Persistent teams disabled'))
    else:
        raise UsageError('on/off')
Exemplo n.º 15
0
def onMuteSpectatorsCmd(cn, args):
	'''@description Mute all spectators
	   @usage'''
	if args == '':
		if mute_spectators[0] == True:
			raise StateError('Spectators are arleady muted')
		else:
			mute_spectators[0] = True
			sbserver.message(notice('Spectators are now muted'))
	else:
		raise ExtraArgumentError()
Exemplo n.º 16
0
def onUnMuteSpectatorsCmd(cn, args):
	'''@description Unmute spectators
	   @usage'''
	if args == '':
		if mute_spectators[0] == False:
			raise StateError('Spectators are not currently muted')
		else:
			mute_spectators[0] = False
			sbserver.message(notice('Spectators are no longer muted'))
	else:
		raise ExtraArgumentError()
Exemplo n.º 17
0
def persistentTeamsCmd(cn, args):
    """@description Keep current teams as they are across multiple games.
	   @usage on/off"""
    if args == "on":
        persistentTeams(True)
        sbserver.message(notice("Persistent teams enabled"))
    elif args == "off":
        persistentTeams(False)
        sbserver.message(notice("Persistent teams disabled"))
    else:
        raise UsageError("on/off")
Exemplo n.º 18
0
def duelCountdown(count, map, mode):
	players = sbserver.players()
	if len(sbserver.players()) != 2 or players[0] not in duelers or players[1] not in duelers:
		cancelDuel()
	elif count == 0:
		currently_dueling[0] = True
		sbserver.message(green('Fight!'))
		sbserver.setMap(map, mode)
		sbserver.setPaused(False)
	else:
		sbserver.message(green('%i seconds' % count))
		addTimer(1000, duelCountdown, (count-1, map, mode))
Exemplo n.º 19
0
Arquivo: demo.py Projeto: pguenth/xsbs
def playerRecordNextMatch(cn, val):
	if permissions_ok(cn):
		if val == sbserver.nextMatchRecorded():
			return
		if val:
			act = 'enabled'
		else:
			act = 'disabled'
		sbserver.setRecordNextMatch(val)
		sbserver.message(notice(action_temp.substitute(colordict, action=act, user=sbserver.playerName(cn))))
	else:
		insufficientPermissions(cn)
Exemplo n.º 20
0
Arquivo: duel.py Projeto: pguenth/xsbs
def duelCountdown(count, map, mode):
    players = sbserver.players()
    if len(sbserver.players()
           ) != 2 or players[0] not in duelers or players[1] not in duelers:
        cancelDuel()
    elif count == 0:
        currently_dueling[0] = True
        sbserver.message(green('Fight!'))
        sbserver.setMap(map, mode)
        sbserver.setPaused(False)
    else:
        sbserver.message(green('%i seconds' % count))
        addTimer(1000, duelCountdown, (count - 1, map, mode))
Exemplo n.º 21
0
def onVoteKick(cn, args):
	'''@description Vote to kick a player from server
	   @usage <cn>'''
	if args == '':
		sbserver.playerMessage(cn, error('Usage #votekick <cn>'))
	else:
		try:
			tcn = int(args)
			if player(cn).votekick == tcn:
				sbserver.playerMessage(cn, error('You have already voted to kick that player.'))
				allow_vote = False
			else:
				allow_vote = True
		except AttributeError:
			allow_vote = True
		if allow_vote:
			sbserver.message(info(vktemp.substitute(colordict, voter=sbserver.playerName(cn), victim=sbserver.playerName(tcn))))
			player(cn).votekick = int(args)
			checkVotes(int(args))
Exemplo n.º 22
0
def ban(cn, seconds, reason, banner_cn):
	ip = sbserver.playerIpLong(cn)
	expiration = time.time() + seconds
	nick = sbserver.playerName(cn)
	if banner_cn != -1:
		banner_ip = sbserver.playerIpLong(banner_cn)
		banner_nick = sbserver.playerName(banner_cn)
	else:
		banner_ip = 0
		banner_nick = ''
	newban = Ban(ip, expiration, reason, nick, banner_ip, banner_nick, time.time())
	session.add(newban)
	session.commit()
	addTimer(200, sbserver.playerKick, (cn,))
	logging.info('Player %s (%s) banned for %s by %s (%s)',
		nick,
		ipLongToString(ip),
		reason,
		banner_nick,
		ipLongToString(banner_ip))
	sbserver.message(info(ban_message.substitute(colordict, name=nick, seconds=seconds, reason=reason)))
Exemplo n.º 23
0
def setPaused(val, cn=-1):
	'''Pause or unpause the game'''
	if isFrozen():
		raise StateError('Server is currently frozen')
	if val == isPaused():
		return
	if val:
		action = 'paused'
	else:
		action = 'unpaused'
	try:
		p = player(cn)
	except ValueError:
		name = 'Unknown'
	else:
		name = p.name()
	sbserver.message(notice(pause_message.substitute(
		colordict,
		action=action,
		name=name)))
	sbserver.setPaused(val)
Exemplo n.º 24
0
def onUnmuteCommand(cn, args):
	'''@description Unmute a player
	   @usage cn'''
	try:
		args = args.split(' ')
		tcn = int(args[0])
		if len(args) > 1:
			raise KeyError
		try:
			p = player(tcn)
			if p.is_muted:
				p.is_muted = False
				muter = player(cn).name()
				sbserver.message(info(unmuted_temp.substitute(colordict, muted_name=p.name(), muter=muter)))
			else:
				raise StateError('Specified player is not crrently muted')
		except AttributeError:
			raise StateError('Specified player is not currently muted.')
	except KeyError:
		raise UsageError('No cn specified')
	except ValueError:
		raise ArgumentValueError('Invalid player cn')
Exemplo n.º 25
0
def onMapVote(cn, mapname, mapmode):
	p = player(cn)
	if sbserver.mapName() == '':
		setMap(mapname, mapmode)
	elif isAtLeastMaster(cn) and sbserver.masterMode() > 0:
		setMap(mapname, mapmode)
	elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote):
		p.message(error('You cannot vote for a new game mode'))
	else:
		try:
			vote = player(cn).gamevars['mapvote']
			allow_vote = vote[0] != mapname and vote[1] != mapmode
		except KeyError:
			allow_vote = True
		if allow_vote:
			sbserver.message(info(request_temp.substitute(colordict,
				user=p.name(),
				modename=sbserver.modeName(mapmode),
				mapname=mapname)))
			p.gamevars['mapvote'] = (mapname, mapmode)
		else:
			sbserver.playerMessage(cn, error('You have already requested this map.'))
	countVotes()
Exemplo n.º 26
0
def onDuelCommand(cn, args):
	if args == '':
		sbserver.playerMessage(cn, error('Usage: #duel <mapname> (mode) (cn) (cn)'))
	args = args.split(' ')
	players = sbserver.players()
	if len(players) != 2:
		sbserver.playerMessage(cn, error('There must be only two unspectated players to enter duel mode.'))
	else:
		if len(args) == 2:
			map = args[0]
			mode = int(args[1])
		elif len(args) == 1:
			map = args[0]
			mode = sbserver.gameMode()
		else:
			sbserver.playerMessage(cn, error('Usage: #duel <mapname> (mode)'))
			return
		duelers[0] = players[0]
		duelers[1] = players[1]
		prev_mastermode = sbserver.masterMode()
		sbserver.setMasterMode(2)
		sbserver.message(green('Duel begins in...'))
		duelCountdown(5, map, mode)
Exemplo n.º 27
0
def onVoteKick(cn, args):
    '''@description Vote to kick a player from server
	   @usage <cn>'''
    if args == '':
        sbserver.playerMessage(cn, error('Usage #votekick <cn>'))
    else:
        try:
            tcn = int(args)
            if player(cn).votekick == tcn:
                sbserver.playerMessage(
                    cn, error('You have already voted to kick that player.'))
                allow_vote = False
            else:
                allow_vote = True
        except AttributeError:
            allow_vote = True
        if allow_vote:
            sbserver.message(
                info(
                    vktemp.substitute(colordict,
                                      voter=sbserver.playerName(cn),
                                      victim=sbserver.playerName(tcn))))
            player(cn).votekick = int(args)
            checkVotes(int(args))
Exemplo n.º 28
0
def noticeingame(msg):
	sbserver.message("\f1%s" % msg)
Exemplo n.º 29
0
	def check_sprees(self):
		if self.kills_since_death in spreemessages.keys():
			sbserver.message(info(spreemessages[self.kills_since_death].substitute(name=player(self.playercn).name())))
Exemplo n.º 30
0
def announce(cn):
	sbserver.message(sbtools.orange(sbserver.playerName(cn) + " is connected from " + str(getCountry(sbserver.playerIpLong(cn)))))
Exemplo n.º 31
0
def sayingame(msg):
	sbserver.message(msg)
Exemplo n.º 32
0
def setMM(cn, mm):
    sbserver.message((info(green('%s') + ' set master mode to ' + blue('%s')) %
                      (sbserver.playerName(cn), MMNAMES[mm])))
    sbserver.setMasterMode(mm)
Exemplo n.º 33
0
def greet(cn):
	sbserver.message("Hello, " + sbserver.playerName(cn) + ".")
Exemplo n.º 34
0
def message(string):
	'''Send message to server.'''
	sbserver.message(string)
Exemplo n.º 35
0
def onAuthSuccess(cn, name):
	sbserver.message(info(authtemp.substitute(colordict, name=sbserver.playerName(cn), authname=name)))
Exemplo n.º 36
0
	def check_if_ending_spree(self, killercn):
		if self.kills_since_death >= 5:
			if killercn == -2:
				sbserver.message(info(suicideendmsg.substitute(victimname=player(self.playercn).name())))
			else:
				sbserver.message(info(endmsg.substitute(victimname=player(self.playercn).name(), killername=player(killercn).name())))
Exemplo n.º 37
0
Arquivo: duel.py Projeto: pguenth/xsbs
def cancelDuel():
    endDuel()
    sbserver.message(info('Duel cancelled.'))
Exemplo n.º 38
0
def noticeingame(msg):
	sbserver.message(msg)
Exemplo n.º 39
0
def cancelDuel():
	endDuel()
	sbserver.message(info('Duel cancelled.'))
Exemplo n.º 40
0
def onAuthSuccess(cn, name):
    sbserver.message(
        info(
            authtemp.substitute(colordict,
                                name=sbserver.playerName(cn),
                                authname=name)))
Exemplo n.º 41
0
def onRelAdmin(cn):
	sbserver.message(info(ratemp.substitute(colordict, name=sbserver.playerName(cn))))
Exemplo n.º 42
0
def setMM(cn, mm):
	sbserver.message((info(green('%s') + ' set master mode to ' + blue('%s')) % (sbserver.playerName(cn), MMNAMES[mm])))
	sbserver.setMasterMode(mm)
Exemplo n.º 43
0
def onRelMaster(cn):
    sbserver.message(
        info(rmtemp.substitute(colordict, name=sbserver.playerName(cn))))
Exemplo n.º 44
0
def usercommunicationingame(caller,msg):
	if caller[0]=="ingame":
		return
	sbserver.message(""+formatCaller(caller)+": "+msg)
Exemplo n.º 45
0
def onRelAdmin(cn):
    sbserver.message(
        info(ratemp.substitute(colordict, name=sbserver.playerName(cn))))
Exemplo n.º 46
0
def onRelMaster(cn):
	sbserver.message(info(rmtemp.substitute(colordict, name=sbserver.playerName(cn))))