def writechat(inst, whos, msg, tstamp): isindb = False if whos != "ALERT": isindb = dbquery("SELECT * from players WHERE playername = '%s'" % (whos, ), fetch="one") if isindb: dbupdate( """INSERT INTO chatbuffer (server,name,message,timestamp) VALUES ('%s', '%s', '%s', '%s')""" % (inst, whos, msg.replace("'", ""), tstamp)) elif whos == "ALERT": dbupdate( "INSERT INTO chatbuffer (server,name,message,timestamp) VALUES ('%s', '%s', '%s', '%s')" % (inst, whos, msg, tstamp))
def banunbanplayer(steamid, ban=False): if ban: try: dbupdate("UPDATE players SET banned = True WHERE steamid = '%s'" % (steamid, )) dbupdate( "DELETE FROM messages WHERE from_player = '%s' or to_player = '%s'" % (steamid, steamid)) dbupdate( "UPDATE web_users SET active = False WHERE steamid = '%s'" % (steamid, )) except: return False return True else: try: dbupdate("UPDATE players SET banned = NULL WHERE steamid = '%s'" % (steamid, )) dbupdate( "UPDATE web_users SET active = True WHERE steamid = '%s'" % (steamid, )) except: return False return True
def kickplayer(instance, steamid): dbupdate("INSERT INTO kicklist (instance,steamid) VALUES ('%s','%s')" % (instance, steamid))