def login(script, id, password): if not id or not password: return '[INFO] Use /login <ID> <Password> when you are already registered else use /register <Password> <Password Repeating> to register in order to get your own unique numeric ID.' try: id = int(id) except Exception: return '[ERROR] Invalid ID given.' dbres = database.login_player(script.server.db_con, script.connection.name, id, password) if dbres: script.connection.login_id = id database.update_player(script.server.db_con, id, script.connection.name) if not dbres.rank is None: script.connection.rights.update(dbres.rank) return '[LOGIN] Successfully logged in as %s %s. Your last login name was %s with IP %s.' % (dbres.rank.upper(), script.connection.name, dbres.ingame_name, dbres.last_ip) return '[LOGIN] Successfully logged in as %s. Your last login name was %s with IP %s.' % (script.connection.name, dbres.ingame_name, dbres.last_ip) else: return '[ERROR] To many arguments!' return '[ERROR] Login failed.'
def login(script, id, password): if not id or not password: return '[INFO] Use /login <ID> <Password> when you are already registered else use /register <Password> <Password Repeating> to register in order to get your own unique numeric ID.' try: id = int(id) except Exception: return '[ERROR] Invalid ID given.' dbres = database.login_player(script.server.db_con, id, password) if dbres: script.connection.login_id = id database.update_player(script.server.db_con, id, script.connection.name) if not dbres[1] is None: script.connection.rank = dbres[1].lower() user_types = script.server.ranks.get(script.connection.rank, []) script.connection.rights.update(user_types) return '[LOGIN] Successfully logged in as %s %s. Your last login name was %s with IP %s.' % (script.connection.rank, script.connection.name, dbres[0], dbres[2]) return '[LOGIN] Successfully logged in as %s. Your last login name was %s with IP %s.' % (script.connection.name, dbres[0], dbres[2]) else: return '[ERROR] Got no database result!' return '[ERROR] Login failed.'