def setrank(script, id, rank): if not id or not rank: return '[INFO] Use /setrank <ID> <Rank> to set the rank of user with the given id.' rank = rank.lower() if rank not in script.server.ranks: return '[ERROR] Invalid rank!' ret = database.set_player_rank(script.server.db_con, id, rank) if ret is True: user_types = script.server.ranks.get(rank, []) for player in script.server.players.values(): if (player.login_id is not None) and (player.login_id == id): player.rights.update(user_types) print '[INFO] Rights of %s updated.' % player.name return '[SUCCESS] Rank of player with id %s set to %s' % (id, rank) return '[RANK] Could not set rank!'
def setrank(script, name, rank): if not name or not rank: return '[INFO] Use /setrank <Name> <Rank> to set the rank of user with the given name.' player = script.get_player(name) if not player: return '[ERROR] Player %s not found.' % name if not player.login_id: return '[ERROR] Player %s is not logged in!' % name if not (rank in script.server.ranks): script.connection.send_chat('[WARNING] Unknown rank: %s' % rank) ret = database.set_player_rank(script.server.db_con, player.login_id, rank) if ret is True: script.connection.rights.update(rank) player.send_chat('[INFO] You are now %s' % rank.upper()) return '[SUCCESS] Rank of %s set to %s' % (name, rank) return '[RANK] Could not set rank!'