Exemplo n.º 1
0
import sbserver
from xsbs.commands import registerCommandHandler
from xsbs.settings import PluginConfig
from xsbs.colors import green, white
import urllib2

cmd_name = 'mytime'
config = PluginConfig(cmd_name)
timezone = config.getOption('Config', 'timezone', 'EST')

def onCommand(cn, command):
     for i in urllib2.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
          if 'EST' in i:
               sbserver.playerMessage(cn, green('The Eastern Standard Time is: ') + white(i))

registerCommandHandler(cmd_name, onCommand)

Exemplo n.º 2
0
		addTimer(1000, duelCountdown, (count-1, map, mode))

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)

registerCommandHandler('duel', onDuelCommand)
registerServerEventHandler('player_disconnect', onPlayerDisconnect)
registerServerEventHandler('map_changed', onMapChange)

Exemplo n.º 3
0
Arquivo: duel.py Projeto: pguenth/xsbs
            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)


registerCommandHandler('duel', onDuelCommand)
registerServerEventHandler('player_disconnect', onPlayerDisconnect)
registerServerEventHandler('map_changed', onMapChange)
Exemplo n.º 4
0
def onNextMapCmd(cn, args):
	'''@description Display next map
	   @usage
	   @public'''
	if args != '':
		sbserver.playerMessage(cn, error('Usage: #nextmap'))
	else:
		try:
			sbserver.playerMessage(cn, info(nextmap_response.substitute(colordict, mapname=getSuccessor(sbserver.gameMode(), sbserver.mapName()))))
		except (KeyError, ValueError):
			sbserver.playerMessage(cn, error('Could not determine next map'))

def onConnect(cn):
	if rotate_on_join[0]:
		rotate_on_join[0] = False
		sbserver.setPaused(False)

if preset_rotation:
	modeMapLists = {}
	for mode in map_modes:
		modeMapLists[mode[0]] = mode[1].replace(' ', '').split(',')
	rotate_on_join = [False]
	mn = modes.index(start_mode)
	sbserver.setMap(modeMapLists[start_mode][0], mn)
	registerServerEventHandler('intermission_ended', presetRotate)
	registerCommandHandler('nextmap', onNextMapCmd)
	registerServerEventHandler('player_connect', onConnect)
else:
	registerServerEventHandler('intermission_ended', onIntermEnd)

Exemplo n.º 5
0
    try:
        p = player(cn)
        if p.gamevars['modified_map'] and spectate_map_modified:
            p.message(warning('You cannot play with a modified map.'))
            p.spectate()
    except KeyError:
        pass
    except ValueError:
        pass


@masterRequired
def mapModifiedSpecCmd(cn, args):
    '''@description Enable or disable spectate clients with modified map
	   @usage enable/disable'''
    p = player(cn)
    if args == 'disable':
        spectate_map_modified = False
        p.message(info('Spectate modified mapes disabled'))
    elif args == 'enable':
        spectate_map_modified = True
        p.message(info('Spectate modified mapes enabled'))
    else:
        p.message(error('Usage: #mapmodifiedspec (enable/disable)'))


registerServerEventHandler('player_modified_map', onMapModified)
registerServerEventHandler('player_active', checkModified)
registerServerEventHandler('player_unspectated', checkModified)
registerCommandHandler('mapmodifiedspec', mapModifiedSpecCmd)
Exemplo n.º 6
0
def checkModified(cn):
	try:
		p = player(cn)
		if p.gamevars['modified_map'] and spectate_map_modified:
			p.message(warning('You cannot play with a modified map.'))
			p.spectate()
	except KeyError:
		pass
	except ValueError:
	 	pass

@masterRequired
def mapModifiedSpecCmd(cn, args):
	'''@description Enable or disable spectate clients with modified map
	   @usage enable/disable'''
	p = player(cn)
	if args == 'disable':
		spectate_map_modified = False
		p.message(info('Spectate modified mapes disabled'))
	elif args == 'enable':
		spectate_map_modified = True
		p.message(info('Spectate modified mapes enabled'))
	else:
		p.message(error('Usage: #mapmodifiedspec (enable/disable)'))

registerServerEventHandler('player_modified_map', onMapModified)
registerServerEventHandler('player_active', checkModified)
registerServerEventHandler('player_unspectated', checkModified)
registerCommandHandler('mapmodifiedspec', mapModifiedSpecCmd)

Exemplo n.º 7
0
        try:
            sbserver.playerMessage(
                cn,
                info(
                    nextmap_response.substitute(colordict,
                                                mapname=getSuccessor(
                                                    sbserver.gameMode(),
                                                    sbserver.mapName()))))
        except (KeyError, ValueError):
            sbserver.playerMessage(cn, error('Could not determine next map'))


def onConnect(cn):
    if rotate_on_join[0]:
        rotate_on_join[0] = False
        sbserver.setPaused(False)


if preset_rotation:
    modeMapLists = {}
    for mode in map_modes:
        modeMapLists[mode[0]] = mode[1].replace(' ', '').split(',')
    rotate_on_join = [False]
    mn = modes.index(start_mode)
    sbserver.setMap(modeMapLists[start_mode][0], mn)
    registerServerEventHandler('intermission_ended', presetRotate)
    registerCommandHandler('nextmap', onNextMapCmd)
    registerServerEventHandler('player_connect', onConnect)
else:
    registerServerEventHandler('intermission_ended', onIntermEnd)