def cmdTeams(obj, t): msg = obj.data["msg"].split(" ") sender = obj.data["sender"] redPlayers = A.retrieveTeam('red') bluePlayers = A.retrieveTeam('blue') toTeam = 0 fromTeam = None difference = abs(len(redPlayers) - len(bluePlayers)) if difference <= 1: A.tell(sender, "Teams are already balanced.") return A.rcon('bigtext "AUTO-BALANCING TEAMS') if len(bluePlayers) > len(redPlayers): fromTeam = bluePlayers toTeam = 1 elif len(redPlayers) > len(bluePlayers): fromTeam = redPlayers toTeam = 2 while difference > 1: # pick a cid from fromTeam cid = random.choice(fromTeam) fromTeam.remove(cid) A.rcon("forceteam %s %s" % (cid, toTeam)) difference -= 1 A.say("Balanced teams.") #<<< should be told to the user?
def cmdKick(obj, t): msg = obj.data["msg"].split(" ") sender = obj.data["sender"] if len(msg) == 1: A.tell(sender, "Usage: !kick <user>") elif len(msg) == 2: if msg[1].isdigit(): kick = int(msg[1]) #@DEV This needs a check to see if players name is 0 or something annoying like that else: cli = A.findClient(msg[1]) if cli != None: kick = cli.uid A.rcon('clientkick %d' % kick)
def cmdMap(obj, t): msg = obj.data["msg"].split(" ") sender = obj.data["sender"] if len(msg) == 1: A.tell(sender, "Usage: !map <map>") elif len(msg) == 2: maps = A.findMap(msg[1]) if len(maps) == 0: A.tell(sender, "No map found matching that name") elif len(maps) > 1: A.tell(sender, "Found %d maps: %s" % (len(maps), maps)) else: A.rcon('set thismap "map %s"' % maps[0]) A.rcon('vstr thismap')
def cmdIDDQD(obj, t): sender = obj.data['sender'] client = A.getClient(sender) db = database.DB() db.tableSelect("clients") entry = db.rowFind(client.cl_guid, 'guid') entry["cgroup"] = 5 db.rowUpdate(entry) db.commit() db.disconnect() A.rcon('bigtext "Congratuations! You have exquisite taste.') A.delCmd("!iddqd")
def cmdNuke(obj, t): msg = obj.data["msg"].split(" ") sender = obj.data["sender"] if len(msg) == 1: A.tell(sender, "Usage: !nuke <user> <count>") else: if msg[1].isdigit(): nuke = int(msg[1]) else: cli = A.findClient(msg[1]) if cli != None: nuke = cli.uid count = 1 if len(msg) == 3: if canInt(msg[2]): count = int(msg[2]) for i in range(count): A.rcon('nuke %d' % nuke) time.sleep(.8)
def cmdSlap(obj, t): msg = obj.data["msg"].split(" ") sender = obj.data["sender"] if len(msg) == 1: A.tell(sender, "Usage: !slap <user> <count>") else: if msg[1].isdigit(): slap = int(msg[1]) else: cli = A.findClient(msg[1]) if cli != None: slap = cli.uid else: return None count = 1 if len(msg) == 3: if canInt(msg[2]): count = int(msg[2]) for i in range(count): A.rcon('slap %d' % slap) time.sleep(.8)
def cmdForce(obj, t): msg = obj.data['msgsplit'] sender = obj.data['sender'] #The sender id team = msg[2] #Team to switch player to playobj = A.findClient(msg[1]) #Player obj if A.canInt(team): team = const.teams[int(team)] #Is the team an integer representation of a team? if so use the team name if team not in const.teams.values() and team != 'spectator': #we are a bad team! return A.tell(sender, 'Unknown team %s (spec/spectator/red/blue)' % team) if team == 'spec': team == 'spectator' #urt likes spectator if len(msg) == 3 and playobj.team != team: #!force player team A.rcon('forceteam %s %s' % (playobj.uid, team)) A.tell(sender, '%s was forced to %s.' % (playobj.name, team)) elif len(msg) == 4 and msg[3] == 'lock': #!force player team lock A.rcon('forceteam %s %s' % (playobj.uid, team)) playobj.fairplay_locked = True playobj.fairplay_lockedteam = team A.tell(sender, '%s was forced and locked to %s. Type !unlock %s to unlock player.' % (playobj.name, team, playobj.name)) else: A.tell(sender, "Usage: !force <client> <team> [lock]")
def cmdSet(obj, t): msg = obj.data["msg"].split(" ") sender = obj.data["sender"] if len(msg) == 1: A.tell(sender, "Usage: !set <cvar> <value>") elif len(msg) == 2: A.rcon('set %s %s' % (msg[1], msg[2]))
def eveLock(obj, t): cobj = A.getClient(obj.client) if 'fairplay_locked' in cobj.__dict__.keys(): if cobj.fairplay_locked is True: A.rcon('forceteam %s %s' % (cobj.uid, cobj.fairplay_lockedteam))