def sendShamanItems(this): p = ByteArray() shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split( ",") p.writeShort(len(shamanItems)) for item in shamanItems: if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if len(itemSplited) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") p.writeShort(int(realItem)).writeBool( item in this.client.shamanLook.split(",")).writeByte( len(realCustom) + 1) x = 0 while x < len(realCustom): p.writeInt(int(realCustom[x], 16)) x += 1 else: p.writeShort(int(item)).writeBool( item in this.client.shamanLook.split(",")).writeByte(0) this.client.sendPacket(Identifiers.send.Shaman_Items, p.toByteArray())
def sendLookChange(self): try: p = ByteArray() look = self.client.playerLook.split(";") p.writeByte(int(look[0])) for item in look[1].split(","): if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if len(itemSplited) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") p.writeInt(int(realItem)).writeByte(len(realCustom)) x = 0 while x < len(realCustom): p.writeInt(int(realCustom[x], 16)) x += 1 else: p.writeInt(int(item)).writeByte(0) p.writeInt(int(self.client.mouseColor, 16)) self.client.sendPacket(Identifiers.send.Look_Change, p.toByteArray()) except: pass
def parsePacket(this, packet): code = packet.readShort() if code == 1: referidor, ip1, ip2, playerName = packet.readUTF(), packet.readUTF( ), packet.readUTF(), packet.readUTF() client = this.server.players.get(playerName) if client != None: print "[" + playerName + "]", referidor, ip1, ip2 if client.nivel < 3: client.referidor = referidor client.fresasreferidos(referidor, ip1 != ip2) if ip1 == ip2: packet = ByteArray().writeBoolean( client.nivel < 3).writeUTF(client.playerName).writeUTF( client.ipAddress).writeUTF(this.server.serverID) this.sendPacket(2, packet.toByteArray()) elif code == 2: keep = packet.readBoolean() cantidad = packet.readInt() if not keep: this.server.blackList = [] for x in range(cantidad): site = packet.readUTF() this.server.blackList.append(site) this.server.log("[Frodo] Backlist: " + str(len(this.server.blackList)) + " Sitios") elif code == 3: keep = packet.readBoolean() cantidad = packet.readInt() if not keep: this.server.whiteList = [] for x in range(cantidad): site = packet.readUTF() this.server.whiteList.append(site) this.server.log("[Frodo] WhiteList: " + str(len(this.server.whiteList)) + " Sitios")
def sendLookChange(this): packet = ByteArray() skinID, clothes = this.client.playerLook.split(";") clothes = clothes.split(",") packet.writeByte(int(skinID)) for item in clothes: if "_" in item: itemID, custom = item.split("_") custom = custom.split("+") if custom else [] packet.writeInt(int(itemID)) packet.writeByte(len(custom)) x = 0 while x < len(custom): packet.writeInt(int(custom[x], 16)) x += 1 else: packet.writeInt(int(item)).writeByte(0) packet.writeInt(int(this.client.MouseColor, 16)) this.client.sendPacket(Identifiers.send.Look_Change, packet.toByteArray(), True)
def sendLookChange(this): kostum, giysiler = this.client.playerLook.split(";") giysiler = giysiler.split(',') giysiler.append('0') packet = ByteArray().writeByte(int(kostum)) for item in giysiler: if "_" in item: custom = item.split("_")[1] if len( item.split("_")) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") packet.writeInt(int(item.split("_")[0])).writeByte( len(realCustom)) x = 0 while x < len(realCustom): packet.writeInt( int(realCustom[x], 16) if realCustom[x].isdigit( ) else int("FADE55", 16)) x += 1 else: packet.writeInt(int(item)).writeByte(0) try: packet.writeInt(int(this.client.mouseColor, 16)) except: packet.writeInt(int("78583A", 16)) this.client.sendPacket(Identifiers.send.Look_Change, packet.toByteArray())
def loadCafeMode(self): can = not self.client.isGuest if not can: self.client.sendLangueMessage( "", "<ROSE>$PasAutoriseParlerSurServeur") self.client.sendPacket(Identifiers.send.Open_Cafe, ByteArray().writeBoolean(can).toByteArray()) packet = ByteArray() konular = self.server.cafeTopics if len(konular) > 0: # for i,v in self.server.cafeTopics.items(): for i, v in sorted(konular.items(), key=lambda x: x[1]["Tarih"], reverse=True): if v["Dil"] == self.client.langue: konuid, baslik, sahip, yorumlar, sonyazan, tarih = v[ "KonuID"], v["Baslik"], v["Sahip"], v["Yorumlar"], v[ "SonYazan"], v["Tarih"] packet.writeInt(konuid).writeUTF(baslik).writeInt( self.server.getPlayerID(sahip)).writeInt( yorumlar).writeUTF(sonyazan).writeInt( Utils.getSecondsDiff(tarih)) self.client.sendPacket(Identifiers.send.Cafe_Topics_List, packet.toByteArray())
def openCafeTopic(self, topicID): if self.server.cafeTopics.has_key(topicID): packet = ByteArray().writeBoolean(True).writeInt(topicID) for id,v in self.server.cafePosts[topicID].items(): yorumid,yorumyazan,yorumtarih,mesaj,puan,verenler = v["YorumID"],v["YorumYazan"],v["YorumTarih"],v["YorumMesaj"],v["Puan"],v["OyVerenler"] packet.writeInt(yorumid).writeInt(self.server.getPlayerID(yorumyazan)).writeInt(Utils.getSecondsDiff(yorumtarih)).writeUTF(yorumyazan).writeUTF(mesaj).writeBoolean(str(self.client.playerID) not in verenler).writeShort(puan) self.client.sendPacket(Identifiers.send.Open_Cafe_Topic, packet.toByteArray())
def openChatLog(this, playerName): p = ByteArray().writeUTF(playerName).writeByte(len(this.server.chatMessages[playerName]) * 2 if this.server.chatMessages.has_key(playerName) else 0) if this.server.chatMessages.has_key(playerName): for message in this.server.chatMessages[playerName]: p.writeUTF(message[0]).writeUTF(message[1]) this.client.sendPacket(Identifiers.send.Modopwet_Chatlog, p.toByteArray(), True)
def sendShamanSkills(self, refresh): packet = ByteArray().writeByte(len(self.client.playerSkills)) for skill in self.client.playerSkills.items(): packet.writeByte(skill[0]).writeByte(skill[1]) packet.writeBoolean(refresh) self.client.sendPacket(Identifiers.send.Shaman_Skills, packet.toByteArray())
def openChatLog(self, playerName): if self.server.chatMessages.has_key(playerName): packet = ByteArray().writeUTF(playerName).writeByte( len(self.server.chatMessages[playerName])) for message in self.server.chatMessages[playerName]: packet.writeUTF(message[1]).writeUTF(message[0]) self.client.sendPacket(Identifiers.send.Modopwet_Chatlog, packet.toByteArray())
def loadCafeMode(this): can = this.client.privLevel >= 5 or (this.client.privLevel != 0 and this.client.cheeseCount >= 4000) if not can: this.client.sendMessage("<ROSE>Kafede konuşabilmek için 10 kez deliğe peynir götürmelisin.") #this.client.sendLangueMessage("", "<ROSE>$PasAutoriseParlerSurServeur") this.client.sendPacket(Identifiers.send.Open_Cafe, ByteArray().writeBoolean(can).toByteArray()) packet = ByteArray() this.CursorCafe.execute("select * from CafeTopics where Langue = ? order by Date desc limit 0, 20", [this.client.langue]) for rs in this.CursorCafe.fetchall(): packet.writeInt(rs["TopicID"]).writeUTF(rs["Title"]).writeInt(this.server.getPlayerID(rs["Author"])).writeInt(rs["Posts"]).writeUTF(rs["LastPostName"]).writeInt(Utils.getSecondsDiff(rs["Date"])) this.client.sendPacket(Identifiers.send.Cafe_Topics_List, packet.toByteArray())
def sendShamanLook(this): items = ByteArray() count = 0 for item in this.client.shamanLook.split(","): realItem = int(item.split("_")[0]) if "_" in item else int(item) if realItem != 0: items.writeShort(realItem) count += 1 this.client.sendPacket( Identifiers.send.Shaman_Look, ByteArray().writeShort(count).writeBytes( items.toByteArray()).toByteArray())
def getShamanItemCustom(this, code): item = this.client.shamanItems.split(",") if "_" in item: itemSplited = item.split("_") custom = (itemSplited[1] if len(itemSplited) >= 2 else "").split("+") if int(itemSplited[0]) == code: packet = ByteArray().writeByte(len(custom)) x = 0 while x < len(custom): packet.writeInt(int(custom[x], 16)) x += 1 return packet.toByteArray() return chr(0)
def openCafeTopic(this, topicID): packet = ByteArray().writeBoolean(True).writeInt(topicID) this.CursorCafe.execute( "select * from CafePosts where TopicID = ? order by PostID asc", [topicID]) for rs in this.CursorCafe.fetchall(): packet.writeInt(rs["PostID"]).writeInt( this.server.getplayerAvatar(rs["Name"])).writeInt( Utils.getSecondsDiff(rs["Date"])).writeUTF( rs["Name"]).writeUTF(rs["Post"]).writeBoolean( str(this.client.playerCode) not in rs["Votes"].split(",")).writeShort(rs["Points"]) this.client.sendPacket(Identifiers.send.Open_Cafe_Topic, packet.toByteArray())
def getShamanItemCustomization(this, code): items = this.client.shamanItems.split(",") for item in items: if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if len(itemSplited) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") if code == int(realItem): packet = ByteArray().writeByte(len(realCustom)) x = 0 while x < len(realCustom): packet.writeInt(int(realCustom[x], 16)) x += 1 return packet.toByteArray() return chr(0)
def sendShamanItems(self): shamanItems = [] if self.client.shamanItems == "" else self.client.shamanItems.split( ",") packet = ByteArray().writeShort(len(shamanItems)) for item in shamanItems: if "_" in item: custom = item.split("_")[1] if len( item.split("_")) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") packet.writeShort(int(item.split("_")[0])).writeBoolean( item in self.client.shamanLook.split(",")).writeByte( len(realCustom) + 1) x = 0 while x < len(realCustom): packet.writeInt(int(realCustom[x], 16)) x += 1 else: packet.writeShort(int(item)).writeBoolean( item in self.client.shamanLook.split(",")).writeByte(0) self.client.sendPacket(Identifiers.send.Shaman_Items, packet.toByteArray())
def sendShopList(this, sendItems=True): shopItems = [] if this.client.shopItems == "" else this.client.shopItems.split( ",") packet = ByteArray().writeInt(this.client.shopCheeses).writeInt( this.client.shopFraises).writeUTF(this.client.playerLook).writeInt( len(shopItems)) for item in shopItems: if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if len(itemSplited) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") packet.writeByte(len(realCustom) + 1).writeInt(int(realItem)) x = 0 while x < len(realCustom): packet.writeInt(int(realCustom[x], 16)) x += 1 else: packet.writeByte(0).writeInt(int(item)) shop = this.server.shopList if sendItems else [] packet.writeInt(len(shop)) for item in shop: value = item.split(",") packet.writeShort(value[0]).writeShort(value[1]).writeByte( value[2]).writeByte(value[3]).writeByte(value[4]).writeInt( value[5]).writeInt(value[6]).writeShort(0) visuais = this.server.newVisuList packet.writeByte(len(visuais)) i = len(visuais) visu = [] for visual in visuais.items(): visu.append(visual[1]) if visual[1] in visu: visu.remove(visual[1]) packet.writeShort(visual[0]) a = visual[1] packet.writeUTF(''.join(a)) packet.writeByte(2 if visual[0] in [52] else 1 if visual[0] in [53] else 2) i -= 1 packet.writeShort(len(this.client.clothes)) for clothes in this.client.clothes: clotheSplited = clothes.split("/") packet.writeUTF(clotheSplited[1] + ";" + clotheSplited[2] + ";" + clotheSplited[3]) shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split( ",") packet.writeShort(len(shamanItems)) for item in shamanItems: if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if (len(itemSplited) >= 2) else "" realCustom = [] if custom == "" else custom.split("+") packet.writeShort(int(realItem)).writeBoolean( item in this.client.shamanLook.split(",")).writeByte( len(realCustom) + 1) x = 0 while x < len(realCustom): packet.writeInt(int(realCustom[x], 16)) x += 1 else: packet.writeShort(int(item)).writeBoolean( item in this.client.shamanLook.split(",")).writeByte(0) shamanShop = this.server.shamanShopList if sendItems else [] packet.writeShort(len(shamanShop)) for item in shamanShop: value = item.split(",") packet.writeInt(value[0]).writeByte(value[1]).writeByte( value[2]).writeByte(value[3]).writeInt(value[4]).writeShort( value[5]) this.client.sendPacket(Identifiers.send.Shop_List, packet.toByteArray())
def openModoPwet(self, isOpen=False, modopwetOnlyPlayerReports=False, sortBy=False): if isOpen: if len(self.server.reports) <= 0: self.client.sendPacket(Identifiers.send.Modopwet_Open, 0) else: self.client.sendPacket(Identifiers.send.Modopwet_Open, 0) reports, bannedList, deletedList, disconnectList = self.sortReports( self.server.reports, sortBy), {}, {}, [] sayi = 0 p = ByteArray() for i in reports: isim = i[0] v = self.server.reports[isim] if self.client.modoPwetLangue == 'ALL' or v[ "dil"] == self.client.modoPwetLangue: oyuncu = self.server.players.get(isim) saat = math.floor(oyuncu.playerTime / 3600) if oyuncu else 0 odaisim = oyuncu.roomName if oyuncu else "0" sayi += 1 self.client.lastReportID += 1 if sayi >= 255: break p.writeByte(sayi) p.writeShort(self.client.lastReportID) p.writeUTF(v["dil"]) p.writeUTF(isim) p.writeUTF(odaisim) p.writeByte(1) # alttaki modname uzunlugu ile alakali p.writeUTF(self.getRoomMods(odaisim)) p.writeInt(saat) #idk p.writeByte(int(len(v["reporters"]))) for name in v["reporters"]: r = v["reporters"][name] p.writeUTF(name) p.writeShort(self.getPlayerKarma(name)) #karma p.writeUTF(r[1]) p.writeByte(r[0]) p.writeShort(int(Utils.getSecondsDiff(r[2]) / 60)) #05m felan rep suresi mute = v["isMuted"] p.writeBoolean(mute) #isMute if mute: p.writeUTF(v["mutedBy"]) p.writeShort(v["muteHours"]) p.writeUTF(v["muteReason"]) if v['durum'] == 'banned': x = {} x['banhours'] = v['banhours'] x['banreason'] = v['banreason'] x['bannedby'] = v['bannedby'] bannedList[isim] = x if v['durum'] == 'deleted': x = {} x['deletedby'] = v['deletedby'] deletedList[isim] = x if v['durum'] == 'disconnected': disconnectList.append(isim) self.client.sendPacket( Identifiers.send.Modopwet_Open, ByteArray().writeByte(int(len(reports))).writeBytes( p.toByteArray()).toByteArray()) for user in disconnectList: self.changeReportStatusDisconnect(user) for user in deletedList.keys(): self.changeReportStatusDeleted( user, deletedList[user]['deletedby']) for user in bannedList.keys(): self.changeReportStatusBanned( user, bannedList[user]['banhours'], bannedList[user]['banreason'], bannedList[user]['bannedby'])
def sendShamanSkills(this): p = ByteArray().writeByte(len(this.client.playerSkills)) for skill in this.client.playerSkills.items(): p.writeByte(skill[0]).writeByte(skill[1]) p.writeBool(this.client.isSkill) this.client.sendPacket(Identifiers.send.Shaman_Skills, p.toByteArray())
def openModoPwet(this): if len(this.server.reports["names"]) <= 0: this.client.sendPacket(Identifiers.send.Modopwet_Open, 0) else: reports, reporters, count, bannedList, deletedList, disconnectList = 0, 0, 0, {}, {}, [] totalReports = len(this.server.reports["names"]) packet = ByteArray() while reports < totalReports: playerName = this.server.reports["names"][reports] totalReporters = len(this.server.reports[playerName]["types"]) reports += 1 if this.client.modoPwetLangue == "ALL" or this.server.reports[ playerName][ "langue"] == this.client.modoPwetLangue.upper(): count += 1 if count >= 255: break packet.writeUnsignedByte(count).writeUTF( this.server.reports[playerName] ["langue"].upper()).writeUTF(playerName).writeUTF( this.getPlayerRoomName(playerName)).writeInt( this.getProfileCheeseCount(playerName)) packet.writeUnsignedByte(totalReporters) while reporters < totalReporters: packet.writeUTF( this.server.reports[playerName]["reporters"] [reporters]).writeShort( this.getProfileCheeseCount( this.server.reports[playerName] ["reporters"][reporters]) ).writeUTF( this.server.reports[playerName]["comments"] [reporters]).writeUnsignedByte( this.server.reports[playerName]["types"] [reporters]).writeShort(reporters) reporters += 1 if this.server.reports[playerName]["status"] == "banned": x = {} x["banhours"] = this.server.reports[playerName][ "banhours"] x["banreason"] = this.server.reports[playerName][ "banreason"] x["bannedby"] = this.server.reports[playerName][ "bannedby"] bannedList[playerName] = x if this.server.reports[playerName]["status"] == "deleted": x = {} x["deletedby"] = this.server.reports[playerName][ "deletedby"] deletedList[playerName] = x if this.server.reports[playerName][ "status"] == "disconnected": disconnectList.append(playerName) this.client.sendPacket( Identifiers.send.Modopwet_Open, ByteArray().writeUnsignedByte(count).writeBytes( packet.toByteArray()).toByteArray()) for user in disconnectList: this.changeReportStatusDisconnect(user) for user in deletedList.keys(): this.changeReportStatusDeleted(user, deletedList[user]["deletedby"]) for user in bannedList.keys(): this.changeReportStatusBanned(user, bannedList[user]["banhours"], bannedList[user]["banreason"], bannedList[user]["bannedby"])
def checkReferido(this, client): packet = ByteArray().writeUTF(client.playerName).writeUTF( client.ipAddress).writeUTF(this.server.serverID) this.sendPacket(1, packet.toByteArray())
def sendShopList(this, sendItems=True): shopItems = [] if this.client.shopItems == "" else this.client.shopItems.split( ",") packet = ByteArray().writeInt(this.client.shopCheeses).writeInt( this.client.shopFraises).writeUTF(this.client.playerLook).writeInt( len(shopItems)) for item in shopItems: if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if len(itemSplited) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") packet.writeByte(len(realCustom) + 1).writeInt(int(realItem)) x = 0 while x < len(realCustom): packet.writeInt(int(realCustom[x], 16)) x += 1 else: packet.writeByte(0).writeInt(int(item)) shop = this.server.shopList if sendItems else [] packet.writeInt(len(shop)) for item in shop: value = item.split(",") packet.writeShort(int(value[0])).writeShort(int( value[1])).writeByte(int(value[2])).writeByte( int(value[3])).writeByte(int(value[4])).writeInt( int(value[5])).writeInt(int(value[6])).writeShort(0) looks = [] packet.writeByte(len(looks)) for look in looks: packet.writeShort(look[0]) packet.writeUTF(look[1]) packet.writeByte(look[2]) packet.writeShort(len(this.client.clothes)) for clothe in this.client.clothes: clotheSplited = clothe.split("/") packet.writeUTF(clotheSplited[1] + ";" + clotheSplited[2] + ";" + clotheSplited[3]) shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split( ",") packet.writeShort(len(shamanItems)) for item in shamanItems: if "_" in item: itemSplited = item.split("_") realItem = itemSplited[0] custom = itemSplited[1] if len(itemSplited) >= 2 else "" realCustom = [] if custom == "" else custom.split("+") packet.writeShort(int(realItem)) packet.writeBoolean(item in this.client.shamanLook.split( ",")).writeByte(len(realCustom) + 1) x = 0 while x < len(realCustom): packet.writeInt(int(realCustom[x], 16)) x += 1 else: packet.writeShort(int(item)).writeBoolean( item in this.client.shamanLook.split(",")).writeByte(0) shamanShop = this.server.shamanShopList if sendItems else [] packet.writeShort(len(shamanShop)) for item in shamanShop: value = item.split(",") packet.writeInt(int(value[0])).writeByte(int(value[1])).writeByte( int(value[2])).writeByte(int(value[3])).writeInt(int( value[4])).writeShort(int(value[5])) this.client.sendPacket(Identifiers.send.Shop_List, packet.toByteArray())
def openModoPwet(this): if len(this.server.reports["names"]) <= 0: this.client.sendPacket(Identifiers.send.Open_Modopwet, chr(0), True) else: reports = 0 totalReports = len(this.server.reports["names"]) count = 0 bannedList = {} deletedList = {} disconnectList = [] p = ByteArray() while reports < totalReports: playerName = this.server.reports["names"][reports] reports += 1 if this.client.modoPwetLangue == "all" or this.server.reports[playerName]["langue"] == this.client.modoPwetLangue.upper(): count += 1 if count > 255: break p.writeByte(count).writeUTF(this.server.reports[playerName]["langue"].upper()).writeUTF(playerName).writeUTF(this.getPlayerRoomName(playerName)).writeInt(this.getProfileCheeseCount(playerName)) reporters = 0 totalReporters = len(this.server.reports[playerName]["types"]) p.writeByte(totalReporters) while reporters < totalReporters: p.writeUTF(this.server.reports[playerName]["reporters"][reporters]).writeShort(this.getProfileCheeseCount(this.server.reports[playerName]["reporters"][reporters])).writeUTF(this.server.reports[playerName]["comments"][reporters]).writeByte(this.server.reports[playerName]["types"][reporters]).writeShort(reporters) reporters += 1 if this.server.reports[playerName]["status"] == "banned": x = {} x["banhours"] = this.server.reports[playerName]["banhours"] x["banreason"] = this.server.reports[playerName]["banreason"] x["bannedby"] = this.server.reports[playerName]["bannedby"] bannedList[playerName] = x if this.server.reports[playerName]["status"] == "deleted": x = {} x["deletedby"] = this.server.reports[playerName]["deletedby"] deletedList[playerName] = x if this.server.reports[playerName]["status"] == "disconnected": disconnectList.append(playerName) this.client.sendPacket(Identifiers.send.Open_Modopwet, ByteArray().writeByte(count).writeBytes(p.toByteArray()).toByteArray(), True)