Advertisement
FelipeFooox

Untitled

Mar 17th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 191.55 KB | None | 0 0
  1. #coding: utf-8
  2. import os, sys, ConfigParser, random, traceback, time, smtplib, sqlite3
  3.  
  4. Config = ConfigParser.ConfigParser()
  5. Config.read("./Sukelac1/Ayarlar.ini")
  6.  
  7. if bool(int(Config.get("Game", "CompileFiles", 0))) == False:
  8. sys.dont_write_bytecode = True
  9.  
  10. # Modules
  11. from SukePY import *
  12. import logging
  13. # Utils
  14. from utils import *
  15. # Library
  16. from datetime import datetime
  17. from email.mime.text import MIMEText
  18. from twisted.internet import reactor, protocol
  19. try:
  20. Database, Cursor = None, None
  21. Database = sqlite3.connect("./veritabani/Sukelac1.db", check_same_thread = False)
  22. Database.text_factory = str
  23. Database.isolation_level = None
  24. Database.row_factory = sqlite3.Row
  25. Cursor = Database.cursor()
  26. except sqlite3.Error, e:
  27. print "Warning: Failure to connect SQLite Database.\nERROR SQLite: %s." % (e.args[0])
  28. raw_input("Pressione ENTER para fechar.\n")
  29. os._exit(0)
  30.  
  31. class Client(ClientHandler):
  32. def __init__(this):
  33.  
  34. # Roleta
  35. this.TimeGiro = 0
  36.  
  37. # String
  38. this.Username = ""
  39. this.Langue = ""
  40. this.realLangue = ""
  41. this.MouseColor = "78583a"
  42. this.ShamanColor = "95d9d6"
  43. this.roomName = ""
  44. this.shopItems = ""
  45. this.shamanItems = ""
  46. this.playerLook = "1;0,0,0,0,0,0,0,0,0"
  47. this.shamanLook = "0,0,0,0,0,0,0,0,0,0"
  48. this.lastMessage = ""
  49. this.modoPwetLangue = "all"
  50. this.silenceMessage = ""
  51. this.marriage = ""
  52. this.tribeName = ""
  53. this.emailAddress = ""
  54. this.tempEmailAddress = ""
  55. this.lastEmailCode = ""
  56. this.currentMusicName = ""
  57. this.tradeName = ""
  58. this.mouseName = ""
  59. this.captcha = ""
  60.  
  61. # Integer
  62. this.lastPacketID = random.randint(0, 99)
  63. this.langueByte = 0
  64. this.playerScore = 0
  65. this.playerCode = 0
  66. this.privLevel = 0
  67. this.playerID = 0
  68. this.TitleNumber = 0
  69. this.TitleStars = 0
  70. this.posX = 0
  71. this.posY = 0
  72. this.playerX = 0
  73. this.playerY = 0
  74. this.velX = 0
  75. this.velY = 0
  76. this.firstCount = 0
  77. this.cheeseCount = 0
  78. this.shamanCheeses = 0
  79. this.shopCheeses = 0
  80. this.shopFraises = 0
  81. this.shamanSaves = 0
  82. this.hardModeSaves = 0
  83. this.divineModeSaves = 0
  84. this.bootcampCount = 0
  85. this.shamanType = 0
  86. this.regDate = 0
  87. this.banHours = 0
  88. this.shamanLevel = 320
  89. this.shamanExp = 0
  90. this.shamanExpNext = 32
  91. this.ambulanceCount = 0
  92. this.bubblesCount = 0
  93. this.lastOn = 0
  94. this.silenceType = 0
  95. this.gender = 0
  96. this.lastDivorceTimer = 0
  97. this.tribeCode = 0
  98. this.tribeRank = 0
  99. this.tribeJoined = 0
  100. this.tribePoints = 0
  101. this.defilantePoints = 0
  102. this.lastGameMode = 0
  103. this.currentPlace = 0
  104. this.pet = 2340
  105. this.petEnd = 0
  106. this.iceCoins = 0
  107. this.iceTokens = 0
  108. this.shamanSymbol = 0
  109. this.equipedShamanSymbol = 0
  110. this.numGiveCheese = 0
  111. this.avatar = 0
  112.  
  113. # Bool
  114. this.isClosed = False
  115. this.validatingVersion = True
  116. this.isGuest = False
  117. this.isDead = False
  118. this.hasCheese = False
  119. this.hasEnter = False
  120. this.isSync = False
  121. this.isMovingRight = False
  122. this.isMovingLeft = False
  123. this.isJumping = False
  124. this.isShaman = False
  125. this.isAfk = False
  126. this.isVoted = False
  127. this.qualifiedVoted = False
  128. this.modMute = False
  129. this.RTotem = False
  130. this.UTotem = False
  131. this.LoadCountTotem = False
  132. this.modoPwet = False
  133. this.canResSkill = False
  134. this.canShamanRespawn = False
  135. this.isOpportunist = False
  136. this.desintegration = False
  137. this.canMeep = False
  138. this.sendMusic = True
  139. this.sendRank = True
  140. this.isCafe = False
  141. this.canSkipMusic = False
  142. this.isHidden = False
  143. this.isTeleport = False
  144. this.isFly = False
  145. this.isSpeed = False
  146. this.isNewPlayer = False
  147. this.isVampire = False
  148. this.showButtons = True
  149. this.isLuaAdmin = False
  150. this.isSuspect = False
  151. this.isTrade = False
  152. this.tradeConfirm = False
  153. this.canUseConsumable = True
  154. this.runLuaAsBot = False
  155. this.showMusicPlayer = True
  156. this.isPlayingMusic = False
  157. this.isBot = False
  158. this.showMusicPlayer = True
  159.  
  160. # Others
  161. this.Cursor = Cursor
  162. this.TFMUtils = TFMUtils
  163.  
  164. # Nonetype
  165. this.room = None
  166. this.awakeTimer = None
  167. this.resSkillsTimer = None
  168. this.skipMusicTimer = None
  169. this.playMusicTimer = None
  170. this.consumablesTimer = None
  171.  
  172. # List Arguments
  173. this.STotem = [0, ""]
  174. this.Totem = [0, ""]
  175. this.survivorStats = [0, 0, 0, 0]
  176. this.racingStats = [0, 0, 0, 0]
  177. this.marriageInivite = []
  178. this.tribeData = ["", "", 0, None]
  179. this.tribeInvite = []
  180. this.mulodromePos = []
  181. this.canLogin = [False, False]
  182. this.AntiBots = [0, False, 0, 0]
  183.  
  184. # List
  185. this.cheeseTitleList = []
  186. this.firstTitleList = []
  187. this.shamanTitleList = []
  188. this.shopTitleList = []
  189. this.bootcampTitleList = []
  190. this.hardModeTitleList = []
  191. this.divineModeTitleList = []
  192. this.specialTitleList = []
  193. this.titleList = []
  194. this.clothes = []
  195. this.shopBadges = []
  196. this.shopNatal = []
  197. this.friendsList = []
  198. this.ignoredsList = []
  199. this.ignoredMarriageInvites = []
  200. this.ignoredTribeInvites = []
  201. this.chats = []
  202. this.voteBan = []
  203. this.equipedConsumables = []
  204. this.consumablesShop = []
  205.  
  206. # Dict
  207. this.playerSkills = {}
  208. this.playerConsumables = {31:10, 34:10, 2240:10, 2247:10, 2262:10, 2332:10, 2340:10, 5:10, 6:10, 8:10, 25:10, 26:10, 11:10, 10:10, 15:10, 24:10, 28:10, 29:10, 30:10, 2241:10, 2330:10, 2:10, 3:10, 16:10, 23:10, 14:10, 21:10, 2232:10, 2255:10, 2346:10}
  209. this.tradeConsumables = {}
  210.  
  211. def sendRoleta(this):
  212. if this.iceTokens >=10:
  213. tam = 80
  214. else:
  215. tam = 70
  216. this.sendRemovePoup(63)
  217. roleta= '<img src="http://i.imgur.com/B7uOtRY.png">'
  218. girar = '<a href="event:girar"><V><b>Dönüş</b></a>'
  219. op = '<a href="event:fechar"><font color="#FA5858">x</font></a>'
  220. fichas = '<N>Merhaba, Şuanda Sahip Oldugun <ROSE>'+str(this.iceTokens)+' <N>Madeni Para'
  221. this.sendAddPopupText(10050, 220, 15, 300, 370, '000000', '000000', 90, roleta)
  222. this.sendAddPopupText(10051, 358, 237, 80, 50, '000000', '000000', 90, girar)
  223. this.sendAddPopupText(10052, 242, 62, 317, 17, '000000', '000000', 90, op)
  224. this.sendAddPopupText(10053, 260, 85, 220, 40, '000000', '000000', 90, fichas)
  225.  
  226. def sendGetTimeRoletaOn(this):
  227. this.TimeGiro = 0
  228.  
  229. def sendGetTimeRoleta(this):
  230. if this.TimeGiro == 0:
  231. this.TimeGiro = 1
  232. reactor.callLater(3, this.sendSorteioRoleta)
  233. else:
  234. this.sendMessage("<N>[Info] <J>Çark dönüyor...")
  235.  
  236. def sendSorteioRoleta(this):
  237. if this.TimeGiro == 1:
  238. lista = ["queijos", "fraises", "queijos", "moedas", "fraises", "cheeses", "queijos", "bootcamps", "firsts", "moedas", "fichas", "fraises", "queijos", "fraises", "queijos", "cheeses"]
  239. rkey = str(random.choice(lista))
  240.  
  241. this.sendRemovePoup(62)
  242.  
  243. this.iceTokens -= 1
  244. this.Cursor.execute('UPDATE Users SET IceTokens = ? WHERE Username = ?', [this.iceTokens, this.Username])
  245. this.Cursor.fetchone()
  246.  
  247. if rkey == "firsts":
  248. listaQuant = ["10", "10", "15", "15", "20", "20", "20", "30"]
  249. elif rkey == "queijos":
  250. listaQuant = ["10", "10", "15", "15", "20", "20", "20", "30"]
  251. elif rkey == "cheeses":
  252. listaQuant = ["10", "50", "100", "150", "300", "500", "1000", "1500"]
  253. elif rkey == "fraises":
  254. listaQuant = ["10", "50", "100", "150", "300", "500", "1000", "1500"]
  255. elif rkey == "bootcamps":
  256. listaQuant = ["10", "10", "15", "15", "20", "20", "20", "30"]
  257. elif rkey == "moedas":
  258. listaQuant = ["10", "20", "10", "5", "10", "7", "30", "40", "50", "100", "2", "5", "10", "15", "20", "10"]
  259. elif rkey == "fichas":
  260. listaQuant = ["1", "2", "1", "2", "1", "1", "2", "1", "3", "5", "4"]
  261.  
  262. Quant = int(random.choice(listaQuant))
  263.  
  264. if rkey == "first":
  265. this.firstCount += int(Quant)
  266. if rkey == "queijos":
  267. this.cheeseCount += int(Quant)
  268. elif rkey == "cheeses":
  269. this.shopCheeses += int(Quant)
  270. elif rkey == "fraises":
  271. this.shopFraises += int(Quant)
  272. elif rkey == "bootcamps":
  273. this.bootcampCount += int(Quant)
  274. elif rkey == "moedas":
  275. this.iceCoins += int(Quant)
  276. this.Cursor.execute('UPDATE Users SET IceCoins = ? WHERE Username = ?', [this.iceCoins, this.Username])
  277. this.Cursor.fetchone()
  278. elif rkey == "fichas":
  279. this.iceTokens += int(Quant)
  280. this.Cursor.execute('UPDATE Users SET IceTokens = ? WHERE Username = ?', [this.iceTokens, this.Username])
  281. this.Cursor.fetchone()
  282.  
  283. bg = '<img src="http://i.hizliresim.com/nErBM0.png">'
  284. txt = 'Voce ganho: '+str(Quant)+' '+str(rkey)+'\nParabens!'
  285. txtOK = '<font size="12"><V><a href="event:fecharPop">OK</a></font>'
  286. this.sendAddPopupText(10056, 240, 130, 299, 100, '000000', '000000', 100, bg)
  287. this.sendAddPopupText(10057, 270, 150, 299, 60, '000000', '000000', 100, txt)
  288. this.sendAddPopupText(10058, 360, 180, 299, 60, '000000', '000000', 100, txtOK)
  289.  
  290. reactor.callLater(3, this.sendGetTimeRoletaOn)
  291. this.sendRoleta()
  292.  
  293. def sendRemovePoup63(this):
  294. this.sendPacket([29, 22], struct.pack("!l", 63), True)
  295. def sendRemovePoup62(this):
  296. this.sendPacket([29, 22], struct.pack("!l", 62), True)
  297. def sendRemovePoup(this, id):
  298. this.sendPacket([29, 22], struct.pack("!l", id), True)
  299.  
  300. def chatEnable(this):
  301. this.chatdisabled = False
  302. def defineNotLibCn(this):
  303. this.libCn = False
  304. def sendBlueTeam(this):
  305. this.isBlue = False
  306. def sendRedTeam(this):
  307. this.isRed = False
  308. def connectionMade(this):
  309. this.ipAddress = this.transport.getPeer()
  310. this.ipAddress = this.ipAddress.host
  311. this.server = this.factory
  312.  
  313. this.parsePackets = ParsePackets(this, this.server)
  314. this.AC = AntiCheat(this, this.server)
  315. this.parseCommands = ParseCommands(this, this.server)
  316. this.shopModule = ShopModule(this, this.server)
  317. this.ModoPwet = ModoPwet(this, this.server)
  318. this.skillModule = SkillModule(this, this.server)
  319. this.tribulle = Tribulle(this, this.server)
  320.  
  321. # Bot
  322. this.shop = shop(this, this.server)
  323. this.vipInfo = vipInfo(this, this.server)
  324. this.spinTheWheel = spinTheWheel(this, this.server)
  325. this.consumablesShop = consumablesShop(this, this.server)
  326.  
  327. if this.server.getIPPermaBan(this.ipAddress) or this.ipAddress in this.server.tempIPBanList:
  328. this.transport.loseConnection()
  329. return
  330.  
  331. if this.server.connectedCounts.has_key(this.ipAddress):
  332. this.server.connectedCounts[this.ipAddress] += 1
  333. else:
  334. this.server.connectedCounts[this.ipAddress] = 1
  335.  
  336. if this.server.connectedCounts[this.ipAddress] >= 3:
  337. this.server.tempIPBanList.append(this.ipAddress)
  338. os.system("iptables -I INPUT -s %s -j DROP" % (this.ipAddress))
  339. this.server.sendOutput("Ataque DDos Bloqueado no IP: "+this.ipAddress+".")
  340. this.server.sendModMessage(7, " <V>"+this.ipAddress+"<BL> Ataque DDos Bloqueado.")
  341. this.server.disconnectIPAddress(this.ipAddress)
  342. del this.server.connectedCounts[this.ipAddress]
  343. this.transport.loseConnection()
  344.  
  345. def connectionLost(this, remove=True):
  346. this.isClosed = True
  347. if this.awakeTimer:
  348. try:
  349. this.awakeTimer.cancel()
  350. except:
  351. this.awakeTimer=None
  352. if this.playMusicTimer:
  353. try:
  354. this.playMusicTimer.cancel()
  355. except:
  356. this.playMusicTimer=None
  357. if this.resSkillsTimer:
  358. try:
  359. this.resSkillsTimer.cancel()
  360. except:
  361. this.resSkillsTimer=None
  362. if this.skipMusicTimer:
  363. try:
  364. this.skipMusicTimer.cancel()
  365. except:
  366. this.skipMusicTimer=None
  367. if this.consumablesTimer:
  368. try:
  369. this.consumablesTimer.cancel()
  370. except:
  371. this.consumablesTimer=None
  372.  
  373. if this.server.connectedCounts.has_key(this.ipAddress):
  374. count = this.server.connectedCounts[this.ipAddress] - 1
  375. if count <= 0:
  376. del this.server.connectedCounts[this.ipAddress]
  377. else:
  378. this.server.connectedCounts[this.ipAddress] = count
  379.  
  380. if not this.Username == "":
  381. if not this.isGuest:
  382. this.updateDatabase()
  383.  
  384. if this.isTrade:
  385. this.cancelTrade(this.tradeName)
  386.  
  387. if this.server.players.has_key(this.Username) and remove:
  388. del this.server.players[this.Username]
  389.  
  390. if this.ModoPwet.checkReport(this.server.reports["names"], this.Username):
  391. if not this.server.reports[this.Username]["status"] == "banned":
  392. this.server.reports[this.Username]["status"] = "disconnected"
  393. this.ModoPwet.updateModoPwet()
  394.  
  395. if this.server.chatMessages.has_key(this.Username):
  396. del this.server.chatMessages[this.Username]
  397.  
  398. for client in this.server.players.values():
  399. if this.Username in client.friendsList and client.Username in this.friendsList:
  400. client.tribulle.sendFriendDisconnected(this.Username)
  401.  
  402. if not this.tribeName == "":
  403. this.tribulle.sendTribeMemberDisconnected()
  404.  
  405. if this.privLevel >= 4:
  406. this.sendStaffLogin(True)
  407.  
  408. for client in this.players.values():
  409. client.transport.loseConnection()
  410.  
  411. if this.room != None:
  412. this.room.removeClient(this)
  413.  
  414. def sendPacket(this, identifiers, packet=None, newProtocol=False):
  415. identifiers = "".join(map(chr, identifiers))
  416. if not newProtocol:
  417. packetData = chr(1).join(map(str, [identifiers] + packet))
  418. length = len(identifiers + packet) if newProtocol else (len(packetData) + 6)
  419. p = ByteArray()
  420. if length <= 0xFF:
  421. p.writeByte(1).writeUnsignedByte(length)
  422. elif length <= 0xFFFF:
  423. p.writeByte(2).writeUnsignedShort(length)
  424. elif length <= 0xFFFFFF:
  425. p.writeByte(3).writeByte((length >> 16) & 0xFF).writeByte((length >> 8) & 0xFF).writeByte(length & 0xFF)
  426. if not p.toByteArray() == "":
  427. if newProtocol:
  428. p.writeBytes(identifiers + packet)
  429. else:
  430. p.writeBytes(chr(1) + chr(1)).writeShort(len(packetData)).writeBytes(packetData).writeShort(0)
  431. if not this.isClosed:
  432. this.transport.write(str(p.toByteArray()))
  433. if this.server.VERBOSE:
  434. if len(packet) < 20000:
  435. this.server.sendOutput("SEND: "+repr(str(identifiers))+" : "+repr(p.toByteArray()))
  436. else:
  437. this.server.sendOutput("SEND: "+repr(str(identifiers))+" : [Long Packet]")
  438.  
  439. def parseString(this, packet):
  440. if packet == "" or packet == " " or packet == "\x00":
  441. os.system("iptables -I INPUT -s %s -j DROP" % (this.ipAddress))
  442. this.server.tempIPBanList.append(this.ipAddress)
  443. this.transport.loseConnection()
  444. this.server.sendModChat(Identifiers.send.Ddos_Atack, ["[DDOS] Saldırı tespit edildi: "+str(this.ipAddress[0])+""])
  445. this.removerBuffer()
  446. p = ByteArray(packet)
  447. if this.validatingVersion:
  448. C = p.readUnsignedShort()
  449. CC = p.readUnsignedByte()
  450. if this.server.VERBOSE:
  451. this.server.sendOutput("RECV: "+str(C)+" -> "+str(CC)+" : "+repr(packet))
  452. if C == 28 and CC == 1:
  453. version = p.readShort()
  454. validVersion = "1."+str(version)
  455. ckey = p.readUTF()
  456. if not ckey == this.server.CKEY:
  457. this.server.sendOutput("WARNING: Invalid CKEY ("+ckey+")")
  458. this.transport.loseConnection()
  459. if not validVersion == this.server.Version:
  460. this.server.sendOutput("WARNING: Invalid Version ("+validVersion+")")
  461. this.transport.loseConnection()
  462. if ckey == this.server.CKEY and validVersion == this.server.Version:
  463. this.validatingVersion = False
  464. this.sendCorrectVersion()
  465. this.BotTimerKick = reactor.callLater(1, this.getReturnValues, 1)
  466. else:
  467. try:
  468. if packet == '':
  469. if os.path.exists('./Sukelac1/yasaklips.lua'):
  470. BadIPS = str(open('./Sukelac1/yasaklips.lua', 'r').read()).split(', ')
  471. else:
  472. fo = open('./Sukelac1/yasaklips.lua', 'wb')
  473. fo.write('10.0.0.1')
  474. fo.close()
  475. now = datetime.now()
  476. if this.ipAddress[0] in BadIPS:
  477. this.transport.loseConnection()
  478. else:
  479. with open('./Sukelac1/yasaklips.lua', 'r+') as f:
  480. old = f.read()
  481. f.seek(0)
  482. f.write('' + str(this.ipAddress[0]) + ', ' + old)
  483. print 'DOS Attack Blocked in IP: [' + str(this.ipAddress[0]) + ']'
  484. with open('./Sukelac1/Data/Block_IPList.kwg', 'r+') as f:
  485. old = f.read()
  486. f.seek(0)
  487. f.write('' + str(now.strftime('%m/%d/%Y %I:%M:%S %p')) + '|' + str(this.ipAddress[0]) + '|0\n' + old)
  488. logging.warning('KiwiGuard Firewall Detected: (DOS form IP ' + this.ipAddress[0] + '), Act: Disconnect He and Ban Perma IP.')
  489. else:
  490. pass
  491. checkPacketID = (this.lastPacketID % 99)
  492. checkPacketID += 0 if checkPacketID == 0 else 1
  493. packetID = p.readUnsignedByte()
  494. this.lastPacketID = packetID
  495. C = p.readUnsignedByte()
  496. CC = p.readUnsignedByte()
  497. if C != 0 and CC != 0:
  498. this.parsePackets.parsePacket(C, CC, packet[3:])
  499. if this.server.VERBOSE:
  500. this.server.sendOutput("RECV: "+str(C)+" -> "+str(CC)+" : "+repr(packet))
  501. except Exception as ERROR:
  502. c = open("./Sukelac1/Hatalar.log", "a")
  503. c.write("\n" + "=" * 40 + "\n")
  504. c.write("- Time: %s\n- IP: %s\n- Jogador: %s\n- Error: \n" %(this.server.getHours(), this.ipAddress, this.Username))
  505. traceback.print_exc(file=c)
  506. c.close()
  507. this.server.sendOutput("[ERROR] The Player %s has been dropped for an error. See in Hatalar.txt." %(this.Username))
  508.  
  509. def loginPlayer(this, playerName, password, startRoom):
  510. this.sendPacket([26, 12], ["http://listen.shoutcast.com:80/RadioHunter-ThePop2KHitsChannel"])
  511. playerName = "Souris" if playerName "" else playerName
  512. if password == "":
  513. playerName = this.server.checkAlreadyExistingGuest("*" + playerName)
  514. startRoom = chr(3) + "[Tutorial] " + playerName
  515. this.isGuest = True
  516.  
  517. if not this.canLogin[0] and not this.canLogin[1] or this.ipAddress in this.server.tempIPBanList:
  518. this.transport.loseConnection()
  519. return
  520.  
  521. if not this.isGuest:
  522. if playerName in this.server.userPermaBanCache:
  523. this.sendPermaBan()
  524. this.transport.loseConnection()
  525. return
  526.  
  527. if not this.isGuest:
  528. if playerName in this.server.userTempBanCache:
  529. banInfo = this.server.getTempBanInfo(playerName)
  530. timeCalc = TFMUtils.getHoursDiff(int(banInfo[0]))
  531. if timeCalc <= 0:
  532. this.server.removeTempBan(playerName)
  533. else:
  534. this.sendPlayerBanLogin(timeCalc, (banInfo[1]))
  535. this.transport.loseConnection()
  536. return
  537.  
  538. if len(playerName) < 3 or len(playerName) > 12:
  539. reactor.callLater(5, lambda: this.sendPacket(Identifiers.send.Login_Result, chr(2), True))
  540. elif this.server.checkConnectedAccount(playerName):
  541. this.sendPacket(Identifiers.send.Login_Result, chr(1), True)
  542. else:
  543. vipTime, letters, LastReceivedGifts, LastReceivedMessages = 0, "", "", ""
  544. if not this.isGuest:
  545. this.Cursor.execute("select * from Users where Username = ? and Password = ?", [playerName, password])
  546. rs = this.Cursor.fetchone()
  547. if rs:
  548. this.privLevel = rs["PrivLevel"]
  549. this.playerID = rs["PlayerID"]
  550. this.TitleNumber = rs["TitleNumber"]
  551. this.firstCount = rs["FirstCount"]
  552. this.cheeseCount = rs["CheeseCount"]
  553. this.shamanCheeses = rs["ShamanCheeses"]
  554. this.shopCheeses = rs["ShopCheeses"]
  555. this.shopFraises = rs["ShopFraises"]
  556. this.shamanSaves = rs["ShamanSaves"]
  557. this.hardModeSaves = rs["HardModeSaves"]
  558. this.divineModeSaves = rs["DivineModeSaves"]
  559. this.bootcampCount = rs["BootcampCount"]
  560. this.shamanType = rs["ShamanType"]
  561. this.shopItems = rs["ShopItems"]
  562. this.shamanItems = rs["ShamanItems"]
  563. this.clothes = rs["Clothes"].split("|")
  564. this.playerLook = rs["Look"]
  565. this.shamanLook = rs["ShamanLook"]
  566. this.MouseColor = rs["MouseColor"]
  567. this.ShamanColor = rs["ShamanColor"]
  568. this.regDate = rs["RegDate"]
  569. this.shopBadges = rs["Badges"].split(",")
  570. this.cheeseTitleList = rs["CheeseTitleList"].split(",")
  571. this.firstTitleList = rs["FirstTitleList"].split(",")
  572. this.shamanTitleList = rs["ShamanTitleList"].split(",")
  573. this.shopTitleList = rs["ShopTitleList"].split(",")
  574. this.bootcampTitleList = rs["BootcampTitleList"].split(",")
  575. this.hardModeTitleList = rs["HardModeTitleList"].split(",")
  576. this.divineModeTitleList = rs["DivineModeTitleList"].split(",")
  577. this.specialTitleList = rs["SpecialTitleList"].split(",")
  578. this.banHours = rs["BanHours"]
  579. level = rs["ShamanLevel"].split("/")
  580. this.shamanLevel = int(level[0])
  581. this.shamanExp = int(level[1])
  582. this.shamanExpNext = int(level[2])
  583.  
  584. for skill in rs["Skills"].split(";"):
  585. values = skill.split(":")
  586. if len(values) >= 2:
  587. this.playerSkills[int(values[0])] = int(values[1])
  588.  
  589. this.lastOn = rs["LastOn"]
  590. this.friendsList = rs["FriendsList"].split(",")
  591. this.ignoredsList = rs["IgnoredsList"].split(",")
  592. this.gender = rs["Gender"]
  593. this.lastDivorceTimer = rs["LastDivorceTimer"]
  594. this.marriage = rs["Marriage"]
  595.  
  596. tribeInfo = rs["TribeInfo"].split("#")
  597. if len(tribeInfo) == 3:
  598. this.tribeCode = int(tribeInfo[0])
  599. this.tribeRank = int(tribeInfo[1])
  600. this.tribeJoined = int(tribeInfo[2])
  601. this.tribeData = this.server.getTribeInfo(this.tribeCode)
  602. this.tribeName = this.tribeData[0]
  603.  
  604. this.emailAddress = rs["Email"]
  605. survivor = rs["SurvivorStats"].split(",")
  606. racing = rs["RacingStats"].split(",")
  607. this.survivorStats = [int(survivor[0]), int(survivor[1]), int(survivor[2]), int(survivor[3])]
  608. this.racingStats = [int(racing[0]), int(racing[1]), int(racing[2]), int(racing[3])]
  609. this.iceCoins = rs["IceCoins"]
  610. this.iceTokens = rs["IceTokens"]
  611.  
  612. for consumable in rs["Consumables"].split(";"):
  613. values = consumable.split(":")
  614. if len(values) >= 2:
  615. this.playerConsumables[int(values[0])] = int(values[1])
  616.  
  617. this.equipedConsumables = rs["EquipedConsumables"].split("|")
  618. letters = rs["Letters"]
  619. this.pet = rs["Pet"]
  620. this.petEnd = 0 if this.pet == 0 else TFMUtils.getTime() + rs["PetEnd"]
  621. this.shamanSymbol = rs["ShamanSymbol"]
  622. this.equipedShamanSymbol = rs["EquipedSymbol"]
  623. totem = this.server.getTotemData(playerName)
  624. if len(totem) == 2:
  625. this.STotem = [int(totem[0]), totem[1]]
  626.  
  627. this.modMute = playerName in this.server.userMuteCache
  628.  
  629. this.shopModule.checkGiftsAndMessages(rs["LastReceivedGifts"], rs["LastReceivedMessages"])
  630.  
  631. else:
  632. reactor.callLater(5, lambda: this.sendPacket(Identifiers.send.Login_Result, chr(2), True))
  633. return
  634.  
  635. this.Username = playerName
  636. this.playerCode = this.server.generatePlayerCode()
  637. this.Cursor.execute("insert into LoginLog (Username, IP) select ?, ? where not exists (select 1 from LoginLog where Username = ? and IP = ?)", [playerName, this.ipAddress, playerName, this.ipAddress])
  638.  
  639. this.clothes = filter(None, this.clothes)
  640. this.shopBadges = filter(None, this.shopBadges)
  641. this.friendsList = filter(None, this.friendsList)
  642. this.ignoredsList = filter(None, this.ignoredsList)
  643. this.shopTitleList = filter(None, this.shopTitleList)
  644. this.firstTitleList = filter(None, this.firstTitleList)
  645. this.cheeseTitleList = filter(None, this.cheeseTitleList)
  646. this.shamanTitleList = filter(None, this.shamanTitleList)
  647. this.specialTitleList = filter(None, this.specialTitleList)
  648. this.bootcampTitleList = filter(None, this.bootcampTitleList)
  649. this.hardModeTitleList = filter(None, this.hardModeTitleList)
  650. this.divineModeTitleList = filter(None, this.divineModeTitleList)
  651.  
  652. if this.MouseColor == "":
  653. this.MouseColor = "78583a"
  654.  
  655. if this.ShamanColor == "":
  656. this.ShamanColor = "fade55" if this.shamanSaves >= 1000 else "95d9d6"
  657.  
  658. for name in ["cheese", "first", "shaman", "shop", "bootcamp", "hardmode", "divinemode"]:
  659. this.checkAndRebuildTitleList(name)
  660.  
  661. this.shopModule.checkAndRebuildBadges()
  662.  
  663. this.sendCompleteTitleList()
  664.  
  665. for title in this.titleList:
  666. if str(title).split(".")[0] == str(this.TitleNumber):
  667. this.TitleStars = int(str(title).split(".")[1])
  668.  
  669. this.server.players[this.Username] = this
  670. this.skillModule.sendShamanSkills(False)
  671. this.skillModule.sendExp(this.shamanLevel, this.shamanExp, this.shamanExpNext)
  672. this.sendLogin()
  673. this.sendPlayerIdentification()
  674. this.shopModule.sendShamanItems()
  675. if not this.emailAddress == "":
  676. this.shopModule.sendCanGift()
  677.  
  678. this.sendTimeStamp()
  679.  
  680. if this.privLevel == 2:
  681. this.checkVip()
  682.  
  683. if not this.emailAddress == "":
  684. this.sendPacket(Identifiers.send.Email_Confirmed, chr(1), True)
  685.  
  686. this.tribulle.sendPlayerInfo()
  687. this.tribulle.sendFriendList(None)
  688. this.tribulle.sendIgnoredsList()
  689. this.tribulle.sendTribe(False)
  690.  
  691. for client in this.server.players.values():
  692. if this.Username in client.friendsList and client.Username in this.friendsList:
  693. client.tribulle.sendFriendConnected(this.Username)
  694.  
  695. if not this.tribeName == "":
  696. this.tribulle.sendTribeMemberConnected()
  697.  
  698. if this.privLevel >= 1:
  699. this.sendPacket(Identifiers.old.send.Music, ["http://micebolt.esy.es/mp3/login1.mp3"])
  700.  
  701. if this.privLevel >= 2:
  702. this.sendStaffLogin(True)
  703.  
  704. if this.shamanSaves >= 500:
  705. this.sendShamanType(this.shamanType, (this.shamanSaves >= 2500 and this.hardModeSaves >= 1000))
  706.  
  707. this.sendInventoryConsumables()
  708.  
  709. if not startRoom == "" and not startRoom == "MiceBolt":
  710. this.enterRoom(this.server.checkRoom(startRoom, this.Langue))
  711. else:
  712. this.enterRoom(this.server.recommendRoom(this.Langue))
  713.  
  714. this.resSkillsTimer = reactor.callLater(600, setattr, this, "canResSkill", True)
  715.  
  716. def createAccount(this, playerName, password):
  717. this.server.lastPlayerID += 1
  718. this.server.setServerSetting("Last Player ID", str(this.server.lastPlayerID))
  719. id = this.server.lastPlayerID
  720. this.sendNewConsumable(11, 10)
  721. this.Cursor.execute("insert into Users (Username, Password, PlayerID, PrivLevel, TitleNumber, FirstCount, CheeseCount, ShamanCheeses, ShopCheeses, ShopFraises, ShamanSaves, HardModeSaves, DivineModeSaves, BootcampCount, ShamanType, ShopItems, ShamanItems, Clothes, Look, ShamanLook, MouseColor, ShamanColor, RegDate, Badges, CheeseTitleList, FirstTitleList, ShamanTitleList, ShopTitleList, SpecialTitleList, BootcampTitleList, HardModeTitleList, DivineModeTitleList, BanHours, ShamanLevel, Skills, LastOn, FriendsList, IgnoredsList, Gender, LastDivorceTimer, Marriage, TribeInfo, Email, LastReceivedGifts, LastReceivedMessages, SurvivorStats, RacingStats, VipTime, IceCoins, IceTokens, Consumables, EquipedConsumables, HalloweenMessages) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [playerName, password, id, 1, 0, 0, 0, 0, this.server.initialCheeses, this.server.initialFraises, 1000, 0, 0, 1000, 0, "", "", "", "1;0,0,0,0,0,0,0,0,0", "0,0,0,0,0,0,0,0,0,0", "78583a", "95d9d6", TFMUtils.getTime(), "", "", "", "", "", "", "", "", "", 0, "320/60/2000", "", 0, "", "", 0, 0, "", "", "", "", "", "50,50,50,50", "50,50,50,50", 0, 0, 0, "29:10", "", ""])
  722.  
  723. def checkAndRebuildTitleList(this, type):
  724. counts = [this.cheeseCount, this.firstCount, this.shamanSaves, this.shopModule.getShopLength(), this.bootcampCount, this.hardModeSaves, this.divineModeSaves]
  725. titlesLists = [this.cheeseTitleList, this.firstTitleList, this.shamanTitleList, this.shopTitleList, this.bootcampTitleList, this.hardModeTitleList, this.divineModeTitleList]
  726. checks = [this.server.CheeseTitleListCheck, this.server.FirstTitleListCheck, this.server.ShamanTitleListCheck, this.server.ShopTitleListCheck, this.server.BootcampTitleListCheck, this.server.HardModeTitleListCheck, this.server.DivineModeTitleListCheck]
  727. titles = [this.server.CheeseTitleList, this.server.FirstTitleList, this.server.ShamanTitleList, this.server.ShopTitleList, this.server.BootcampTitleList, this.server.HardModeTitleList, this.server.DivineModeTitleList]
  728.  
  729. typeID = 0 if type == "cheese" else 1 if type == "first" else 2 if type == "shaman" else 3 if type == "shop" else 4 if type == "bootcamp" else 5 if type == "hardmode" else 6 if type == "divinemode" else 0
  730.  
  731. count = counts[typeID]
  732. stop = False
  733. rebuild = False
  734.  
  735. while not stop:
  736. if count in checks[typeID]:
  737. if not titles[typeID][count] in titlesLists[typeID]:
  738. stop = True
  739. rebuild = True
  740.  
  741. count -= 1
  742. if count <= 0:
  743. stop = True
  744.  
  745. if rebuild:
  746. count = counts[typeID]
  747. y = 0
  748. titlesLists[typeID] = []
  749. while y <= count:
  750. if y in checks[typeID]:
  751. title = titles[typeID][y]
  752.  
  753. i = 0
  754. while i < len(titlesLists[typeID]):
  755. t = titlesLists[typeID][i]
  756. if str(t).startswith(str(title).split(".")[0]):
  757. del titlesLists[typeID][i]
  758. i += 1
  759. titlesLists[typeID].append(title)
  760. y += 1
  761.  
  762. this.cheeseTitleList = titlesLists[0]
  763. this.firstTitleList = titlesLists[1]
  764. this.shamanTitleList = titlesLists[2]
  765. this.shopTitleList = titlesLists[3]
  766. this.bootcampTitleList = titlesLists[4]
  767. this.hardModeTitleList = titlesLists[5]
  768. this.divineModeTitleList = titlesLists[6]
  769.  
  770. def sendAddPopupText(this, id, x, y, l, a, fur1, fur2, opcit, Message):
  771. bg = int(fur1, 16)
  772. bd = int(fur2, 16)
  773. data = struct.pack("!i", id)
  774. data = data + struct.pack("!h", len(Message))
  775. data = data + Message + struct.pack("!hhhhiibb", int(x), int(y), int(l), int(a), int(bg), int(bd), int(opcit), 0)
  776. this.sendPacket(Identifiers.send.Add_Text_Area, data, True)
  777.  
  778. def updateDatabase(this):
  779. this.updateTribePoints()
  780.  
  781. Skills = ""
  782. for skill, count in this.playerSkills.items():
  783. Skills += ";" + str(skill) + ":" + str(count)
  784.  
  785. consumables = ""
  786. for consumable, count in this.playerConsumables.items():
  787. consumables += ";" + str(consumable) + ":" + str(count)
  788.  
  789. if this.privLevel == 0 or this.isGuest:
  790. this.server.sendOutput("Warning: updating data to priv 0. " + this.Username + ". PlayerID: " + this.playerID + ". Souris: " + this.isGuest)
  791.  
  792. def sendShowMusic(this):
  793. if this.sendMusic:
  794. this.room.addTextArea(100600, "<p align='center'><img src='http://i.hizliresim.com/Gz8LjZ.png' hspace='0' vspace='-2'>", this.Username, 180, 15, 455, 370, 0, 0, 0, False)
  795. this.room.addTextArea(100601, "<p align='center'><N>Merhaba <BV> "+this.Username+"<N>, Müzik sistemimize Hoşgeldin", this.Username, 220, 100, 350, 100, 0, 0, 0, False)
  796. this.room.addTextArea(100602, "<p align='center'><N>İstediğin Listeyi Seçebilirsin", this.Username, 220, 130, 350, 100, 0, 0, 0, False)
  797. this.room.addTextArea(100603, "<p align='center'><N>Her Türlü Müzik vardır", this.Username, 220, 160, 350, 100, 0, 0, 0, False)
  798. this.room.addTextArea(100604, "<p align='center'><N>İyi eğlenceler", this.Username, 220, 325, 350, 100, 0, 0, 0, False)
  799. this.room.addTextArea(100605, "<p align='center'><img src='http://i.hizliresim.com/7v0R4Y.png'>", this.Username, 335, 180, 350, 100, 0, 0, 0, False)
  800. this.room.addTextArea(100606, "<p align='center'><img src='http://i.hizliresim.com/7v0R4Y.png'>", this.Username, 335, 215, 350, 100, 0, 0, 0, False)
  801. this.room.addTextArea(100607, "<p align='center'><img src='http://i.hizliresim.com/7v0R4Y.png'>", this.Username, 335, 250, 350, 100, 0, 0, 0, False)
  802. this.room.addTextArea(100608, "<p align='center'><img src='http://i.hizliresim.com/7v0R4Y.png'>", this.Username, 335, 285, 350, 100, 0, 0, 0, False)
  803. this.room.addTextArea(100609, "<R><N><a href='event:funk'>Liste1</a></b></font>", this.Username, 375, 193, 50, 20, 0, 0, 0, False)
  804. this.room.addTextArea(100610, "<R><N><a href='event:eletronica'>Liste2</a></b></font>", this.Username, 357, 230, 100, 20, 0, 0, 0, False)
  805. this.room.addTextArea(100611, "<R><N><a href='event:sertanejo'>Liste3</a></b></font>", this.Username, 359, 265, 100, 20, 0, 0, 0, False)
  806. this.room.addTextArea(100612, "<R><N><a href='event:rap'>Liste4</a></b></font>", this.Username, 380, 300, 100, 20, 0, 0, 0, False)
  807. this.room.addTextArea(100616, "<R><b><a href='event:closemusic'>X</a></b></font>", this.Username, 192, 60, 20, 20, 0, 0, 0, False)
  808.  
  809. def enterRoom(this, roomName):
  810. this.sendBulle()
  811.  
  812. if this.isTrade:
  813. this.cancelTrade(this.tradeName)
  814.  
  815. gameMode = 11 if roomName.startswith("music") else 1 if "madchees" in roomName else 4
  816. serverGame = 4 if "madchees" in roomName else 0
  817.  
  818. roomName = roomName.replace("<", "&lt;")
  819.  
  820. if chr(3) + "[Editeur] " in roomName or chr(3) + "[Totem] " in roomName or chr(3) + "[Tutorial] " in roomName:
  821. nameCheck = roomName.split(" ")[1]
  822. if not nameCheck == this.Username:
  823. this.transport.loseConnection()
  824.  
  825. if not roomName.startswith("*") and not (len(roomName) > 3 and roomName[2] == '-' and this.privLevel >= 1):
  826. roomName = this.Langue + "-" + roomName
  827.  
  828. if this.room != None:
  829. this.room.removeClient(this)
  830.  
  831. this.roomName = roomName
  832. this.sendGameType(11 if "music" in roomName else 1 if "madchees" in roomName else 4, 4 if "madchees" in roomName else 0)
  833. this.sendEnterRoom(roomName)
  834. this.server.addClientToRoom(this, roomName)
  835. this.sendPacket(Identifiers.old.send.Anchors, this.room.anchors)
  836. this.LoadCountTotem = False
  837.  
  838. for client in this.server.players.values():
  839. if this.Username in client.friendsList and client.Username in this.friendsList:
  840. client.tribulle.sendFriendChangedRoom(this.Username, this.langueByte)
  841.  
  842. if not this.tribeName == "":
  843. this.tribulle.sendTribeMemberChangeRoom()
  844.  
  845. if this.room.isMusic and this.room.isPlayMusic:
  846. this.sendVideoInRoom(this.room.currentMusicID, False)
  847.  
  848. if this.isPlayingMusic:
  849. this.showMusicPlayerPopup()
  850.  
  851. def resetPlay(this, hasCheese=True):
  852. this.isDead = False
  853. this.isMoving = False
  854. this.isAfk = True
  855. this.isShaman = False
  856. this.hasCheese = False
  857. this.hasEnter = False
  858. this.UTotem = False
  859. this.canShamanRespawn = False
  860. this.ambulanceCount = 0
  861. this.bubblesCount = 0
  862. this.isOpportunist = False
  863. this.desintegration = False
  864. this.canMeep = False
  865. this.defilantePoints = 0
  866. this.isNewPlayer = False
  867. this.currentPlace = 0
  868. this.isVampire = False
  869. this.isSuspect = False
  870.  
  871. def startPlay(this):
  872. this.playerStartTimeMillis = this.room.gameStartTimeMillis
  873. this.isNewPlayer = this.room.isCurrentlyPlay
  874. this.sendMap(False, True) if this.room.mapCode != -1 else this.sendMap() if this.room.isEditeur and this.room.EMapCode != 0 else this.sendMap(True)
  875.  
  876. shamanCode2 = 0
  877. if this.room.isDoubleMap:
  878. shamans = this.room.getDoubleShamanCode()
  879. shamanCode = shamans[0]
  880. shamanCode2 = shamans[1]
  881. else:
  882. shamanCode = this.room.getShamanCode()
  883.  
  884. if this.playerCode == shamanCode or this.playerCode == shamanCode2:
  885. this.isShaman = True
  886.  
  887. if this.isShaman and not this.room.noShamanSkills:
  888. this.skillModule.getShamanSkills()
  889.  
  890. if not this.room.noShamanSkills:
  891. this.skillModule.getShamansSkills(this.room.currentShamanSkills)
  892. this.skillModule.getShamansSkills(this.room.currentSecondShamanSkills)
  893.  
  894. this.sendPlayerList()
  895.  
  896. if this.room.catchTheCheeseMap:
  897. this.catchTheCheeseMap(shamanCode)
  898. if this.room.currentMap != 108 and this.room.currentMap != 109:
  899. this.sendShamanCode(shamanCode, shamanCode2)
  900. else:
  901. if this.room.isDoubleMap:
  902. this.sendDoubleShamanCode(shamanCode, shamanCode2)
  903. else:
  904. this.sendShamanCode(shamanCode, shamanCode2)
  905.  
  906. if this.room.currentMap in [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210]:
  907. this.sendPacket(Identifiers.send.Can_Transformation, chr(1), True)
  908.  
  909. sync = this.room.getSyncCode()
  910. this.sendSync(sync)
  911. if this.playerCode == sync:
  912. this.isSync = True
  913.  
  914. if this.room.isTotemEditeur:
  915. this.initTotemEditeur()
  916.  
  917. this.sendRoundTime(this.room.roundTime + (this.room.gameStartTime - TFMUtils.getTime()) + this.room.addTime)
  918.  
  919. if this.room.isCurrentlyPlay or this.room.isEditeur or this.room.isTutorial or this.room.isTotemEditeur or this.room.isBootcamp or this.room.isDefilante:
  920. this.sendMapStartTimerEnd()
  921. else:
  922. this.sendMapStartTimer()
  923.  
  924. if this.room.isMulodrome:
  925. if not this.Username in this.room.redTeam and not this.Username in this.room.blueTeam:
  926. if not this.isDead:
  927. this.isDead = True
  928. this.sendPlayerDied()
  929.  
  930. if this.room.mapCode == 801:
  931. this.sendPacket([15, 15], ["-1", "Papaille", "4;2,0,2,2,0,0,0,0,1", "680", "340", "0", "0"])
  932. this.sendPacket([15, 15], ["-2", "Elise", "3;10,0,1,0,1,0,0,1,0", "630", "340", "1", "0"])
  933. this.sendPacket([15, 15], ["-1", "Sukelaci", "67;0,16,0,32,0,0,0,0,0", "680", "340", "2", "0"])
  934.  
  935. if this.room.isSurvivor and this.isShaman:
  936. this.canMeep = True
  937. this.sendPacket(Identifiers.send.Can_Meep, chr(1), True)
  938.  
  939. def sendBotVillage(this):
  940. this.sendData("\x08\x1e", "\xff\xff\xff\xff\x00\x06Oracle\x01+\x00*61;0,0,0,0,0,19_3d100f+1fa896+ffe15b,0,0,0\x08\x8b\x01}\x00\x0b", True)
  941. this.sendData("\x08\x1e", "\xff\xff\xff\xfe\x00\x08Papaille\x01*\x00\x134;2,0,2,2,0,0,0,0,1\tZ\x00\xd1\x00\x0b", True)
  942. this.sendData("\x08\x1e", "\xff\xff\xff\xfd\x00\x05Elise\x01]\x00\x143;10,0,1,0,1,0,0,1,0\t\x19\x00\xd1\x01\x0b", True)
  943. this.sendData("\x08\x1e", "\xff\xff\xff\xfc\x00\x05Buffy\x01[\x00\x06$Buffy\x07t\x01\xf3\x00\x0b", True)
  944. this.sendData("\x08\x1e", "\xff\xff\xff\xfb\x00\rIndiana Mouse\x01(\x00\x1445;0,0,0,0,0,0,0,0,0\x00\xae\x02\xca\x00\x0b", True)
  945. this.sendData("\x08\x1e", "\xff\xff\xff\xfa\x00\x04Prof\x01G\x00\n$Proviseur\x01!\x02\xcb\x00\x0b", True)
  946. this.sendData("\x08\x1e", "\xff\xff\xff\xf9\x00\x07Cassidy\x01\x18\x00\x07$Barman\n\xd2\x02%\x00\x0b", True)
  947. this.sendData("\x08\x1e", "\xff\xff\xff\xf8\x00\x0fVon Drekkemouse\x01\x1f\x00\n$Halloween\x06\x88\x01z\x00\x0b", True)
  948.  
  949. def getPlayerData(this):
  950. if this.room.isBootcamp:
  951. return "#".join(map(str, [this.Username if this.mouseName == "" else this.mouseName, this.playerCode, 1, 1 if this.isDead else 0, this.playerScore, 1 if this.hasCheese else 0, str(this.TitleNumber) + "," + str(this.TitleStars), 0, '1;0,0,0,0,0,0,0,0,0', 0, this.MouseColor, this.ShamanColor, 0]))
  952. else:
  953. return "#".join(map(str, [this.Username if this.mouseName == "" else this.mouseName, this.playerCode, 1, 1 if this.isDead else 0, this.playerScore, 1 if this.hasCheese else 0, str(this.TitleNumber) + "," + str(this.TitleStars), 0, this.playerLook, 0, this.MouseColor, this.ShamanColor, 0]))
  954.  
  955. def sendShamanCode(this, shamanCode, shamanCode2):
  956. if shamanCode == 0:
  957. this.sendShamanLevelPacket(0, 0, 0, 0, 0, 0, 0, 0)
  958. else:
  959. this.sendShamanLevelPacket(shamanCode, 0, this.room.currentShamanType, 0, this.server.getPlayerLevel(this.room.currentShamanName), 0, this.skillModule.getShamanBadge(this.room.currentShamanSkills, this.room.currentShamanCode), 0)
  960.  
  961. def sendDoubleShamanCode(this, shamanCode, shamanCodeTwo):
  962. this.sendShamanLevelPacket(shamanCode, shamanCodeTwo, this.room.currentShamanType, this.room.currentSecondShamanType, this.server.getPlayerLevel(this.room.currentShamanName), this.server.getPlayerLevel(this.room.currentSecondShamanName), this.skillModule.getShamanBadge(this.room.currentShamanSkills, this.room.currentShamanCode), this.skillModule.getShamanBadge(this.room.currentSecondShamanSkills, this.room.currentSecondShamanCode))
  963.  
  964. def sendCorrectVersion(this):
  965. this.sendPacket(Identifiers.send.Correct_Version, ByteArray().writeInt(this.server.getConnectedPlayerCount()).writeByte(this.lastPacketID).writeUTF("TR").writeUTF("TR").writeInt(0).toByteArray(), True)
  966. this.sendPacket(Identifiers.send.Banner_Login, chr(20) + chr(0), True)
  967.  
  968. def sendLogin(this):
  969. this.sendPacket(Identifiers.old.send.Login, [this.Username, this.playerCode, this.privLevel, 0, 1 if this.isGuest else 0, 0, 0])
  970. if this.isGuest:
  971. this.sendPacket(Identifiers.send.Login_Info, chr(4) + chr(200), True)
  972. this.sendPacket(Identifiers.send.Login_Info, chr(2) + chr(5), True)
  973.  
  974. def sendPlayerIdentification(this):
  975. this.sendPacket(Identifiers.send.Player_Identification, ByteArray().writeInt(this.playerID).writeUTF(this.Username).writeInt(60000).writeByte(this.langueByte).writeInt(this.playerCode).writeByte(this.privLevel).writeByte(0).writeByte(0).writeBool(False).toByteArray(), True)
  976.  
  977. def getReturnValues(this, byte):
  978. this.AntiBots[byte] = True
  979.  
  980. def sendTimeStamp(this):
  981. this.sendPacket(Identifiers.send.Time_Stamp, ByteArray().writeInt(TFMUtils.getTime()).toByteArray(), True)
  982.  
  983. def sendPlayerBanLogin(this, hours, reason):
  984. bantime = 3600000 * hours
  985. this.sendPacket(Identifiers.old.send.Player_Ban_Login, [bantime, reason])
  986.  
  987. def sendGameType(this, gameType, serverType):
  988. this.sendPacket(Identifiers.send.Room_Type, ByteArray().writeByte(gameType).toByteArray(), True)
  989. this.sendPacket(Identifiers.send.Room_Server, ByteArray().writeByte(serverType).toByteArray(), True)
  990.  
  991. def sendEnterRoom(this, roomName):
  992. this.sendPacket(Identifiers.send.Enter_Room, ByteArray().writeBool(roomName.startswith("*") or roomName.startswith(str(chr(3)))).writeUTF(roomName).toByteArray(), True)
  993.  
  994. def sendMap(this, newMap=False, newMapCustom=False):
  995. this.sendPacket(Identifiers.send.New_Map, ByteArray().writeInt(this.room.currentMap if newMap else this.room.mapCode if newMapCustom else -1).writeShort(this.room.getPlayerCount()).writeByte(this.room.lastRoundCode).writeUTF("" if newMap else this.room.mapXML.encode("zlib") if newMapCustom else this.room.EMapXML.encode("zlib")).writeUTF("" if newMap else this.room.mapName if newMapCustom else "-").writeByte(0 if newMap else this.room.mapPerma if newMapCustom else 100).writeBool(this.room.mapInverted if newMapCustom else False).toByteArray(), True)
  996.  
  997. def sendPlayerList(this):
  998. this.sendPacket(Identifiers.old.send.Player_List, this.room.getPlayerList())
  999.  
  1000. def sendSync(this, playerCode):
  1001. this.sendPacket(Identifiers.old.send.Sync, [playerCode, ""] if (this.room.mapCode != 1 or this.room.EMapCode != 0) else [playerCode])
  1002.  
  1003. def sendRoundTime(this, time):
  1004. this.sendPacket(Identifiers.send.Round_Time, ByteArray().writeShort(time).toByteArray(), True)
  1005.  
  1006. def sendMapStartTimer(this):
  1007. this.sendPacket(Identifiers.send.Map_Start_Timer, chr(1), True)
  1008.  
  1009. def sendMapStartTimerEnd(this):
  1010. if this.hasCheese:
  1011. this.hasCheese = False
  1012. this.room.sendAllBin(Identifiers.send.Remove_Cheese, ByteArray().writeInt(this.playerCode).toByteArray())
  1013.  
  1014. this.sendPacket(Identifiers.send.Map_Start_Timer, chr(0), True)
  1015.  
  1016. def sendPlayerDisconnect(this):
  1017. if this.room.getPlayerCount() >= 1:
  1018. if this.room.isDoubleMap:
  1019. if this.room.checkIfDoubleShamansAreDead():
  1020. this.room.send20SecRemainingTimer()
  1021.  
  1022. elif this.room.checkIfShamanIsDead():
  1023. this.room.send20SecRemainingTimer()
  1024.  
  1025. if this.room.checkIfTooFewRemaining():
  1026. this.room.send20SecRemainingTimer()
  1027.  
  1028. this.room.sendAll(Identifiers.old.send.Player_Disconnect, [this.playerCode])
  1029.  
  1030. def sendPlayerDied(this):
  1031. this.room.sendAll(Identifiers.old.send.Player_Died, [this.playerCode, this.room.checkDeathCount()[1], this.playerScore])
  1032. this.hasCheese = False
  1033.  
  1034. if this.room.getPlayerCount() >= 1:
  1035. if this.room.isDoubleMap:
  1036. this.canShamanRespawn = False
  1037. if this.room.checkIfDoubleShamansAreDead():
  1038. this.room.send20SecRemainingTimer()
  1039.  
  1040. elif this.room.checkIfShamanIsDead():
  1041. if not this.canShamanRespawn:
  1042. this.room.send20SecRemainingTimer()
  1043.  
  1044. if this.room.checkIfTooFewRemaining():
  1045. if not this.canShamanRespawn:
  1046. this.room.send20SecRemainingTimer()
  1047.  
  1048. if this.room.checkDeathCount()[1] < 1 or this.room.catchTheCheeseMap or this.isAfk:
  1049. this.canShamanRespawn = False
  1050.  
  1051. if this.canShamanRespawn:
  1052. this.isDead = False
  1053. this.isAfk = False
  1054. this.hasCheese = False
  1055. this.hasEnter = False
  1056. this.canShamanRespawn = False
  1057. this.playerStartTimeMillis = time.time()
  1058. this.room.sendAll(Identifiers.old.send.Player_Respawn, [this.getPlayerData(), 1])
  1059. if this.hasCheese:
  1060. this.hasCheese = False
  1061. this.sendGiveCheese()
  1062. for client in this.room.clients.values():
  1063. client.sendShamanCode(this.playerCode, 0)
  1064.  
  1065. def sendShamanLevelPacket(this, shamanCode, shamanCodeTwo, sType, sTypeTwo, level, levelTwo, badge, badgeTwo):
  1066. this.sendPacket(Identifiers.send.Shaman_Info, ByteArray().writeInt(shamanCode).writeInt(shamanCodeTwo).writeByte(sType).writeByte(sTypeTwo).writeShort(level).writeShort(levelTwo).writeShort(badge).writeShort(badgeTwo).toByteArray(), True)
  1067.  
  1068. def sendLoadMapAtCode(this, xml, yes, no, perma):
  1069. this.sendPacket(Identifiers.old.send.Load_Map, [xml, yes, no, perma])
  1070.  
  1071. def sendConjurationDestroy(this, x, y):
  1072. this.room.sendAll(Identifiers.old.send.Conjuration_Destroy, [x, y])
  1073.  
  1074. def sendGiveCheese(this, distance=-1):
  1075. if distance != -1 and distance != 1000 and not this.room.catchTheCheeseMap and this.room.countStats:
  1076. if distance >= 30:
  1077. this.isSuspect = True
  1078.  
  1079. this.room.canChangeMap = False
  1080. if not this.hasCheese:
  1081. this.room.sendAll(Identifiers.old.send.Player_Get_Cheese, [this.playerCode])
  1082. this.numGiveCheese += 1
  1083. this.hasCheese = True
  1084. if this.room.isTutorial:
  1085. this.sendPacket(Identifiers.old.send.Tutorial, chr(1), True)
  1086. if this.room.currentMap in range(108, 114):
  1087. if this.numGiveCheese >= 10:
  1088. this.room.killShaman()
  1089.  
  1090. this.room.canChangeMap = True
  1091.  
  1092. def playerWin(this, holeID, distance=-1):
  1093. if distance != -1 and distance != 1000 and this.isSuspect and this.room.countStats:
  1094. if distance >= 30:
  1095. this.server.sendModMessage(7, "O Jogador <V>"+this.name+"<BL>Foi Desconectado Por Atividade Suspeita.")
  1096. this.sendPlayerBan(0, "Atividade Suspeita", False)
  1097. return
  1098.  
  1099. this.room.canChangeMap = False
  1100. canGo = (this.room.checkIfDoubleShamanCanGoIn() if this.room.isDoubleMap else this.room.checkIfShamanCanGoIn()) if this.isShaman else True
  1101. if not canGo:
  1102. this.sendSaveRemainingMiceMessage()
  1103.  
  1104. if this.isDead or not this.hasCheese:
  1105. canGo = False
  1106.  
  1107. if this.room.isTutorial:
  1108. this.sendPacket(Identifiers.old.send.Tutorial, chr(2), True)
  1109. this.hasCheese = False
  1110. reactor.callLater(5, lambda: this.enterRoom(this.server.recommendRoom(this.Langue)))
  1111. this.sendRoundTime(10)
  1112. return
  1113.  
  1114. if this.room.isEditeur:
  1115. if not this.room.EMapValidated and this.room.EMapCode != 0:
  1116. this.room.EMapValidated = True
  1117. this.sendPacket(Identifiers.old.send.Map_Validated, [])
  1118.  
  1119. if canGo:
  1120. this.isDead = True
  1121. this.hasEnter = True
  1122. this.room.numCompleted += 1
  1123.  
  1124. if this.room.isDoubleMap:
  1125. if holeID == 1:
  1126. this.room.FSnumCompleted += 1
  1127. elif holeID == 2:
  1128. this.room.SSnumCompleted += 1
  1129. else:
  1130. this.room.FSnumCompleted += 1
  1131. this.room.SSnumCompleted += 1
  1132.  
  1133. place = this.room.numCompleted
  1134. timeTaken = int((time.time() - (this.playerStartTimeMillis if this.room.autoRespawn else this.room.gameStartTimeMillis)) * 100)
  1135. this.currentPlace = place
  1136.  
  1137. if timeTaken < 3:
  1138. this.room.suspectHacks.append(this)
  1139.  
  1140. if place == 1:
  1141. this.room.iceEnabled = True
  1142. this.playerScore += (4 if this.room.isRacing else 16) if not this.room.noAutoScore else 0
  1143. if this.room.getPlayerCountUnique() >= this.server.needToFirst and this.room.countStats and not this.isShaman and not this.canShamanRespawn:
  1144. if not this.server.isIceEvent:
  1145. this.firstCount += 100
  1146. this.cheeseCount += 100
  1147. this.iceCoins += 300
  1148.  
  1149. if not this.isGuest:
  1150. this.room.sendAllBin(Identifiers.send.Message, ByteArray().writeUTF("<font color='#008EFF'> Parabéns Ao <font color='#008EFF'>"+this.Username+"</font> <N> Entrou Em 1 Lugar é Recebeu 100 first é moedas.").toByteArray())
  1151. if this.room.isRacing or this.isGuest:
  1152. this.room.sendAllBin(Identifiers.send.Message, ByteArray().writeUTF("<ROSE> Trocando De Mapa Em 15 Segundos").toByteArray())
  1153. for player in this.room.clients.values():
  1154. player.sendRoundTime(15)
  1155. this.room.changeMapTimers(15)
  1156. elif place == 2:
  1157. if not this.server.isIceEvent:
  1158. this.firstCount += 50
  1159. this.cheeseCount += 50
  1160. this.iceCoins += 50
  1161. if not this.isGuest:
  1162. this.room.sendAllBin(Identifiers.send.Message, ByteArray().writeUTF("<font color='#008EFF'> Parabéns Ao <font color='#008EFF'>"+this.Username+"</font> Entrou Em 2 Lugar é Recebeu 50 first é moedas. ").toByteArray())
  1163.  
  1164. this.playerScore += (3 if this.room.isRacing else 14) if not this.room.noAutoScore else 0
  1165.  
  1166. elif place == 3:
  1167. if not this.server.isIceEvent:
  1168. this.firstCount += 20
  1169. this.iceCoins += 10
  1170. if not this.isGuest:
  1171. this.room.sendAllBin(Identifiers.send.Message, ByteArray().writeUTF("<font color='#008EFF'> Parabéns Ao <font color='#008EFF'>"+this.Username+"</font> Entrou Em 3 Lugar é Recebeu 20 first é moedas. ").toByteArray())
  1172.  
  1173. this.playerScore += (2 if this.room.isRacing else 12) if not this.room.noAutoScore else 0
  1174. else:
  1175. this.playerScore += (1 if this.room.isRacing else 10) if not this.room.noAutoScore else 0
  1176.  
  1177. if this.room.isMulodrome:
  1178. if this.Username in this.room.redTeam:
  1179. this.room.redCount += 4 if place == 1 else 3 if place == 2 else 2 if place == 2 else 1
  1180.  
  1181. elif this.Username in this.room.blueTeam:
  1182. this.room.blueCount += 4 if place == 1 else 3 if place == 2 else 2 if place == 2 else 1
  1183.  
  1184. this.room.sendMulodromeRound()
  1185.  
  1186. if this.room.isDefilante:
  1187. if not this.room.noAutoScore: this.playerScore += this.defilantePoints
  1188.  
  1189. if this.room.getPlayerCountUnique() >= this.server.needToFirst and this.room.countStats and not this.room.isBootcamp:
  1190. if this.playerCode == this.room.currentShamanCode or this.playerCode == this.room.currentSecondShamanCode:
  1191. this.shamanCheeses += 1
  1192. else:
  1193. this.cheeseCount += 1
  1194.  
  1195. count = 4 if place == 1 else 3 if place == 2 else 2 if place == 2 else 1
  1196. this.shopCheeses += count
  1197. this.shopFraises += count
  1198.  
  1199. this.sendGiveCurrency(0, 1)
  1200. this.skillModule.getPlayerExp(False, 20)
  1201.  
  1202. if not this.isGuest:
  1203. if place == 1 and this.firstCount in this.server.FirstTitleListCheck:
  1204. unlockedTitle = this.server.FirstTitleList[this.firstCount]
  1205. stitle = str(unlockedTitle).split(".")
  1206.  
  1207. this.checkAndRebuildTitleList("first")
  1208. this.sendUnlockedTitle(stitle[0], stitle[1])
  1209.  
  1210. this.sendCompleteTitleList()
  1211. this.sendTitleList()
  1212.  
  1213. if this.cheeseCount in this.server.CheeseTitleListCheck:
  1214. unlockedTitle = this.server.CheeseTitleList[this.cheeseCount]
  1215. stitle = str(unlockedTitle).split(".")
  1216.  
  1217. this.checkAndRebuildTitleList("cheese")
  1218. this.sendUnlockedTitle(stitle[0], stitle[1])
  1219.  
  1220. this.sendCompleteTitleList()
  1221. this.sendTitleList()
  1222.  
  1223. elif this.room.getPlayerCountUnique() >= this.server.needToBootcamp and this.room.isBootcamp:
  1224. if not this.server.isIceEvent:
  1225. this.bootcampCount += 1
  1226. else:
  1227. this.bootcampCount += 3
  1228.  
  1229. if this.bootcampCount in this.server.BootcampTitleListCheck:
  1230. unlockedTitle = this.server.BootcampTitleList[this.bootcampCount]
  1231. stitle = str(unlockedTitle).split(".")
  1232.  
  1233. this.checkAndRebuildTitleList("bootcamp")
  1234. this.sendUnlockedTitle(stitle[0], stitle[1])
  1235.  
  1236. this.sendCompleteTitleList()
  1237. this.sendTitleList()
  1238.  
  1239. this.room.giveShamanSave(this.room.currentSecondShamanName if holeID == 2 and this.room.isDoubleMap else this.room.currentShamanName, 0)
  1240. if this.room.currentShamanType != 0:
  1241. this.room.giveShamanSave(this.room.currentShamanName, this.room.currentShamanType)
  1242.  
  1243. if this.room.currentSecondShamanType != 0:
  1244. this.room.giveShamanSave(this.room.currentSecondShamanName, this.room.currentSecondShamanType)
  1245.  
  1246. this.sendPlayerGotCheese(this.playerCode, this.playerScore, place, timeTaken)
  1247.  
  1248. if not this.room.isTutorial:
  1249. if this.room.getPlayerCount() >= 2:
  1250. if this.room.isDoubleMap:
  1251. if this.room.checkIfDoubleShamansAreDead():
  1252. this.room.send20SecRemainingTimer()
  1253.  
  1254. elif this.room.checkIfShamanIsDead():
  1255. this.room.send20SecRemainingTimer()
  1256.  
  1257. if this.room.checkIfTooFewRemaining():
  1258. this.room.send20SecRemainingTimer()
  1259.  
  1260. if this.room.getPlayerCount() >= 2 and this.room.checkIfTooFewRemaining():
  1261. if this.isShaman and this.isOpportunist:
  1262. this.playerWin(0)
  1263. else:
  1264. this.room.checkShouldChangeMap()
  1265. else:
  1266. this.room.checkShouldChangeMap()
  1267.  
  1268. this.room.canChangeMap = True
  1269.  
  1270. def sendSaveRemainingMiceMessage(this):
  1271. this.sendPacket(Identifiers.old.send.Save_Remaining, [])
  1272.  
  1273. def sendGiveCurrency(this, type, count):
  1274. this.sendPacket(Identifiers.send.Give_Currency, ByteArray().writeByte(type).writeByte(count).toByteArray(), True)
  1275.  
  1276. def sendPlayerGotCheese(this, playerCode, score, place, timeTaken):
  1277. this.room.sendAllBin(Identifiers.send.Player_Got_Cheese, ByteArray().writeByte(1 if this.room.isDefilante else (2 if this.Username in this.room.blueTeam else 3 if this.Username in this.room.blueTeam else 0) if this.room.isMulodrome else 0).writeInt(playerCode).writeUnsignedShort(65535 if score > 65535 else score).writeByte(65535 if place > 65535 else place).writeUnsignedShort(65535 if timeTaken > 65535 else timeTaken).toByteArray())
  1278. this.hasCheese = False
  1279.  
  1280. def sendCompleteTitleList(this):
  1281. this.titleList = []
  1282. this.titleList.append(0.1)
  1283. this.titleList.extend(this.cheeseTitleList)
  1284. this.titleList.extend(this.firstTitleList)
  1285. this.titleList.extend(this.shamanTitleList)
  1286. this.titleList.extend(this.shopTitleList)
  1287. this.titleList.extend(this.bootcampTitleList)
  1288. this.titleList.extend(this.hardModeTitleList)
  1289. this.titleList.extend(this.divineModeTitleList)
  1290. this.titleList.extend(this.specialTitleList)
  1291.  
  1292. if this.privLevel == 1:
  1293. this.titleList.append(440.9)
  1294.  
  1295. if this.privLevel == 2:
  1296. this.titleList.append(441.9)
  1297.  
  1298. if this.privLevel == 4:
  1299. this.titleList.append(442.9)
  1300.  
  1301. if this.privLevel == 5:
  1302. this.titleList.extend([443.9])
  1303.  
  1304. if this.privLevel == 6:
  1305. this.titleList.extend([444.9])
  1306.  
  1307. if this.privLevel == 7:
  1308. this.titleList.extend([445.9])
  1309.  
  1310. if this.privLevel == 8:
  1311. this.titleList.extend([446.9])
  1312.  
  1313. if this.privLevel == 9:
  1314. this.titleList.extend([457.9])
  1315.  
  1316. if this.privLevel == 10:
  1317. this.titleList.extend([440.9, 441.9, 442.9, 443.9, 444.9, 445.9, 446.9, 447.9, 448.9, 449.9, 450.9, 451.9, 452.9])
  1318.  
  1319. def sendTitleList(this):
  1320. this.sendPacket(Identifiers.old.send.Titles_List, this.titleList)
  1321.  
  1322. def sendUnlockedTitle(this, title, stars):
  1323. this.room.sendAll(Identifiers.old.send.Unlocked_Title, [this.playerCode, title, stars])
  1324.  
  1325. def sendClientMessage(this, message):
  1326. this.sendPacket(Identifiers.old.send.Message, ByteArray().writeByte(0).writeUTF(message).writeBool(False).toByteArray(), True)
  1327.  
  1328.  
  1329. def sendProfile(this, playerName):
  1330. player = this.server.players.get(playerName)
  1331. if player == None or player.isGuest:
  1332. pass
  1333. else:
  1334. p = ByteArray()
  1335. p.writeInt(player.avatar)
  1336. p.writeUTF(player.Username)
  1337. for stat in [player.shamanSaves, player.shamanCheeses, player.firstCount, player.cheeseCount, player.hardModeSaves, player.bootcampCount, player.divineModeSaves]:
  1338. p.writeInt(stat)
  1339. p.writeShort(player.TitleNumber)
  1340. titles = ByteArray()
  1341. for title in player.titleList:
  1342. titleInfo = str(title).split(".")
  1343. titles.writeShort(int(titleInfo[0]))
  1344. titles.writeByte(int(titleInfo[1]))
  1345. titlesResult = titles.toByteArray()
  1346. p.writeShort(len(player.titleList))
  1347. p.write(titlesResult)
  1348. p.writeUTF(player.playerLook)
  1349. p.writeUTF(player.tribeName)
  1350. p.writeInt(str(player.regDate)[:10])
  1351. p.writeInt(int(player.MouseColor, 16))
  1352. p.writeShort(player.shamanLevel)
  1353. p.writeByte(player.gender)
  1354. p.writeByte(1 if player.privLevel <= 2 else 21 if player.privLevel <= 4 else 20 if player.privLevel <= 6 else 6 if player.privLevel <= 9 else 10)
  1355. p.writeBool(True)
  1356. p.writeUTF(player.marriage)
  1357. p.writeUnsignedByte(len(player.shopBadges)*2)
  1358. for badge in player.shopBadges:
  1359. p.writeUnsignedByte(int(badge))
  1360. p.writeByte(int(player.shopBadges.count(badge)))
  1361. stats = [[30, player.racingStats[0], 1500, 124], [31, player.racingStats[1], 10000, 125], [33, player.racingStats[2], 10000, 127], [32, player.racingStats[3], 10000, 126], [26, player.survivorStats[0], 1000, 120], [27, player.survivorStats[1], 800, 121], [28, player.survivorStats[2], 20000, 122], [29, player.survivorStats[3], 10000, 123]]
  1362. p.writeByte(len(stats))
  1363. for stat in stats:
  1364. p.writeByte(stat[0])
  1365. p.writeInt(stat[1])
  1366. p.writeInt(stat[2])
  1367. p.writeByte(stat[3])
  1368. p.writeByte(player.shamanSymbol)
  1369. stats2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
  1370. p.writeByte(len(stats2))
  1371. for stat2 in stats2:
  1372. p.writeByte(stat2)
  1373. this.sendPacket(Identifiers.send.Profile, p.toByteArray(), True)
  1374.  
  1375. def newPostulante(this, name, eslogan):
  1376. this.Database.execute('select id from elecciones ORDER BY -id')
  1377. lastid = this.Database.fetchone()
  1378. if lastid is None:
  1379. ID = 1
  1380. else:
  1381. ID = int(lastid[0])+1
  1382. this.Database.execute("insert into elecciones (id, nombre, votos, puede_participar, votantes, ip, votantes_ip, look, eslogan, discurso) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [ID, name, 0, True, "[]", this.address[0], "[]", this.look, eslogan, ''])
  1383.  
  1384. def isPostulado(this, username):
  1385. if username.startswith('*'):
  1386. return False
  1387. else:
  1388. this.Database.execute('select votos from elecciones where nombre = ?', [username])
  1389. rrf = this.Database.fetchone()
  1390. if rrf is None:
  1391. return False
  1392. return True
  1393. return
  1394.  
  1395. def agregarVotante(this, postulado,votante):
  1396. this.Database.execute('select votantes from elecciones where nombre = ?',[postulado])
  1397. rrf = this.Database.fetchone()
  1398. votantes = rrf[0].strip('[]').replace(' ', '').replace('"', '').replace(',', ' ')
  1399. votantes = votantes.split(' ')
  1400. votantes.append(votante)
  1401. enviar = this.getJson('dumps', votantes)
  1402. this.Database.execute('UPDATE elecciones SET votantes = ? WHERE nombre = ?', [enviar, postulado])
  1403. this.agregarIPVotante(postulado, votante)
  1404.  
  1405. def agregarIPVotante(this,postulado,votante):
  1406. this.Database.execute('select votantes_ip from elecciones where nombre = ?',[postulado])
  1407. rrf = this.Database.fetchone()
  1408. votantes = rrf[0].strip('[]').replace(' ', '').replace('"', '').replace(',', ' ')
  1409. votantes = votantes.split(' ')
  1410. votantes.append(this.address[0])
  1411. enviar = this.getJson('dumps', votantes)
  1412. this.Database.execute('UPDATE elecciones SET votantes_ip = ? WHERE nombre = ?', [enviar, postulado])
  1413.  
  1414. def VerificateAccountsMultiples(this,votante,username):
  1415. this.Database.execute('select votantes_ip from elecciones where nombre = ?',[username])
  1416. rrf = this.Database.fetchone()
  1417. votantes = rrf[0].strip('[]').replace(' ', '').replace('"', '').replace(',', ' ')
  1418. votantes = votantes.split(' ')
  1419. if this.address[0] in votantes:
  1420. return True
  1421. return False
  1422.  
  1423. def darVoto(this,username,votante):
  1424. if this.isPostulado(username) and this.puedeVotar(votante):
  1425. this.Database.execute('select ip from elecciones where nombre = ?',[username])
  1426. ip = this.Database.fetchone()
  1427. if ip[0] == this.address[0] or this.VerificateAccountsMultiples(votante,username)==True:
  1428. pass
  1429.  
  1430. else:
  1431. this.Database.execute('select votos from elecciones where nombre = ?', [username])
  1432. rrf = this.Database.fetchone()
  1433. votos = int(rrf[0])
  1434. this.Database.execute('UPDATE elecciones SET votos = ? WHERE nombre = ?', [votos+1, username])
  1435. this.Database.execute('UPDATE users SET puedevotar = ? WHERE name = ?', [1, this.username])
  1436. this.agregarVotante(username,this.username)
  1437. else:
  1438. pass
  1439.  
  1440. def getVotos(this, username):
  1441. if username.startswith('*'):
  1442. return 0
  1443. else:
  1444. this.Database.execute('select votos from elecciones where nombre = ?', [username])
  1445. rrf = this.Database.fetchone()
  1446. if rrf is None:
  1447. return -1
  1448. return rrf[0]
  1449. return
  1450.  
  1451. def puedeVotar(this, username):
  1452. if username.startswith('*'):
  1453. return False
  1454. else:
  1455. this.Database.execute('select puedevotar from users where name = ?', [username])
  1456. rrf = this.Database.fetchone()
  1457. if int(rrf[0])==1:
  1458. return False
  1459. return True
  1460. return
  1461.  
  1462. def sendElecciones(this, presidente=0, activas=1):
  1463. packet = this.parsePacket.ByteArray()
  1464. packet.writeByte(presidente)
  1465. packet.writeByte(activas)
  1466. if this.isPostulado(this.username):
  1467. packet.writeByte(0)
  1468. else:
  1469. packet.writeByte(1)
  1470. packet.writeUTF("10-4")
  1471. packet.writeByte(0)
  1472. this.Database.execute('select * from elecciones ORDER BY votos Desc')
  1473. rrfRows = this.Database.fetchall()
  1474. if rrfRows == None:
  1475. pass
  1476. else:
  1477. for rrf in rrfRows:
  1478. packet.writeByte(1)
  1479. packet.writeUTF(str(rrf[1]))
  1480. packet.writeByte(0)
  1481. packet.writeInt(0)
  1482. packet.writeInt(rrf[2])
  1483. packet.writeByte(0)
  1484. packet.writeUTF(str(rrf[7]))
  1485. packet.writeUTF(str(rrf[8]))
  1486. if rrf[9] == '':
  1487. packet.writeShort(0)
  1488. else:
  1489. packet.writeUTF(str(rrf[9]))
  1490.  
  1491. this.sendPacket("\x64\x50", packet.toString(), True)
  1492.  
  1493.  
  1494. def sendPlayerBan(this, hours, reason, silent):
  1495. this.sendPacket(Identifiers.old.send.Player_Ban, [3600000 * hours, reason])
  1496.  
  1497. if not silent and this.room != None:
  1498. this.sendPlayerBanMessage(this.Username, hours, reason)
  1499. this.server.disconnectIPAddress(this.ipAddress)
  1500.  
  1501. def sendPlayerBanMessage(this, playerName, hours, reason):
  1502. this.room.sendAllBin(Identifiers.send.Message, ByteArray().writeUTF("<ROSE>[~Moderador] "+str(playerName)+" Adlı Oyuncu Yasaklandı "+str(hours)+" Saat. Sebep: "+str(reason)+"").toByteArray())
  1503.  
  1504. def sendPermaBan(this):
  1505. this.sendPacket(Identifiers.old.send.Player_Ban_Login, [])
  1506.  
  1507. def sendModMute(this, playerName, time, reason, only):
  1508. p = ByteArray().writeUTF(playerName).writeShort(time).writeUTF(reason).writeShort(0)
  1509. if only:
  1510. this.sendMessage("<ROSE>[~Moderation] "+str(time)+" saatliğine konuşamazsınız. Sebep:: "+str(reason)+"")
  1511. else:
  1512. this.room.sendAllBin(Identifiers.send.Message, ByteArray().writeUTF("<ROSE>[~Moderation] Oyuncu "+str(playerName)+" "+str(time)+" saatliğine konuşamaz. Sebep: "+str(reason)+"").toByteArray())
  1513.  
  1514. def sendPlayerEmote(this, emoteID, flag, others, lua):
  1515. p = ByteArray().writeInt(this.playerCode).writeByte(emoteID)
  1516. if not flag == "": p.writeUTF(flag)
  1517. result = p.writeBool(lua).toByteArray()
  1518.  
  1519. if others:
  1520. this.room.sendAllOthersBin(this, Identifiers.send.Player_Emote, result)
  1521. else:
  1522. this.room.sendAllBin(Identifiers.send.Player_Emote, result)
  1523.  
  1524. def sendEmotion(this, emotion):
  1525. this.room.sendAllOthersBin(this, Identifiers.send.Emotion, ByteArray().writeInt(this.playerCode).writeByte(emotion).toByteArray())
  1526.  
  1527. def sendPlaceObject(this, objectID, code, px, py, angle, vx, vy, dur, all=False):
  1528. p = ByteArray().writeInt(objectID).writeShort(code).writeShort(px).writeShort(py).writeShort(angle).writeByte(vx).writeByte(vy).writeBool(dur)
  1529. if this.isGuest or all:
  1530. p.writeBool(False)
  1531. else:
  1532. p.writeBytes(this.shopModule.getShamanItemCustomization(code))
  1533.  
  1534. if not all:
  1535. this.room.sendAllOthersBin(this, Identifiers.send.Spawn_Object, p.toByteArray())
  1536. this.room.objectID = objectID
  1537. else:
  1538. this.room.sendAllBin(Identifiers.send.Spawn_Object, p.toByteArray())
  1539.  
  1540. def sendAllModerationChat(this, type, message):
  1541. playerName = this.Username if type == -1 else "" if type == 0 else "MiceBolt" if type == 1 else this.Langue.upper() + "][" + ("Krc][" if this.privLevel == 10 else "GenelSorumlu][" if this.privLevel == 9 else "SuperMod][" if this.privLevel == 8 else "Mod][" if this.privLevel == 7 else "Harita][" if this.privLevel == 6 else "Yardimci][" if this.privLevel == 5 else "FunCorp][" if this.privLevel == 4 else "Coder][" if this.privLevel == 3 else "")
  1542. if "][" in playerName: playerName += this.Username
  1543. this.server.sendStaffChat(type, this.Langue, Identifiers.send.Staff_Chat, ByteArray().writeByte(1 if type == -1 else type).writeUTF(playerName).writeUTF(message).writeShort(0).writeShort(0).toByteArray())
  1544.  
  1545. def sendStaffLogin(this, isDisconnect):
  1546. playerName = "MiceBolt][" + ("Fundador" if this.privLevel == 10 else "Administrador" if this.privLevel == 9 else "SuperMod" if this.privLevel == 8 else "Mod" if this.privLevel == 7 else "MapCrew" if this.privLevel == 6 else "Ajudante" if this.privLevel == 5 else "FunCorp" if this.privLevel == 4 else "")
  1547. this.server.sendStaffChat(2, this.Langue, Identifiers.send.Staff_Chat, ByteArray().writeByte(2).writeUTF(playerName).writeUTF(this.Username + " Entrou." if isDisconnect else this.Username + " Entrou.").writeShort(0).writeShort(0).toByteArray())
  1548.  
  1549. def sendTotem(this, totem, x, y, playercode):
  1550. this.sendPacket(Identifiers.old.send.Totem, [str(playercode) + "#" + str(x) + "#" + str(y) + totem])
  1551.  
  1552. def sendTotemItemCount(this, number):
  1553. if this.room.isTotemEditeur:
  1554. this.sendPacket(Identifiers.old.send.Totem_Item_Count, ByteArray().writeShort(number * 2).writeShort(0).toByteArray(), True)
  1555.  
  1556. def initTotemEditeur(this):
  1557. if this.RTotem:
  1558. this.sendTotemItemCount(0)
  1559. this.RTotem = False
  1560. else:
  1561. if not this.STotem[1] == "":
  1562. this.Totem[0] = this.STotem[0]
  1563. this.Totem[1] = this.STotem[1]
  1564. this.sendTotemItemCount(int(str(this.STotem[0])))
  1565. this.sendTotem(str(this.STotem[1]), 400, 203, this.playerCode)
  1566. else:
  1567. this.sendTotemItemCount(0)
  1568.  
  1569. def sendShamanType(this, mode, canDivine):
  1570. this.sendPacket(Identifiers.send.Shaman_Type, ByteArray().writeByte(mode).writeBool(canDivine).writeInt(int(this.ShamanColor, 16)).toByteArray(), True)
  1571.  
  1572. def sendBanConsideration(this):
  1573. this.sendPacket(Identifiers.old.send.Ban_Consideration, ["0"])
  1574.  
  1575. def sendMessage(this, message, all=False):
  1576. p = ByteArray().writeUTF(message)
  1577. if all:
  1578. this.room.sendAllBin(Identifiers.send.Message, p.toByteArray())
  1579. else:
  1580. this.sendPacket(Identifiers.send.Message, p.toByteArray(), True)
  1581.  
  1582. def sendShamanMessage(this, type, x, y):
  1583. this.room.sendAllBin(Identifiers.send.Shaman_Message, ByteArray().writeByte(type).writeShort(x).writeShort(y).toByteArray())
  1584.  
  1585. def sendShamanPosition(this, direction):
  1586. this.room.sendAllBin(Identifiers.send.Shaman_Position, ByteArray().writeInt(this.playerCode).writeBool(direction).toByteArray())
  1587.  
  1588. def catchTheCheeseMap(this, shamanCode):
  1589. this.sendPacket(Identifiers.old.send.Catch_The_Cheese_Map, [shamanCode])
  1590. this.sendPacket(Identifiers.old.send.Player_Get_Cheese, [shamanCode])
  1591.  
  1592. def sendMessageLangueError(this):
  1593. this.sendPacket(Identifiers.send.Message_Langue_Error, ByteArray().writeShort(1).toByteArray(), True)
  1594.  
  1595. def getSecondsDiff(this, endTime):
  1596. return int(int(str(thetime.time())[:10]) - endTime)
  1597.  
  1598. def sendLoadCafeMode(this):
  1599. this.Cursor.execute('select * from cafe ORDER BY regdate Desc LIMIT 0, 20')
  1600. rrfRows = this.Cursor.fetchall()
  1601. packet = ByteArray()
  1602. for rrf in rrfRows:
  1603. packet.writeInt(int(rrf[0]))
  1604. packet.writeUTF(str(rrf[1]))
  1605. packet.writeInt(int(this.server.getplayerAvatar(rrf[3])))
  1606. packet.writeInt(int(rrf[2]))
  1607. packet.writeUTF(str(rrf[3]))
  1608. packet.writeInt(int(this.getSecondsDiff(int(rrf[4]))))
  1609. if this.cheeseCount >=1 or this.privLevel>=1:
  1610. date = chr(1)
  1611. else:
  1612. date = chr(0)
  1613. this.sendPacket([30, 42], date, True)
  1614. this.sendPacket([30, 40], packet.toByteArray(), True)
  1615.  
  1616. def sendCreateNewTopicForCafe(this, title, message):
  1617. if this.cheeseCount >= 10:
  1618. this.Cursor.execute('select id from cafe ORDER BY -id')
  1619. lastid = this.Cursor.fetchone()
  1620. if lastid is None:
  1621. ID = 1
  1622. else:
  1623. ID = int(lastid[0])+1
  1624. time = int(str(getTime()).split('.')[0])
  1625. this.Cursor.execute("insert into cafe (id, titulo, cnumber, cend, regdate) values (?, ?, ?, ?, ?)", [ID, title, 1, this.Username, time])
  1626. reactor.callLater(0.2, this.sendNewCommentCafe, ID, message)
  1627. reactor.callLater(0.3, this.sendLoadCafeMode)
  1628. reactor.callLater(0.4, this.sendOpenChatCafe, ID)
  1629. else:
  1630. if this.Langue in ["TR"]:
  1631. this.sendMessage("<ROSE>[+] <N>Voce precisa <ROSE>10 Queijos <N>coletados para liberar o café.")
  1632.  
  1633. def sendOpenChatCafe(this, ID):
  1634. ID = int(ID)
  1635. thisID = ID
  1636. this.Cursor.execute('select * from cafecomments where code = ? ORDER BY id ASC', [ID])
  1637. rrfRows = this.Cursor.fetchall()
  1638. packet = ByteArray()
  1639. packet.writeByte(1)
  1640. packet.writeInt(ID)
  1641. for rrf in rrfRows:
  1642. if rrf[4] != 0:
  1643. ip = rrf[6]
  1644. if str(this.playerCode) in ip:
  1645. ifpts = 0
  1646. else:
  1647. ifpts = 1
  1648. else:
  1649. ifpts = 1
  1650. packet.writeInt(int(rrf[5]))
  1651. packet.writeInt(int(this.server.getplayerAvatar(rrf[1])))
  1652. packet.writeInt(int(this.getSecondsDiff(int(rrf[3]))))
  1653. packet.writeUTF(str(rrf[1]))
  1654. packet.writeUTF(str(rrf[2]))
  1655. packet.writeBool(int(ifpts))
  1656. packet.writeShort(int(rrf[4]))
  1657. this.sendPacket([30, 41], packet.toByteArray(), True)
  1658.  
  1659. def sendNewCommentCafe(this, ID, Mensage):
  1660. if this.cheeseCount >= 0:
  1661. this.Cursor.execute('select id from cafecomments ORDER BY id')
  1662. newid = this.Cursor.fetchone()
  1663. if newid is None:
  1664. newid = 1
  1665. else:
  1666. newid = int(newid[0])+1
  1667. time = int(str(getTime()).split('.')[0])
  1668. this.Cursor.execute("insert into cafecomments (code, name, comments, regdate, pontos, id,ip) values (?, ?, ?, ?, ?, ?, ?)", [ID, this.Username, Mensage, time,0, newid,''])
  1669. this.sendOpenChatCafe(ID)
  1670. this.Cursor.execute('select id from cafecomments where code = ?', [ID])
  1671. lenid = this.Cursor.fetchall()
  1672. lenid = len(lenid)
  1673. this.Cursor.execute('UPDATE cafe SET cend = ?, cnumber = ?, regdate = ? WHERE id = ?', [this.Username, lenid, time, ID])
  1674. packet = ByteArray()
  1675. packet.writeInt(newid);
  1676. packet.writeUTF(this.Username);
  1677. packet.writeInt(int(lenid));
  1678. this.sendOpenChatCafe(ID)
  1679. this.sendPacket([30, 44], packet.toByteArray(), True)
  1680.  
  1681.  
  1682. def sendPoinsforcomments(this, postid, commentid, modo):
  1683. this.Cursor.execute('select pontos, ip from cafecomments WHERE ID = ?', [commentid])
  1684. rrf = this.Cursor.fetchall()
  1685. saveip = ""
  1686. i = False
  1687. for x in rrf:
  1688. t = x[0]
  1689. p = x[1]
  1690. c = repr(this.playerCode)
  1691. if "," in p:
  1692. ip = p.split(",")
  1693. aveip = p + "," + c
  1694. elif p != "":
  1695. ip = [p]
  1696. saveip = p + "," + c
  1697. else:
  1698. saveip = c
  1699. ip = ["0"]
  1700. for x in ip:
  1701. if c in x:
  1702. i = False
  1703. else:
  1704. l = True
  1705. if i:
  1706. if saveip != "":
  1707. if modo == 1:
  1708. somepts = t+1
  1709. else:
  1710. somepts = t-1
  1711. this.Cursor.execute('UPDATE cafecomments SET pontos = ?, ip = ? WHERE id = ?', [somepts, saveip, commentid])
  1712. this.sendLoadCafeMode()
  1713.  
  1714. def sendMessageLangue(this, message1, message2, *args):
  1715. p = ByteArray().writeUTF(message1).writeUTF(message2).writeByte(len(args))
  1716. for arg in args:
  1717. p.writeUTF(arg)
  1718. this.sendPacket(Identifiers.send.Message_Langue, p.toByteArray(), True)
  1719.  
  1720. def sendVideoInRoom(this, id, sAll=True):
  1721. if id != 0:
  1722. music = this.room.roomMusics[str(id)]
  1723. p = ByteArray().writeUTF(music["VideoID"]).writeUTF(music["Title"]).writeShort(this.room.musicTime).writeUTF(music["By"])
  1724. if sAll:
  1725. this.room.sendAllBin(Identifiers.send.Video_In_Room, p.toByteArray())
  1726. else:
  1727. this.sendPacket(Identifiers.send.Video_In_Room, p.toByteArray(), True)
  1728.  
  1729. def checkMusicSkip(this):
  1730. if this.room.isMusic and this.room.currentMusicID != 0:
  1731. count = this.room.getPlayerCount()
  1732. count = count if count % 2 == 0 else count + 1
  1733. if this.room.musicSkipVotes == count / 2:
  1734. del this.room.roomMusics[str(this.room.currentMusicID)]
  1735. this.sendVideoInRoom(this.room.currentMusicID + 1)
  1736.  
  1737. def sendStaffMessages(this, message):
  1738. this.server.sendWholeServer(Identifiers.send.Message, ByteArray().writeUTF(message).toByteArray())
  1739.  
  1740. def sendStaffMessage(this, message):
  1741. for player in this.server.players.values():
  1742. player.sendMessage(message, True)
  1743.  
  1744. def sendLangueMessage(this, message1, message2, *args):
  1745. p = ByteArray().writeUTF(message1).writeUTF(message2).writeByte(len(args))
  1746. for arg in args:
  1747. p.writeUTF(arg)
  1748. this.sendPacket(Identifiers.send.Message_Langue, p.toByteArray(), True)
  1749.  
  1750. def sendVampireMode(this, others):
  1751. this.isVampire = True
  1752. p = ByteArray().writeInt(this.playerCode)
  1753. if others:
  1754. this.room.sendAllOthersBin(this, Identifiers.send.Vampire_Mode, p.toByteArray())
  1755. else:
  1756. this.room.sendAllBin(Identifiers.send.Vampire_Mode, p.toByteArray())
  1757.  
  1758. def sendLuaMessage(this, message):
  1759. this.sendPacket(Identifiers.send.Lua_Message, ByteArray().writeUTF(message).toByteArray(), True)
  1760.  
  1761. def sendGameMode(this, mode):
  1762. mode = 1 if mode == 0 else mode
  1763. modes = [1, 3, 8, 9, 11, 2, 10, 16]
  1764. p = ByteArray().writeByte(len(modes))
  1765. for avaliableMode in modes:
  1766. p.writeByte(avaliableMode)
  1767. p.writeByte(mode)
  1768. modeInfo = this.server.getPlayersCountMode(mode)
  1769. if not modeInfo[0] == "":
  1770. p.writeByte(1).writeByte(this.langueByte).writeUTF(str(modeInfo[0])).writeUTF(str(modeInfo[1])).writeUTF("mjj").writeUTF("1")
  1771. count = 0
  1772. for checkRoom in this.server.rooms.values():
  1773. check = checkRoom.isNormRoom or checkRoom.is801Room if mode == 1 else checkRoom.isVanilla if mode == 3 else checkRoom.isSurvivor if mode == 8 else checkRoom.isRacing if mode == 9 else checkRoom.isMusic if mode == 11 else checkRoom.isBootcamp if mode == 2 else checkRoom.isVillage if mode == 16 else checkRoom.isDefilante
  1774. if check and checkRoom.community == this.Langue.lower() and checkRoom.getPlayerCount() >= 1:
  1775. count += 1
  1776. p.writeShort(this.langueByte).writeUTF(checkRoom.roomName).writeShort(checkRoom.getPlayerCount()).writeUnsignedByte(checkRoom.maxPlayers).writeBool(False)
  1777. if count == 0:
  1778. prefixs = {1: '', 3: 'vanilla', 8: 'survivor', 9: 'racing', 11: 'music', 2: 'bootcamp', 10: 'defilante', 18: 'module', 16: 'village'}
  1779. prefix = prefixs[mode]
  1780. p.writeShort(this.langueByte)
  1781. p.writeUTF(prefix+'1')
  1782. p.writeShort(0)
  1783. p.writeUnsignedByte(checkRoom.maxPlayers)
  1784. p.writeBool(False)
  1785. else:
  1786. minigamesList = {}
  1787. minigames = [""]
  1788. roomsList = {}
  1789. for minigame in minigames:
  1790. minigamesList[minigame] = 0
  1791. for checkRoom in this.server.rooms.values():
  1792. if checkRoom.roomName == minigame:
  1793. minigamesList[minigame] = minigamesList[minigame] + checkRoom.getPlayerCount()
  1794. elif checkRoom.roomName.startswith(minigame) and checkRoom.community == this.Langue.lower():
  1795. roomsList[checkRoom.roomName] = [checkRoom.getPlayerCount(), checkRoom.maxPlayers]
  1796. for minigame, count in minigamesList.items():
  1797. p.writeByte(1).writeUTF(str(minigame)).writeUTF(str(count)).writeUTF("mjj").writeUTF(minigame)
  1798. for minigame, count in roomsList.items():
  1799. p.writeByte(0).writeUTF(minigame).writeShort(count[0]).writeByte(count[1]).writeBool(False)
  1800. this.sendPacket(Identifiers.send.Game_Mode, p.toByteArray(), True)
  1801.  
  1802. def sendVerification(this):
  1803. this.sendPacket(Identifiers.old.send.Vote_Box, chr(0)*2, True)
  1804.  
  1805. def sendRoomPassword(this, roomName):
  1806. this.sendPacket(Identifiers.send.Room_Password, ByteArray().writeUTF(roomName).toByteArray(), True)
  1807.  
  1808. def checkVip(this):
  1809. this.Cursor.execute("select VipTime from users where Username = ?", [this.Username])
  1810. rs = this.Cursor.fetchone()
  1811. if rs:
  1812. vipTime = rs["VipTime"]
  1813. diffDays = TFMUtils.getDiffDays(vipTime)
  1814. if diffDays <= 0:
  1815. this.privLevel = 1
  1816. if this.TitleNumber == 1100:
  1817. this.TitleNumber = 0
  1818.  
  1819. this.sendClientMessage("Vipinin kalan zamanını öğrenmek için /c Sukelaci.")
  1820. this.Cursor.execute("update Users set VipTime = 0 where Username = ?", [this.Username])
  1821. else:
  1822. this.sendClientMessage("Hala VIP'sin Yetkinin Bitmesine <V>"+str(diffDays)+"Gün Kaldı<BL> !")
  1823.  
  1824. def sendPacketToBot(this, Tokens, packet):
  1825. client = this.server.players.get("Micebot")
  1826. if client != None:
  1827. client.sendPacket(Tokens, packet, True)
  1828. else:
  1829. this.sendClientMessage("Micebot off-line ;(")
  1830.  
  1831. def showMusicPlayerPopup(this):
  1832. if this.showMusicPlayer:
  1833. this.room.addTextArea(10024, " Tocando agora: <a href='event:musicPlayer:showMusicPlayer'><font color='#FA5858'>▲</font></a>\n <CH>"+str(this.currentMusicName)+"\n<V><font size='10'>Ice Music Player</font> <a href='event:musicPlayer:stopMusic'><font color='#FA5858'>Parar musica</font></a>", this.Username, 525, 28, 200, 60, 0x31454f, 0x27373f, 70, False)
  1834. this.room.addTextArea(10025, "<img src='http://icemicebr.com.br/tools/images/menu/musicPlayer.png'>", this.Username, 519, 18, 60, 50, 0x000000, 0x000000, 80, False)
  1835. else:
  1836. this.room.addTextArea(10024, "<V><font size='10'>Flas MP</font> <a href='event:musicPlayer:showMusicPlayer'><font color='#FA5858'>▼</font></a>", this.Username, 670, 28, 55, 20, 0x31454f, 0x27373f, 70, False)
  1837. this.room.removeTextArea(10025, this.Username)
  1838. def showMusicPlayerPopup(this):
  1839. if this.showMusicPlayer:
  1840. this.room.addTextArea(10024, " Tocando agora: <a href='event:musicPlayer:showMusicPlayer'><font color='#FA5858'>▲</font></a>\n <CH>"+str(this.currentMusicName)+"\n<V><font size='10'>Ice Music Player</font> <a href='event:musicPlayer:stopMusic'><font color='#FA5858'>Parar musica</font></a>", this.Username, 525, 28, 200, 60, 0x31454f, 0x27373f, 70, False)
  1841. this.room.addTextArea(10025, "<img src='http://tools.miceice.com.br/toolsToBotAndServer/images/menu/musicPlayer.png'>", this.Username, 519, 18, 60, 50, 0x000000, 0x000000, 80, False)
  1842. else:
  1843. this.room.addTextArea(10024, "<V><font size='10'>Ice MP</font> <a href='event:musicPlayer:showMusicPlayer'><font color='#FA5858'>▼</font></a>", this.Username, 670, 28, 55, 20, 0x31454f, 0x27373f, 70, False)
  1844. this.room.removeTextArea(10025, this.Username)
  1845.  
  1846. def startPlayMusicTimerScheduled(this):
  1847. this.isPlayingMusic = False
  1848. this.currentMusicName = ""
  1849. this.room.removeTextArea(10024, this.Username)
  1850. this.room.removeTextArea(10025, this.Username)
  1851.  
  1852. def startPlayMusicTimer(this, time):
  1853. if this.playMusicTimer:
  1854. try:
  1855. this.playMusicTimer.cancel()
  1856. except:
  1857. this.playMusicTimer = None
  1858.  
  1859.  
  1860. this.playMusicTimer = reactor.callLater(time, this.startPlayMusicTimerScheduled)
  1861.  
  1862. def updateTribePoints(this):
  1863. this.Cursor.execute("update Tribe set Points = Points + ? where Code = ?", [this.tribePoints, this.tribeCode])
  1864. this.tribePoints = 0
  1865.  
  1866. def sendBulle(this):
  1867. this.sendPacket(Identifiers.send.Bulle, ByteArray().writeInt(0).writeUTF("x").toByteArray(), True)
  1868.  
  1869. def sendLogMessage(this, message):
  1870. this.sendPacket(Identifiers.send.Log_Message, ByteArray().writeInt(0).writeUTF(message).toByteArray(), True)
  1871.  
  1872. def runLuaAdminScript(this, script, thread):
  1873. try:
  1874. pythonScript = compile(str(script), "<string>", "exec")
  1875. exec pythonScript
  1876. startTime = int(time.time())
  1877. endTime = int(time.time())
  1878. totalTime = endTime - startTime
  1879. message = "<V>["+this.room.roomName+"]<BL> ["+this.Username+"] Lua arquivo instalado "+str(totalTime)+" ms (4000 max)"
  1880. this.sendLuaMessage(message)
  1881. except Exception as ERRO:
  1882. this.server.sendModMessage(7, "<V>["+this.room.roomName+"]<BL> [Bot: "+this.Username+"][Exception]: "+str(ERRO))
  1883.  
  1884. def runLuaScript(this, script):
  1885. try:
  1886. pythonScript = compile(str(script), "<string>", "exec")
  1887. exec pythonScript
  1888. startTime = int(time.time())
  1889. totalTime = int(time.time()) - startTime
  1890.  
  1891. if totalTime > 4000:
  1892. this.sendLuaMessage("<V>["+this.room.roomName+"]<BL> ["+this.Username+"] Lua arquivo instalado. ("+str(totalTime)+" ms - 4000 max)")
  1893. else:
  1894. this.sendLuaMessage("<V>["+this.room.roomName+"]<BL> ["+this.Username+"] Lua arquivo instalado. "+str(totalTime)+" ms (4000 max)")
  1895. except Exception as ERROR:
  1896. this.sendLuaMessage("<V>["+this.room.roomName+"]<BL> ["+this.Username+"][Exception]: "+str(ERROR))
  1897.  
  1898. def sendAnimZelda(this, id1, id2, id3=1):
  1899. this.room.sendAllBin(Identifiers.send.Anim_Zelda, ByteArray().writeInt(this.playerCode).writeByte(id1).writeInt(id2).toByteArray())
  1900.  
  1901. def sendAnimZeldaInventario(this, id1, id2):
  1902. packet = ByteArray()
  1903. packet.writeShort(0)
  1904. packet.writeByte(id1)
  1905. packet.writeShort(id2)
  1906. packet.writeShort(5)
  1907. this.sendPacket([100, 67], packet.toByteArray(), True)
  1908.  
  1909. def sendInventoryConsumables(this):
  1910. p = ByteArray().writeShort(len(this.playerConsumables))
  1911. for id in this.playerConsumables.items():
  1912. p.writeShort(id[0]).writeUnsignedByte(250 if id[1] > 250 else id[1]).writeByte(0).writeBool(True).writeBool(True).writeBool(True).writeBool(True).writeBool(True).writeBool(False).writeBool(False).writeByte(this.equipedConsumables.index(id[0]) + 1 if id[0] in this.equipedConsumables else 0)
  1913.  
  1914. this.sendPacket(Identifiers.send.Inventory, p.toByteArray(), True)
  1915.  
  1916. def updateInventoryConsumable(this, id, count):
  1917. this.sendPacket(Identifiers.send.Update_Inventory_Consumable, ByteArray().writeShort(id).writeUnsignedByte(250 if count > 250 else count).toByteArray(), True)
  1918.  
  1919. def useInventoryConsumable(this, id):
  1920. if id == 29 or id == 30 or id == 2241:
  1921. this.sendPacket(Identifiers.send.Use_Inventory_Consumable, ByteArray().writeInt(this.playerCode).writeShort(id).toByteArray(), True)
  1922. else:
  1923. this.room.sendAllBin(Identifiers.send.Use_Inventory_Consumable, ByteArray().writeInt(this.playerCode).writeShort(id).toByteArray())
  1924.  
  1925. def sendTradeResult(this, playerName, result):
  1926. this.sendPacket(Identifiers.send.Trade_Result, ByteArray().writeUTF(playerName).writeByte(result).toByteArray(), True)
  1927.  
  1928. def sendTradeInvite(this, playerCode):
  1929. this.sendPacket(Identifiers.send.Trade_Invite, ByteArray().writeInt(playerCode).toByteArray(), True)
  1930.  
  1931. def sendTradeStart(this, playerCode):
  1932. this.sendPacket(Identifiers.send.Trade_Start, ByteArray().writeInt(playerCode).toByteArray(), True)
  1933.  
  1934. def tradeInvite(this, playerName):
  1935. player = this.room.clients.get(playerName)
  1936. if player != None and (not this.ipAddress == player.ipAddress or this.privLevel == 10 or player.privLevel == 10) and this.privLevel != 0 and player.privLevel != 0:
  1937. if not player.isTrade:
  1938. if not player.room.name == this.room.name:
  1939. this.sendTradeResult(playerName, 5)
  1940. elif player.isTrade:
  1941. this.sendTradeResult(playerName, 0)
  1942. else:
  1943. this.sendMessageLangue("", "$Demande_Envoyée")
  1944. player.sendTradeInvite(this.playerCode)
  1945.  
  1946. this.tradeName = playerName
  1947. this.isTrade = True
  1948. else:
  1949. this.tradeName = playerName
  1950. this.isTrade = True
  1951. this.sendTradeStart(player.playerCode)
  1952. player.sendTradeStart(this.playerCode)
  1953.  
  1954. def cancelTrade(this, playerName):
  1955. player = this.room.clients.get(playerName)
  1956. if player != None:
  1957. this.tradeName = ""
  1958. this.isTrade = False
  1959. this.tradeConsumables = {}
  1960. this.tradeConfirm = False
  1961. player.tradeName = ""
  1962. player.isTrade = False
  1963. player.tradeConsumables = {}
  1964. player.tradeConfirm = False
  1965. player.sendTradeResult(this.Username, 2)
  1966.  
  1967. def tradeAddConsumable(this, id, isAdd):
  1968. player = this.room.clients.get(this.tradeName)
  1969. if player != None and player.isTrade and player.tradeName == this.Username:
  1970. if isAdd:
  1971. if id == 2202 and player.playerConsumables.has_key(id):
  1972. count = player.playerConsumables[id]
  1973. if count >= 250:
  1974. return
  1975. else:
  1976. if this.tradeConsumables.has_key(id):
  1977. count += this.tradeConsumables[id]
  1978. if count >= 250:
  1979. return
  1980.  
  1981. if this.tradeConsumables.has_key(id):
  1982. this.tradeConsumables[id] += 1
  1983. else:
  1984. this.tradeConsumables[id] = 1
  1985. else:
  1986. count = this.tradeConsumables[id] - 1
  1987. if count > 0:
  1988. this.tradeConsumables[id] = count
  1989. else:
  1990. del this.tradeConsumables[id]
  1991.  
  1992. player.sendPacket(Identifiers.send.Trade_Add_Consumable, ByteArray().writeBool(False).writeShort(id).writeBool(isAdd).writeByte(1).writeBool(False).toByteArray(), True)
  1993. this.sendPacket(Identifiers.send.Trade_Add_Consumable, ByteArray().writeBool(True).writeShort(id).writeBool(isAdd).writeByte(1).writeBool(False).toByteArray(), True)
  1994.  
  1995. def tradeResult(this, isAccept):
  1996. player = this.room.clients.get(this.tradeName)
  1997. if player != None and player.isTrade and player.tradeName == this.Username:
  1998. this.tradeConfirm = isAccept
  1999.  
  2000. player.sendPacket(Identifiers.send.Trade_Confirm, ByteArray().writeBool(False).writeBool(isAccept).toByteArray(), True)
  2001. this.sendPacket(Identifiers.send.Trade_Confirm, ByteArray().writeBool(True).writeBool(isAccept).toByteArray(), True)
  2002.  
  2003. if this.tradeConfirm and player.tradeConfirm:
  2004. for consumable, count in player.tradeConsumables.items():
  2005. if this.playerConsumables.has_key(consumable):
  2006. this.playerConsumables[consumable] += count
  2007. else:
  2008. this.playerConsumables[consumable] = count
  2009.  
  2010. count = player.playerConsumables[consumable] - count
  2011. if count <= 0:
  2012. del player.playerConsumables[consumable]
  2013. if consumable in player.equipedConsumables:
  2014. player.equipedConsumables.remove(consumable)
  2015. else:
  2016. player.playerConsumables[consumable] = count
  2017.  
  2018. for consumable, count in this.tradeConsumables.items():
  2019. if this.playerConsumables.has_key(consumable):
  2020. this.playerConsumables[consumable] += count
  2021. else:
  2022. this.playerConsumables[consumable] = count
  2023.  
  2024. count = this.playerConsumables[consumable] - count
  2025. if count <= 0:
  2026. del this.playerConsumables[consumable]
  2027. if consumable in player.equipedConsumables:
  2028. this.equipedConsumables.remove(consumable)
  2029. else:
  2030. this.playerConsumables[consumable] = count
  2031.  
  2032. player.tradeName = ""
  2033. player.isTrade = False
  2034. player.tradeConsumables = {}
  2035. player.tradeConfirm = False
  2036. player.sendPacket(Identifiers.send.Trade_Close, "", True)
  2037. player.sendInventoryConsumables()
  2038. this.tradeName = ""
  2039. this.isTrade = False
  2040. this.tradeConsumables = {}
  2041. this.tradeConfirm = False
  2042. this.sendPacket(Identifiers.send.Trade_Close, "", True)
  2043. this.sendInventoryConsumables()
  2044.  
  2045. def sendNewConsumable(this, consumable, count):
  2046. this.sendPacket(Identifiers.send.New_Consumable, ByteArray().writeByte(0).writeShort(consumable).writeShort(count).toByteArray(), True)
  2047.  
  2048. def checkLetters(this, playerLetters):
  2049. needUpdate = False
  2050. letters = playerLetters.split("/")
  2051. for letter in letters:
  2052. if not letter == "":
  2053. values = letter.split("|")
  2054. this.sendPacket(Identifiers.send.Letter, ByteArray().writeUTF(values[0]).writeUTF(values[1]).writeByte(int(values[2])).writeBytes(binascii.unhexlify(values[3])).toByteArray())
  2055. needUpdate = True
  2056.  
  2057. if needUpdate:
  2058. this.Cursor.execute("update users set Letters = '' where Username = ?", [this.Username])
  2059.  
  2060. class Server(protocol.ServerFactory):
  2061. protocol = Client
  2062. def __init__(this):
  2063.  
  2064. # Settings
  2065. this.ac_config = open('./utils/anticheat/anticheat_config.txt', 'r').read()
  2066. this.ac_enabled = True
  2067. this.ac_c = json.loads(this.ac_config)
  2068. this.learning = this.ac_c['learning']
  2069. this.bantimes = this.ac_c['ban_times']
  2070. this.s_list = open('./utils/anticheat/anticheat_allow', 'r').read()
  2071. if this.s_list != "":
  2072. this.s_list = this.s_list.split(',')
  2073. this.s_list.remove("")
  2074. else:
  2075. this.s_list = []
  2076. this.CKEY = str(this.config("CKEY"))
  2077. this.Version = str(this.config("Version"))
  2078. this.DEBUG = bool(int(this.config("DEBUG")))
  2079. this.VERBOSE = bool(int(this.config("VERBOSE")))
  2080. this.allowStandalone = bool(int(this.config("Allow Standalone")))
  2081. this.checkURL = bool(int(this.config("Check URL")))
  2082. this.serverURL = this.config("Server URL").split(", ")
  2083. this.lastPlayerID = int(this.config("Last Player ID"))
  2084. this.lastMapEditeurCode = int(this.config("Last Map Editeur Code"))
  2085. this.needToFirst = int(this.config("Need To First"))
  2086. this.needToBootcamp = int(this.config("Need To Bootcamp"))
  2087. this.lastTribeID = int(this.config("Last Tribe ID"))
  2088. this.lastChatID = int(this.config("Last Chat ID"))
  2089. this.initialCheeses = int(this.config("Initial Cheeses"))
  2090. this.initialFraises = int(this.config("Initial Fraises"))
  2091. this.EmailAddress = this.config("Email Address")
  2092. this.EmailPassword = this.config("Email Password")
  2093. this.lastTopicID = int(this.config("Last Topic ID"))
  2094. this.lastPostID = int(this.config("Last Post ID"))
  2095. this.isIceEvent = bool(int(this.config("Ice Event")))
  2096. this.Admins = this.config("Admins").split(", ")
  2097. this.avatarURL = this.config("Avatar URL")
  2098. this.shopList = Config.get("ConfigShop", "Shop List", 0).split(";")
  2099. this.shamanShopList = Config.get("ConfigShop", "Shaman Shop List", 0).split(";")
  2100.  
  2101. # Integer
  2102. this.lastPlayerCode = 0
  2103. this.lastGiftID = 0
  2104.  
  2105. # Nonetype
  2106. this.rebootTimer = None
  2107. this.rankingTimer = None
  2108.  
  2109. # List
  2110. this.CheeseTitleListCheck = [5, 20, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 2000, 2300, 2700, 3200, 3800, 4600, 6000, 7000, 8000, 9001, 10000, 14000, 18000, 22000, 26000, 30000, 34000, 38000, 42000, 46000, 50000, 55000, 60000, 65000, 70000, 75000, 80000]
  2111. this.FirstTitleListCheck = [1, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4000, 4500, 5000, 5500, 6000, 7000, 8000, 9000, 10000, 12000, 14000, 16000, 18000, 20000, 25000, 30000, 35000, 40000]
  2112. this.ShamanTitleListCheck = [10, 100, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 18000, 20000, 22000, 24000, 26000, 28000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 100000, 140000]
  2113. this.ShopTitleListCheck = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 45, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 67, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 89, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 111, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 133, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 155, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 177, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198]
  2114. this.BootcampTitleListCheck = [1, 3, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1001, 1003, 1005, 1007, 1010, 1015, 1020, 1025, 1030, 1040, 1050, 1060, 1070, 1080, 1090, 1100, 1120, 1140, 1160, 1180, 1200, 1250, 1300, 1350, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2001, 2003, 2005, 2007, 2010, 2015, 2020, 2025, 2030, 2040, 2050, 2060, 2070, 2080, 2090, 2100, 2120, 2140, 2160, 2180, 2200, 2250, 2300, 2350, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3001, 3003, 3005, 3007, 3010, 3015, 3020, 3025, 3030, 3040, 3050, 3060, 3070, 3080, 3090, 3100, 3120, 3140, 3160, 3180, 3200, 3250, 3300, 3350, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4001, 4003, 4005, 4007, 4010, 4015, 4020, 4025, 4030, 4040, 4050, 4060, 4070, 4080, 4090, 4100, 4120, 4140, 4160, 4180, 4200, 4250, 4300, 4350, 4400, 4500, 4600, 4700, 4800, 4900, 5000, 5001, 5003, 5005, 5007, 5010, 5015, 5020, 5025, 5030, 5040, 5050, 5060, 5070, 5080, 5090, 5100, 5120, 5140, 5160, 5180, 5200, 5250, 5300, 5350, 5400, 5500, 5600, 5700, 5800, 5900, 6000, 6001, 6003, 6005, 6007, 6010, 6015, 6020, 6025, 6030, 6040, 6050, 6060, 6070, 6080, 6090, 6100, 6120, 6140, 6160, 6180, 6200, 6250, 6300, 6350, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7001, 7003, 7005, 7007, 7010, 7015, 7020, 7025, 7030, 7040, 7050, 7060, 7070, 7080, 7090, 7100, 7120, 7140, 7160, 7180, 7200, 7250, 7300, 7350, 7400, 7500, 7600, 7700, 7800, 7900, 8000, 8001, 8003, 8005, 8007, 8010, 8015, 8020, 8025, 8030, 8040, 8050, 8060, 8070, 8080, 8090, 8100, 8120, 8140, 8160, 8180, 8200, 8250, 8300, 8350, 8400, 8500, 8600, 8700, 8800, 8900, 9000]
  2115. this.HardModeTitleListCheck = [500, 2000, 4000, 7000, 10000, 14000, 18000, 22000, 26000, 30000, 40000]
  2116. this.DivineModeTitleListCheck = [500, 2000, 4000, 7000, 10000, 14000, 18000, 22000, 26000, 30000, 40000]
  2117. this.ShopBadgesCheck = [2227, 2208, 2202, 2209, 2228, 2215, 2218, 2205, 2206, 2219, 2229, 2230, 2231, 2211, 2232, 2224, 2217, 2214, 2212, 2220, 2221, 2222, 2223, 2234, 2203, 2220, 2236, 2238, 2204, 2239, 2241, 2242, 2243, 2244, 2207, 2245, 2246, 2247, 210, 2225, 2213, 2216, 2248, 2226, 2241, 2242, 2245, 2249, 2250, 2252, 2253, 2254, 10132, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2282, 2283]
  2118. this.tempIPBanList = []
  2119. this.ipPermaBanCache = []
  2120. this.userPermaBanCache = []
  2121. this.userTempBanCache = []
  2122. this.shopPromotions = []
  2123. this.userMuteCache = []
  2124. this.rankingsList = []
  2125. this.CheckVeryAccount = {}
  2126.  
  2127. # Dict
  2128. this.reports = {"names": []}
  2129. this.rooms = {}
  2130. this.players = {}
  2131. this.connectedCounts = {}
  2132. this.shopListCheck = {}
  2133. this.shamanShopListCheck = {}
  2134. this.shopGifts = {}
  2135. this.CheeseTitleList = {5:5.1, 20:6.1, 100:7.1, 200:8.1, 300:35.1, 400:36.1, 500:37.1, 600:26.1, 700:27.1, 800:28.1, 900:29.1, 1000:30.1, 1100:31.1, 1200:32.1, 1300:33.1, 1400:34.1, 1500:38.1, 1600:39.1, 1700:40.1, 1800:41.1, 2000:72.1, 2300:73.1, 2700:74.1, 3200:75.1, 3800:76.1, 4600:77.1, 6000:78.1, 7000:79.1, 8000:80.1, 9001:81.1, 10000:82.1, 14000:83.1, 18000:84.1, 22000:85.1, 26000:86.1, 30000:87.1, 34000:88.1, 38000:89.1, 42000:90.1, 46000:91.1, 50000:92.1, 55000:234.1, 60000:235.1, 65000:236.1, 70000:237.1, 75000:238.1, 80000:93.1}
  2136. this.FirstTitleList = {1:9.1, 10:10.1, 100:11.1, 200:12.1, 300:42.1, 400:43.1, 500:44.1, 600:45.1, 700:46.1, 800:47.1, 900:48.1, 1000:49.1, 1100:50.1, 1200:51.1, 1400:52.1, 1600:53.1, 1800:54.1, 2000:55.1, 2200:56.1, 2400:57.1, 2600:58.1, 2800:59.1, 3000:60.1, 3200:61.1, 3400:62.1, 3600:63.1, 3800:64.1, 4000:65.1, 4500:66.1, 5000:67.1, 5500:68.1, 6000:69.1, 7000:231.1, 8000:232.1, 9000:233.1, 10000:70.1, 12000:224.1, 14000:225.1, 16000:226.1, 18000:227.1, 20000:202.1, 25000:228.1, 30000:229.1, 35000:230.1, 40000:71.1}
  2137. this.ShamanTitleList = {10:1.1, 100:2.1, 1000:3.1, 2000:4.1, 3000:13.1, 4000:14.1, 5000:15.1, 6000:16.1, 7000:17.1, 8000:18.1, 9000:19.1, 10000:20.1, 11000:21.1, 12000:22.1, 13000:23.1, 14000:24.1, 15000:25.1, 16000:94.1, 18000:95.1, 20000:96.1, 22000:97.1, 24000:98.1, 26000:99.1, 28000:100.1, 30000:101.1, 35000:102.1, 40000:103.1, 45000:104.1, 50000:105.1, 55000:106.1, 60000:107.1, 65000:108.1, 70000:109.1, 75000:110.1, 80000:111.1, 85000:112.1, 90000:113.1, 100000:114.1, 140000:115.1}
  2138. this.ShopTitleList = {1:115.1, 2:116.1, 4:117.1, 6:118.1, 8:119.1, 10:120.1, 12:121.1, 14:122.1, 16:123.1, 18:124.1, 20:125.1, 22:126.1, 23:115.2, 24:116.2, 26:117.2, 28:118.2, 30:119.2, 32:120.2, 34:121.2, 36:122.2, 38:123.2, 40:124.2, 42:125.2, 44:126.2, 45:115.3, 46:116.3, 48:117.3, 50:118.3, 52:119.3, 54:120.3, 56:121.3, 58:122.3, 60:123.3, 62:124.3, 64:125.3, 66:126.3, 67:115.4, 68:116.4, 70:117.4, 72:118.4, 74:119.4, 76:120.4, 78:121.4, 80:122.4, 82:123.4, 84:124.4, 86:125.4, 88:126.4, 89:115.5, 90:116.5, 92:117.5, 94:118.5, 96:119.5, 98:120.5, 100:121.5, 102:122.5, 104:123.5, 106:124.5, 108:125.5, 110:126.5, 111:115.6, 112:116.6, 114:117.6, 116:118.6, 118:119.6, 120:120.6, 122:121.6, 124:122.6, 126:123.6, 128:124.6, 130:125.6, 132:122.6, 133:115.7, 134:116.7, 136:117.7, 138:118.7, 140:119.7, 142:120.7, 144:121.7, 146:122.7, 148:123.7, 150:124.7, 152:125.7, 154:126.7, 155:115.8, 156:116.8, 158:117.8, 160:118.8, 162:119.8, 164:120.8, 166:121.8, 168:122.8, 170:123.8, 172:124.8, 174:125.8, 176:126.8, 177:115.9, 178:116.9, 180:117.9, 182:118.9, 184:119.9, 186:120.9, 188:121.9, 190:122.9, 192:123.9, 194:124.9, 196:125.9, 198:126.9}
  2139. this.BootcampTitleList = {1:256.1, 3:257.1, 5:258.1, 7:259.1, 10:260.1, 15:261.1, 20:262.1, 25:263.1, 30:264.1, 40:265.1, 50:266.1, 60:267.1, 70:268.1, 80:269.1, 90:270.1, 100:271.1, 120:272.1, 140:273.1, 160:274.1, 180:275.1, 200:276.1, 250:277.1, 300:278.1, 350:279.1, 400:280.1, 500:281.1, 600:282.1, 700:283.1, 800:284.1, 900:285.1, 1000:286.1, 1001:256.2, 1003:257.2, 1005:258.2, 1007:259.2, 1010:260.2, 1015:261.2, 1020:262.2, 1025:263.2, 1030:264.2, 1040:265.2, 1050:266.2, 1060:267.2, 1070:268.2, 1080:269.2, 1090:270.2, 1100:271.2, 1120:272.2, 1140:273.2, 1160:274.2, 1180:275.2, 1200:276.2, 1250:277.2, 1300:278.2, 1350:279.2, 1400:280.2, 1500:281.2, 1600:282.2, 1700:283.2, 1800:284.2, 1900:285.2, 2000:286.2, 2001:256.3, 2003:257.3, 2005:258.3, 2007:259.3, 2010:260.3, 2015:261.3, 2020:262.3, 2025:263.3, 2030:264.3, 2040:265.3, 2050:266.3, 2060:267.3, 2070:268.3, 2080:269.3, 2090:270.3, 2100:271.3, 2120:272.3, 2140:273.3, 2160:274.3, 2180:275.3, 2200:276.3, 2250:277.3, 2300:278.3, 2350:279.3, 2400:280.3, 2500:281.3, 2600:282.3, 2700:283.3, 2800:284.3, 2900:285.3, 3000:286.3, 3001:256.4, 3003:257.4, 3005:258.4, 3007:259.4, 3010:260.4, 3015:261.4, 3020:262.4, 3025:263.4, 3030:264.4, 3040:265.4, 3050:266.4, 3060:267.4, 3070:268.4, 3080:269.4, 3090:270.4, 3100:271.4, 3120:272.4, 3140:273.4, 3160:274.4, 3180:275.4, 3200:276.4, 3250:277.4, 3300:278.4, 3350:279.4, 3400:280.4, 3500:281.4, 3600:282.4, 3700:283.4, 3800:284.4, 3900:285.4, 4000:286.4, 4001:256.5, 4003:257.5, 4005:258.5, 4007:259.5, 4010:260.5, 4015:261.5, 4020:262.5, 4025:263.5, 4030:264.5, 4040:265.5, 4050:266.5, 4060:267.5, 4070:268.5, 4080:269.5, 4090:270.5, 4100:271.5, 4120:272.5, 4140:273.5, 4160:274.5, 4180:275.5, 4200:276.5, 4250:277.5, 4300:278.5, 4350:279.5, 4400:280.5, 4500:281.5, 4600:282.5, 4700:283.5, 4800:284.5, 4900:285.5, 5000:286.5, 5001:256.6, 5003:257.6, 5005:258.6, 5007:259.6, 5010:260.6, 5015:261.6, 5020:262.6, 5025:263.6, 5030:264.6, 5040:265.6, 5050:266.6, 5060:267.6, 5070:268.6, 5080:269.6, 5090:270.6, 5100:271.6, 5120:272.6, 5140:273.6, 5160:274.6, 5180:275.6, 5200:276.6, 5250:277.6, 5300:278.6, 5350:279.6, 5400:280.6, 5500:281.6, 5600:282.6, 5700:283.6, 5800:284.6, 5900:285.6, 6000:286.6, 6001:256.7, 6003:257.7, 6005:258.7, 6007:259.7, 6010:260.7, 6015:261.7, 6020:262.7, 6025:263.7, 6030:264.7, 6040:265.7, 6050:266.7, 6060:267.7, 6070:268.7, 6080:269.7, 6090:270.7, 6100:271.7, 6120:272.7, 6140:273.7, 6160:274.7, 6180:275.7, 6200:276.7, 6250:277.7, 6300:278.7, 6350:279.7, 6400:280.7, 6500:281.7, 6600:282.7, 6700:283.7, 6800:284.7, 6900:285.7, 7000:286.7, 7001:256.8, 7003:257.8, 7005:258.8, 7007:259.8, 7010:260.8, 7015:261.8, 7020:262.8, 7025:263.8, 7030:264.8, 7040:265.8, 7050:266.8, 7060:267.8, 7070:268.8, 7080:269.8, 7090:270.8, 7100:271.8, 7120:272.8, 7140:273.8, 7160:274.8, 7180:275.8, 7200:276.8, 7250:277.8, 7300:278.8, 7350:279.8, 7400:280.8, 7500:281.8, 7600:282.8, 7700:283.8, 7800:284.8, 7900:285.8, 8000:286.8, 8001:256.9, 8003:257.9, 8005:258.9, 8007:259.9, 8010:260.9, 8015:261.9, 8020:262.9, 8025:263.9, 8030:264.9, 8040:265.9, 8050:266.9, 8060:267.9, 8070:268.9, 8080:269.9, 8090:270.9, 8100:271.9, 8120:272.9, 8140:273.9, 8160:274.9, 8180:275.9, 8200:276.9, 8250:277.9, 8300:278.9, 8350:279.9, 8400:280.9, 8500:281.9, 8600:282.9, 8700:283.9, 8800:284.9, 8900:285.9, 9000:286.9}
  2140. this.HardModeTitleList = {500:213.1, 2000:214.1, 4000:215.1, 7000:216.1, 10000:217.1, 14000:218.1, 18000:219.1, 22000:220.1, 26000:221.1, 30000:222.1, 40000:223.1}
  2141. this.DivineModeTitleList = {500:324.1, 2000:325.1, 4000:326.1, 7000:327.1, 10000:328.1, 14000:329.1, 18000:330.1, 22000:331.1, 26000:332.1, 30000:333.1, 40000:334.1}
  2142. this.ShopBadges = {2227:2, 2208:3, 2202:4, 2209:5, 2228:8, 2215:37, 2218:10, 2205:38, 2206:11, 2219:12, 2229:13, 2230:14, 2231:15, 2211:19, 2232:20, 2224:21, 2217:22, 2214:23, 2212:24, 2220:25, 2221:32, 2222:39, 2223:26, 2234:27, 2203:31, 2220:32, 2236:36, 2238:41, 2204:40, 2239:43, 2241:44, 2242:47, 2243:45, 2216:46, 2241:41, 2244:48, 2207:49, 2245:51, 2246:52, 2247:53, 210:54, 2225:56, 2213:60, 2245:51, 2248:61, 2226:62, 2249:63, 2252:67, 2250:66, 2253:68, 2254:70, 10132:71, 2255:72, 2256:128, 2257:135, 2258:136, 2259:137, 2260:138, 2261:140, 2262:141, 2263:143, 2264:146, 2265:148, 2266:148, 2267:149, 2268:150, 2269:151, 2270:152, 2271:155, 2272:156, 2273:157, 2274:160, 2275:161, 2276:165, 2277:167, 2278:171, 2279:173, 2280:175, 2281:176, 2282:177, 2283:178}
  2143. this.chatMessages = {}
  2144. this.avatarKeys = {}
  2145. this.clientAvatarKeys = {}
  2146. this.shopNatal = {0:1}
  2147.  
  2148. # Others
  2149. this.Cursor = Cursor
  2150. this.parseShop()
  2151. this.parseBanList()
  2152. this.parseShamanShop()
  2153. this.menu = this.parseJson("./Sukelac1/menu.json")
  2154. this.blackList = this.parseJson("./Sukelac1/karaliste.json")
  2155. this.rankingTimer = reactor.callLater(1, this.getRanking)
  2156.  
  2157. def updateConfig(this):
  2158. this.setServerSetting("Last Player ID", str(this.lastPlayerID))
  2159. this.setServerSetting("Last Map Editeur Code", str(this.lastMapEditeurCode))
  2160. this.setServerSetting("Last Tribe ID", str(this.lastTribeID))
  2161. this.setServerSetting("Last Chat ID", str(this.lastChatID))
  2162. this.setServerSetting("Last Topic ID", str(this.lastTopicID))
  2163. this.setServerSetting("Last Post ID", str(this.lastPostID))
  2164.  
  2165. def parseShop(this):
  2166. for item in this.shopList:
  2167. values = item.split(",")
  2168. this.shopListCheck[values[0] + "|" + values[1]] = [int(values[5]), int(values[6])]
  2169.  
  2170. def parseShamanShop(this):
  2171. for item in this.shamanShopList:
  2172. values = item.split(",")
  2173. this.shamanShopListCheck[values[0]] = [int(values[3]), int(values[4])]
  2174.  
  2175. def sendOutput(this, message):
  2176. print "["+(str(this.getHours()))+"] " + message
  2177.  
  2178. def getHours(this):
  2179. Time = str(datetime.now())[11:].split(":")
  2180. Time = Time[0] + ":" + Time[1] + ":" + Time[2][:2]
  2181. return str(Time)
  2182.  
  2183. def config(this, setting):
  2184. return Config.get("Settings", setting, 0)
  2185.  
  2186. def setServerSetting(this, setting, value):
  2187. Config.set("Settings", setting, value)
  2188. with open("./Sukelac1/Config.ini", "w") as configfile:
  2189. Config.write(configfile)
  2190.  
  2191. def parseJson(this, directory):
  2192. with open(directory, "r") as f:
  2193. return eval(f.read())
  2194.  
  2195. def sendServerReboot(this):
  2196. this.sendServerRestart(0, 0)
  2197. this.rebootTimer = reactor.callLater(120, lambda: os._exit(120))
  2198.  
  2199. def sendServerShutdown(this):
  2200. this.sendServerRestart(0, 0)
  2201. this.rebootTimer = reactor.callLater(120, lambda: os._exit(120))
  2202.  
  2203. def sendServerRestart(this, no, sec):
  2204. if sec > 0 or no != 5:
  2205. this.sendServerRestartSEC(120 if no == 0 else 60 if no == 1 else 30 if no == 2 else 20 if no == 3 else 10 if no == 4 else sec)
  2206. if this.rebootTimer != None: this.rebootTimer.cancel()
  2207. this.rebootTimer = reactor.callLater(60 if no == 0 else 30 if no == 1 else 10 if no == 2 or no == 3 else 1, lambda: this.sendServerRestart(no if no == 5 else no + 1, 9 if no == 4 else sec - 1 if no == 5 else 0))
  2208.  
  2209. def sendServerRestartSEC(this, seconds):
  2210. this.sendPanelRestartMessage(seconds)
  2211. this.sendWholeServer(Identifiers.send.Server_Restart, ByteArray().writeInt(seconds * 1000).toByteArray())
  2212.  
  2213. def sendPanelRestartMessage(this, seconds):
  2214. if seconds == 120:
  2215. this.sendOutput("[SERVER] O servidor irá começar outra vez em 2 minutos.")
  2216. elif seconds < 120 and seconds > 1:
  2217. this.sendOutput("[SERVER] Sunucu "+str(seconds)+" Começa de novo em segundos.")
  2218. else:
  2219. this.sendOutput("[SERVER] O servidor vai começar de novo dentro de 1 segundo.")
  2220.  
  2221. def getConnectedPlayerCount(this):
  2222. return len(this.players)
  2223.  
  2224. def getRoomsCount(this):
  2225. return len(this.rooms)
  2226.  
  2227. def generatePlayerCode(this):
  2228. this.lastPlayerCode += 1
  2229. return this.lastPlayerCode
  2230.  
  2231. def sendEmail(this, code, DestinEmail, playerName):
  2232. setHostName = "smtp.gmail.com"
  2233. setSslSmtpPort = 587
  2234. setFrom = this.EmailAddress
  2235. addTo = str(DestinEmail)
  2236. setSubject = "Transformice"
  2237. setMsg = "Hello "+playerName+", your activation code is: "+str(code)
  2238. server = smtplib.SMTP(setHostName, setSslSmtpPort)
  2239. server.ehlo()
  2240. server.starttls()
  2241. server.ehlo()
  2242. server.login(this.EmailAddress, this.EmailPassword)
  2243. mail = MIMEText(setMsg)
  2244. mail["To"] = str(DestinEmail)
  2245. mail["Subject"] = setSubject
  2246. mail["Content-type"] = "text/html"
  2247. server.sendmail(setFrom, addTo, mail.as_string())
  2248. server.close()
  2249.  
  2250. def sendLuaLog(this, name, message):
  2251. p = ByteArray()
  2252. p.writeByte(8)
  2253. p.writeUTF('Log')
  2254. p.writeUTF(message)
  2255. p.writeShort(0)
  2256. p.writeShort(0)
  2257. this.server.sendLuaLog(this, '\x06\n', p.toString(), True)
  2258.  
  2259. def checkAlreadyExistingGuest(this, playerName):
  2260. found = False
  2261. result = ""
  2262.  
  2263. if not this.checkConnectedAccount(playerName):
  2264. found = True
  2265. result = playerName
  2266.  
  2267. while not found:
  2268. tempName = playerName + "_" + TFMUtils.getRandomChars(4)
  2269. if not this.checkConnectedAccount(tempName):
  2270. found = True
  2271. result = tempName
  2272. return result
  2273.  
  2274. def checkConnectedAccount(this, playerName):
  2275. return this.players.has_key(playerName)
  2276.  
  2277. def disconnectIPAddress(this, ip):
  2278. for client in this.players.values():
  2279. if client.ipAddress == ip:
  2280. client.transport.loseConnection()
  2281.  
  2282. def getplayerAvatar(this, playerName):
  2283. if playerName.startswith('*'):
  2284. return 0
  2285. else:
  2286. this.Cursor.execute('select avatar from Users where Username = ?', [playerName])
  2287. rrf = this.Cursor.fetchone()
  2288. if rrf is None:
  2289. return 0
  2290. if rrf[0] == 'None':
  2291. return 0
  2292. return int()
  2293.  
  2294. def getProfileAvatar(this, username):
  2295. found = False
  2296. for room in this.rooms.values():
  2297. for player in room.clients.values():
  2298. if player.username == username:
  2299. found = player.avatar
  2300. return found
  2301.  
  2302. def checkExistingUser(this, playerName):
  2303. this.Cursor.execute("select * from Users where Username = ?", [playerName])
  2304. if this.Cursor.fetchone():
  2305. return True
  2306. return False
  2307.  
  2308. def recommendRoom(this, langue):
  2309. found = False
  2310. x = 0
  2311. result = ""
  2312. while not found:
  2313. x += 1
  2314. if this.rooms.has_key(langue + "-" + str(x)):
  2315. if this.rooms[langue + "-" + str(x)].getPlayerCount() < 25:
  2316. found = True
  2317. result = str(x)
  2318. else:
  2319. found = True
  2320. result = str(x)
  2321. return result
  2322.  
  2323. def checkRoom(this, roomName, langue):
  2324. found = False
  2325. x = 0
  2326. result = roomName
  2327. if this.rooms.has_key(langue + "-" + roomName if not roomName.startswith("*") and roomName[0] != chr(3) else roomName):
  2328. room = this.rooms.get(langue + "-" + roomName if not roomName.startswith("*") and roomName[0] != chr(3) else roomName)
  2329. if room.getPlayerCount() < room.maxPlayers if room.maxPlayers != -1 else True:
  2330. found = True
  2331. else:
  2332. found = True
  2333.  
  2334. while not found:
  2335. x += 1
  2336. if this.rooms.has_key((langue + "-" + roomName if not roomName.startswith("*") and roomName[0] != chr(3) else roomName) + str(x)):
  2337. room = this.rooms.get((langue + "-" + roomName if not roomName.startswith("*") and roomName[0] != chr(3) else roomName) + str(x))
  2338. if room.getPlayerCount() < room.maxPlayers if room.maxPlayers != -1 else True:
  2339. found = True
  2340. result += str(x)
  2341. else:
  2342. found = True
  2343. result += str(x)
  2344. return result
  2345.  
  2346. def addClientToRoom(this, client, roomName):
  2347. if this.rooms.has_key(roomName):
  2348. this.rooms[roomName].addClient(client)
  2349. else:
  2350. room = Room(this, roomName)
  2351. this.rooms[roomName] = room
  2352. room.addClient(client)
  2353.  
  2354. def getIPPermaBan(this, ip):
  2355. return ip in this.ipPermaBanCache
  2356.  
  2357. def checkReport(this, array, playerName):
  2358. return playerName in array
  2359.  
  2360. def banPlayer(this, playerName, bantime, reason, modname, silent):
  2361. found = False
  2362.  
  2363. client = this.players.get(playerName)
  2364. if client != None:
  2365. found = True
  2366. if not modname == "Server":
  2367. client.banHours += bantime
  2368. ban = str(time.time())
  2369. bandate = ban[:len(ban) - 4]
  2370. this.Cursor.execute("insert into BanLog (Name, BannedBy, Time, Reason, Date, Status, Room, IP) values (?, ?, ?, ?, ?, ?, ?, ?)", [playerName, modname, str(bantime), reason, bandate, "Çevrimiçi", client.roomName, client.ipAddress])
  2371. else:
  2372. this.sendModMessage(5, "<V>Servidores <BL>Jogador <V>"+playerName+"<BL> o jogo <V>1 <BL> removeu a hora. Causa: <V>maioria de votos<BL>.")
  2373.  
  2374. if not playerName.startswith("*"):
  2375. this.Cursor.execute("update Users SET BanHours = ? WHERE Username = ?", [bantime, playerName])
  2376.  
  2377. if bantime >= 361 or client.banHours >= 361:
  2378. this.userPermaBanCache.append(playerName)
  2379. this.Cursor.execute("insert into UserPermaBan (Name, BannedBy, Reason) values (?, ?, ?)", [playerName, modname, reason])
  2380.  
  2381. if client.banHours >= 361:
  2382. this.ipPermaBanCache.append(client.ipAddress)
  2383. this.Cursor.execute("insert into IPPermaBan (IP, BannedBy, Reason) values (?, ?, ?)", [client.ipAddress, modname, reason])
  2384.  
  2385. if bantime >= 1 and bantime <= 360:
  2386. this.tempBanUser(playerName, bantime, reason)
  2387. this.tempBanIP(client.ipAddress, bantime)
  2388.  
  2389. if this.checkReport(this.reports["names"], playerName):
  2390. this.reports[playerName]["status"] = "banned"
  2391. this.reports[playerName]["status"] = "modname"
  2392. this.reports[playerName]["status"] = str(bantime)
  2393. this.reports[playerName]["banreason"] = "hack"
  2394.  
  2395. client.sendPlayerBan(bantime, reason, silent)
  2396.  
  2397. if not found and not playerName.startswith("*") and this.checkExistingUser(playerName) and not modname == "Server" and bantime >= 1:
  2398. found = True
  2399. totalBanTime = this.getTotalBanHours(playerName) + bantime
  2400. if totalBanTime >= 361 and bantime <= 360 or bantime >= 361:
  2401. this.userPermaBanCache.append(playerName)
  2402. this.Cursor.execute("insert into UserPermaBan (Name, BannedBy, Reason) values (?, ?, ?)", [playerName, modname, reason])
  2403.  
  2404. if bantime >= 1 and bantime <= 360:
  2405. this.tempBanUser(playerName, bantime, reason)
  2406.  
  2407. this.Cursor.execute("update Users SET BanHours = ? WHERE Username = ?", [bantime, playerName])
  2408.  
  2409. ban = str(time.time())
  2410. bandate = ban[:len(ban) - 4]
  2411. this.Cursor.execute("insert into BanLog (Name, BannedBy, Time, Reason, Date, Status, Room, IP) values (?, ?, ?, ?, ?, ?, ?, ?)", [playerName, modname, str(bantime), reason, bandate, "Çevrimdışı", "", "Çevrimdışı"])
  2412. return found
  2413.  
  2414. def checkTempBan(this, playerName):
  2415. this.Cursor.execute("select * from UserTempBan where Name = ?", [playerName])
  2416. if this.Cursor.fetchone():
  2417. return True
  2418. return False
  2419.  
  2420. def removeTempBan(this, playerName):
  2421. this.userTempBanCache.remove(playerName)
  2422. this.Cursor.execute("delete from UserTempBan where Name = ?", [playerName])
  2423.  
  2424. def tempBanUser(this, playerName, bantime, reason):
  2425. if this.checkTempBan(playerName):
  2426. this.removeTempBan(playerName)
  2427.  
  2428. this.userTempBanCache.append(playerName)
  2429. this.Cursor.execute("insert into UserTempBan (Name, Time, Reason) values (?, ?, ?)", [playerName, str(TFMUtils.getTime() + (bantime * 60 * 60)), reason])
  2430.  
  2431. def getTempBanInfo(this, playerName):
  2432. this.Cursor.execute("select Time, Reason from UserTempBan where Name = ?", [playerName])
  2433. rs = this.Cursor.fetchone()
  2434. if rs:
  2435. return [rs["Time"], rs["Reason"]]
  2436. return [0, ""]
  2437.  
  2438. def checkPermaBan(this, playerName):
  2439. this.Cursor.execute("select * from UserPermaBan where Name = ?", [playerName])
  2440. if this.Cursor.fetchone():
  2441. return True
  2442. return False
  2443.  
  2444. def removePermaBan(this, playerName):
  2445. this.userPermaBanCache.remove(playerName)
  2446. this.Cursor.execute("delete from UserPermaBan where Name = ?", [playerName])
  2447.  
  2448. def tempBanIP(this, ip, time):
  2449. if not ip in this.tempIPBanList:
  2450. this.tempIPBanList.append(ip)
  2451. reactor.callLater(time, lambda: this.tempIPBanList.remove(ip))
  2452.  
  2453. def getTotalBanHours(this, playerName):
  2454. this.Cursor.execute("select BanHours from Users where Username = ?", [playerName])
  2455. rs = this.Cursor.fetchone()
  2456. if rs:
  2457. return rs["BanHours"]
  2458. return 0
  2459.  
  2460. def parseBanList(this):
  2461. this.Cursor.execute("select ip from IPPermaBan")
  2462. rs = this.Cursor.fetchone()
  2463. if rs:
  2464. this.ipPermaBanCache.append(rs["ip"])
  2465.  
  2466. this.Cursor.execute("select Name from UserPermaBan")
  2467. rs = this.Cursor.fetchone()
  2468. if rs:
  2469. this.userPermaBanCache.append(rs["Name"])
  2470.  
  2471. this.Cursor.execute("select Name from UserTempBan")
  2472. rs = this.Cursor.fetchone()
  2473. if rs:
  2474. this.userTempBanCache.append(rs["Name"])
  2475.  
  2476. this.Cursor.execute("select Name from UserTempMute")
  2477. rs = this.Cursor.fetchone()
  2478. if rs:
  2479. this.userMuteCache.append(rs["Name"])
  2480.  
  2481. def voteBanPopulaire(this, playerName, myIP):
  2482. client = this.players.get(playerName)
  2483. if client != None:
  2484. if client.privLevel <= 2:
  2485. if not myIP in client.voteBan:
  2486. client.voteBan.append(myIP)
  2487. if len(client.voteBan) == 10:
  2488. this.banPlayer(playerName, 1, "Vote Populaire", "Sunucu", False)
  2489.  
  2490. def muteUser(this, playerName, mutetime, reason):
  2491. this.userMuteCache.append(playerName)
  2492. this.Cursor.execute("insert into UserTempMute (Name, Time, Reason) values (?, ?, ?)", [playerName, str(TFMUtils.getTime() + (mutetime * 60 * 60)), reason])
  2493.  
  2494. def removeModMute(this, playerName):
  2495. this.Cursor.execute("delete from UserTempMute where Name = ?", [playerName])
  2496.  
  2497. def getModMuteInfo(this, playerName):
  2498. this.Cursor.execute("select Time, Reason from UserTempMute where Name = ?", [playerName])
  2499. rs = this.Cursor.fetchone()
  2500. if rs:
  2501. return [rs["Time"], rs["Reason"]]
  2502. return [0, ""]
  2503. def sendModChat(this, senderClient, eventTokens, data, binary = None):
  2504. if eventTokens == "\x1A\x04":
  2505. print str(datetime.today())+" [Servidor] "+data[0]
  2506. for room in this.rooms.values():
  2507. for playerCode, client in room.clients.items():
  2508. if client.privLevel >= 4:
  2509. if binary:
  2510. reactor.callLater(0, client.sendPacket, eventTokens, data, True)
  2511. else:
  2512. reactor.callLater(0, client.sendPacket, eventTokens, data)
  2513.  
  2514. def mutePlayer(this, playerName, time, reason, modname):
  2515. client = this.players.get(playerName)
  2516. if client != None:
  2517. this.sendModMessage(5, "<V>"+str(modname)+"<BL> Por <V>"+playerName+"<BL> Os jogadores não podem falar agora chamado <V>"+str(time)+"<BL> Comprar. causa: <V>"+str(reason)+"<BL>.")
  2518. if playerName in this.userMuteCache:
  2519. this.removeModMute(playerName)
  2520.  
  2521. client.modMute = True
  2522. client.sendModMute(playerName, time, reason, False)
  2523. this.muteUser(playerName, time, reason)
  2524.  
  2525. def desmutePlayer(this, playerName, modname):
  2526. client = this.players.get(playerName)
  2527. if client != None:
  2528. this.sendModMessage(5, "<V>"+str(modname)+"<N> Por <V>"+playerName+" Agora você pode conversar com os jogadores nomeados<BL>.")
  2529. this.removeModMute(playerName)
  2530. client.modMute = False
  2531.  
  2532. def sendStaffChat(this, type, langue, identifiers, packet):
  2533. minLevel = 0 if type == -1 or type == 0 else 1 if type == 1 else 7 if type == 3 or type == 4 else 5 if type == 2 or type == 5 else 6 if type == 7 or type == 6 else 3 if type == 8 else 4 if type == 9 else 0
  2534. for client in this.players.values():
  2535. if client.privLevel >= minLevel and client.Langue == langue or type == 1 or type == 4 or type == 5:
  2536. client.sendPacket(identifiers, packet, True)
  2537.  
  2538. def getTotemData(this, playerName):
  2539. if playerName.startswith("*"):
  2540. return []
  2541. else:
  2542. this.Cursor.execute("select ItemCount, Totem from Totem where Name = ?", [playerName])
  2543. rs = this.Cursor.fetchone()
  2544. if rs:
  2545. itemCount = rs["ItemCount"]
  2546. totem = rs["Totem"]
  2547. totem = totem.replace("%", chr(1))
  2548. return [str(itemCount), totem]
  2549. return []
  2550.  
  2551. def setTotemData(this, playerName, ItemCount, totem):
  2552. if playerName.startswith("*"):
  2553. pass
  2554. else:
  2555. totem = totem.replace(chr(1), "%")
  2556.  
  2557. if len(this.getTotemData(playerName)) != 0:
  2558. this.Cursor.execute("update Totem set ItemCount = ?, Totem = ? where Name = ?", [ItemCount, totem, playerName])
  2559. else:
  2560. this.Cursor.execute("insert into Totem (Name, ItemCount, Totem) values (?, ?, ?)", [playerName, ItemCount, totem])
  2561.  
  2562. def getPlayerLevel(this, playerName):
  2563. client = this.players.get(playerName)
  2564. return client.shamanLevel if client != None else 0
  2565.  
  2566. def getPlayerID(this, playerName):
  2567. if playerName.startswith("*"):
  2568. return 0
  2569.  
  2570. elif this.players.has_key(playerName):
  2571. return this.players[playerName].playerID
  2572. else:
  2573. this.Cursor.execute("select PlayerID from Users where Username = ?", [playerName])
  2574. rs = this.Cursor.fetchone()
  2575. if rs:
  2576. return rs["PlayerID"]
  2577. return 0
  2578.  
  2579. def getPlayerPrivlevel(this, playerName):
  2580. if playerName.startswith("*"):
  2581. return 0
  2582.  
  2583. elif this.players.has_key(playerName):
  2584. return this.players[playerName].privLevel
  2585. else:
  2586. this.Cursor.execute("select PrivLevel from Users where Username = ?", [playerName])
  2587. rs = this.Cursor.fetchone()
  2588. if rs:
  2589. return rs["PrivLevel"]
  2590. return 0
  2591.  
  2592. def getPlayerName(this, playerID):
  2593. this.Cursor.execute("select Username from Users where PlayerID = ?", [playerID])
  2594. rs = this.Cursor.fetchone()
  2595. if rs:
  2596. return rs["Username"]
  2597. return ""
  2598.  
  2599. def getPlayerRoomName(this, playerName):
  2600. if this.players.has_key(playerName):
  2601. return this.players[playerName].roomName
  2602. return ""
  2603.  
  2604. def getTribeInfo(this, tribeCode):
  2605. tribeRankings = {}
  2606. this.Cursor.execute("select * from Tribe where Code = ?", [tribeCode])
  2607. rs = this.Cursor.fetchone()
  2608. if rs:
  2609. for rank in rs["Rankings"].split(";"):
  2610. values = rank.split("|", 1)
  2611. tribeRankings[int(values[0])] = values[1]
  2612. return [rs["Name"], rs["Message"], rs["House"], tribeRankings, rs["Chat"]]
  2613. return ["", "", 0, tribeRankings]
  2614.  
  2615. def getTribeHouse(this, tribeName):
  2616. this.Cursor.execute("select House from Tribe where Name = ?", [tribeName])
  2617. rs = this.Cursor.fetchone()
  2618. if rs:
  2619. return rs["House"]
  2620. return -1
  2621.  
  2622. def checkDuplicateEmail(this, email):
  2623. this.Cursor.execute("select Username from Users where Email = ?", [email])
  2624. if this.Cursor.fetchone():
  2625. return True
  2626. return False
  2627.  
  2628. def checkEmailAddress(this, playerName, email):
  2629. this.Cursor.execute("select Email from Users where Username = ?", [playerName])
  2630. rs = this.Cursor.fetchone()
  2631. if rs:
  2632. return rs["Email"] == email
  2633. return False
  2634.  
  2635. def getPlayersCountMode(this, mode):
  2636. playerCount = 0
  2637. modeName = ""
  2638. if mode == 1:
  2639. modeName = "MiceBolt Todos os quartos"
  2640. for room in this.rooms.values():
  2641. if room.isNormRoom:
  2642. playerCount += room.getPlayerCount()
  2643.  
  2644. elif mode == 3:
  2645. modeName = "MiceBolt - Vanilla"
  2646. for room in this.rooms.values():
  2647. if room.isVanilla:
  2648. playerCount += room.getPlayerCount()
  2649.  
  2650. elif mode == 8:
  2651. modeName = "MiceBolt - Survivor"
  2652. for room in this.rooms.values():
  2653. if room.isSurvivor:
  2654. playerCount += room.getPlayerCount()
  2655.  
  2656. elif mode == 9:
  2657. modeName = "MiceBolt - Racing"
  2658. for room in this.rooms.values():
  2659. if room.isRacing:
  2660. playerCount += room.getPlayerCount()
  2661.  
  2662. elif mode == 11:
  2663. modeName = "MiceBolt - Music"
  2664. for room in this.rooms.values():
  2665. if room.isMusic:
  2666. playerCount += room.getPlayerCount()
  2667.  
  2668. elif mode == 2:
  2669. modeName = "MiceBolt - Bootcamp"
  2670. for room in this.rooms.values():
  2671. if room.isBootcamp:
  2672. playerCount += room.getPlayerCount()
  2673.  
  2674. elif mode == 10:
  2675. modeName = "MiceBolt - Defilante"
  2676. for room in this.rooms.values():
  2677. if room.isDefilante:
  2678. playerCount += room.getPlayerCount()
  2679.  
  2680. elif mode == 16:
  2681. modeName = "MiceBolt - Village"
  2682. for room in this.rooms.values():
  2683. if room.isVillage:
  2684. playerCount += room.getPlayerCount()
  2685.  
  2686. return [modeName, playerCount]
  2687. def sendWholeServer(this, identifiers, result):
  2688. for client in this.players.values():
  2689. client.sendPacket(identifiers, result, True)
  2690.  
  2691. def checkMessage(this, client, message):
  2692. list = this.blackList["list"]
  2693. i = 0
  2694. while i < len(list):
  2695. if re.search("[^a-zA-Z]*".join(list[i]), message.lower()):
  2696. this.sendModMessage(7, "[<V>"+client.roomName+"<BL>][<T>"+client.Username+"<BL>] Envie um link foi nomeado Jogador <J>"+str(message)+"<BL>, (digite <ROSE>/addlink <S><B>Link</B><BL>, Adicionado Black List).")
  2697. return True
  2698. i += 1
  2699.  
  2700. return False
  2701.  
  2702. def setVip(this, playerName, days):
  2703. player = this.players.get(playerName)
  2704. if ((player != None and player.privLevel == 1) or this.getPlayerPrivlevel(playerName) == 1):
  2705. this.Cursor.execute("update users set VipTime = ? where Username = ?" if player != None else "update users SET VipTime = ?, PrivLevel = 2 where Username = ?", [TFMUtils.getTime() + (days * 24 * 3600), playerName])
  2706. if player != None:
  2707. player.privLevel = 2
  2708.  
  2709. this.sendModMessage(7, "<V>"+playerName+"</V> Virou Vip Em Nosso Servidor Por: <V>"+str(days)+"</V> Dias.")
  2710. return True
  2711.  
  2712. return False
  2713.  
  2714. def getPlayerCode(this, playerName):
  2715. client = this.players.get(TFMUtils.parsePlayerName(playerName))
  2716. if client != None:
  2717. return client.playerCode
  2718. else:
  2719. return 0
  2720.  
  2721. def sendModMessage(this, minLevel, message):
  2722. for client in this.players.values():
  2723. if client.privLevel >= minLevel:
  2724. client.sendPacket(Identifiers.old.send.Message, ByteArray().writeByte(0).writeUTF(message).writeBool(False).toByteArray(), True)
  2725.  
  2726. def getRandomKey(this):
  2727. return TFMUtils.getRandomChars(6)
  2728.  
  2729. def checkSuspectBot(this, playerName, type):
  2730. if not this.DEBUG:
  2731. if this.banPlayer(playerName, 360, "Hack Suspect", "Sunucu", False):
  2732. this.sendModMessage(5, "<V>Servidor<BL>Jogador <V>"+playerName+"<BL> Jogador <V>360 <BL>Foi Punido pelo Seguinte Motivo. Causa: <V>Hack ("+str(type)+")<BL>.")
  2733.  
  2734. def getRanking(this):
  2735. this.rankingTimer = reactor.callLater(30, this.getRanking)
  2736. this.rankingsList = []
  2737. this.rankingsList.append({})
  2738. this.rankingsList.append({})
  2739. this.rankingsList.append({})
  2740. this.rankingsList.append({})
  2741.  
  2742. this.Cursor.execute("select Username, FirstCount from Users order by FirstCount desc limit 0, 15")
  2743. r = this.Cursor.fetchall()
  2744. count = 0
  2745. for rs in r:
  2746. playerName = rs["Username"]
  2747. this.rankingsList[0][count] = [playerName, this.players[playerName].firstCount if this.checkConnectedAccount(playerName) else rs["FirstCount"]]
  2748. count += 1
  2749.  
  2750. this.Cursor.execute("select Username, CheeseCount from Users order by CheeseCount desc limit 0, 15")
  2751. r = this.Cursor.fetchall()
  2752. count = 0
  2753. for rs in r:
  2754. playerName = rs["Username"]
  2755. this.rankingsList[1][count] = [playerName, this.players[playerName].cheeseCount if this.checkConnectedAccount(playerName) else rs["CheeseCount"]]
  2756. count += 1
  2757.  
  2758. this.Cursor.execute("select Username, ShamanSaves from Users order by ShamanSaves desc limit 0, 15")
  2759. r = this.Cursor.fetchall()
  2760. count = 0
  2761. for rs in r:
  2762. playerName = rs["Username"]
  2763. this.rankingsList[2][count] = [playerName, this.players[playerName].shamanSaves if this.checkConnectedAccount(playerName) else rs["ShamanSaves"]]
  2764. count += 1
  2765.  
  2766. this.Cursor.execute("select Username, BootcampCount from Users order by BootcampCount desc limit 0, 15")
  2767. r = this.Cursor.fetchall()
  2768. count = 0
  2769. for rs in r:
  2770. playerName = rs["Username"]
  2771. this.rankingsList[3][count] = [playerName, this.players[playerName].bootcampCount if this.checkConnectedAccount(playerName) else rs["BootcampCount"]]
  2772. count += 1
  2773.  
  2774. class Room:
  2775. def __init__(this, server, name):
  2776.  
  2777. # String
  2778. this.currentSyncName = ""
  2779. this.currentShamanName = ""
  2780. this.currentSecondShamanName = ""
  2781. this.forceNextMap = "-1"
  2782. this.mapName = ""
  2783. this.mapXML = ""
  2784. this.EMapXML = ""
  2785. this.roomPassword = ""
  2786. this.minigameSearchName = ""
  2787.  
  2788. # Integer
  2789. this.maxPlayers = 100
  2790. this.currentMap = 0
  2791. this.lastRoundCode = 0
  2792. this.lastCodePartie = 0
  2793. this.mapCode = -1
  2794. this.mapYesVotes = 0
  2795. this.mapNoVotes = 0
  2796. this.mapPerma = -1
  2797. this.mapStatus = 0
  2798. this.currentSyncCode = -1
  2799. this.roundTime = 120
  2800. this.gameStartTime = 0
  2801. this.currentShamanCode = -1
  2802. this.currentSecondShamanCode = -1
  2803. this.currentShamanType = -1
  2804. this.currentSecondShamanType = -1
  2805. this.forceNextShaman = -1
  2806. this.numCompleted = 0
  2807. this.FSnumCompleted = 0
  2808. this.SSnumCompleted = 0
  2809. this.receivedNo = 0
  2810. this.receivedYes = 0
  2811. this.EMapLoaded = 0
  2812. this.EMapCode = 0
  2813. this.objectID = 0
  2814. this.tempTotemCount = -1
  2815. this.addTime = 0
  2816. this.iceCount = 2
  2817. this.cloudID = -1
  2818. this.companionBox = -1
  2819. this.mulodromeRoundCount = 0
  2820. this.redCount = 0
  2821. this.blueCount = 0
  2822. this.musicsLength = 0
  2823. this.currentMusicID = 0
  2824. this.musicSkipVotes = 0
  2825. this.musicMapStatus = 0
  2826. this.musicTime = 0
  2827. this.roundsCount = -1
  2828. this.survivorMapStatus = 0
  2829. this.lastImageID = 0
  2830. this.changeMapAttemps = 0
  2831.  
  2832. this.gameStartTimeMillis = 0
  2833.  
  2834. # Bool
  2835. this.isClosed = False
  2836. this.isCurrentlyPlay = False
  2837. this.isDoubleMap = False
  2838. this.isNoShamanMap = False
  2839. this.isVotingMode = False
  2840. this.initVotingMode = True
  2841. this.isVotingBox = False
  2842. this.EMapValidated = False
  2843. this.countStats = True
  2844. this.never20secTimer = False
  2845. this.isVanilla = False
  2846. this.isEditeur = False
  2847. this.changed20secTimer = False
  2848. this.specificMap = False
  2849. this.noShaman = False
  2850. this.isTutorial = False
  2851. this.isTotemEditeur = False
  2852. this.autoRespawn = False
  2853. this.iceEnabled = False
  2854. this.noAutoScore = False
  2855. this.catchTheCheeseMap = False
  2856. this.isTribeHouse = False
  2857. this.isTribeHouseMap = False
  2858. this.isMulodrome = False
  2859. this.isRacing = False
  2860. this.isMusic = False
  2861. this.isPlayMusic = False
  2862. this.isRacingP17 = False
  2863. this.isBootcamp = False
  2864. this.isBootcampP13 = False
  2865. this.isSurvivor = False
  2866. this.isSurvivorVamp = False
  2867. this.isDefilante = False
  2868. this.isNormRoom = False
  2869. this.isSnowing = False
  2870. this.canChangeMap = True
  2871. this.disableAfkKill = False
  2872. this.isFixedMap = False
  2873. this.noShamanSkills = False
  2874. this.is801Room = False
  2875. this.mapInverted = False
  2876. this.isVillage = False
  2877.  
  2878. # Bool
  2879. this.changeMapTimer = None
  2880. this.closeRoomRoundJoinTimer = None
  2881. this.voteCloseTimer = None
  2882. this.killAfkTimer = None
  2883. this.autoRespawnTimer = None
  2884. this.endSnowTimer = None
  2885. this.startTimerLeft = None
  2886.  
  2887. # List Arguments
  2888. this.MapList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 141, 142, 143, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210]
  2889. this.noShamanMaps = [7, 8, 14, 22, 23, 28, 29, 54, 55, 57, 58, 59, 60, 61, 70, 77, 78, 87, 88, 92, 122, 123, 124, 125, 126, 1007, 888, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210]
  2890. this.anchors = []
  2891. this.lastHandymouse = [-1, -1]
  2892.  
  2893. # List
  2894. this.redTeam = []
  2895. this.blueTeam = []
  2896. this.suspectHacks = []
  2897. this.roomTimers = []
  2898.  
  2899. # Dict
  2900. this.clients = {}
  2901. this.currentShamanSkills = {}
  2902. this.currentSecondShamanSkills = {}
  2903. this.roomMusics = {}
  2904. this.currentTimers = {}
  2905.  
  2906. # Others
  2907. this.name = name
  2908. this.server = server
  2909. this.Cursor = Cursor
  2910. this.gameStartTime = TFMUtils.getTime()
  2911.  
  2912. if this.name.startswith("*"):
  2913. this.community = "xx"
  2914. this.roomName = this.name
  2915. else:
  2916. this.community = this.name.split("-")[0].lower()
  2917. this.roomName = this.name.split("-")[1]
  2918.  
  2919. if this.roomName.startswith(chr(3) + "[Editeur] "):
  2920. this.countStats = False
  2921. this.isEditeur = True
  2922. this.never20secTimer = True
  2923.  
  2924. elif this.roomName.startswith(chr(3) + "[Tutorial] "):
  2925. this.countStats = False
  2926. this.currentMap = 900
  2927. this.specificMap = True
  2928. this.noShaman = True
  2929. this.never20secTimer = True
  2930. this.isTutorial = True
  2931.  
  2932. elif this.roomName.startswith(chr(3) + "[Totem] "):
  2933. this.countStats = False
  2934. this.specificMap = True
  2935. this.currentMap = 444
  2936. this.isTotemEditeur = True
  2937. this.roundTime = 360
  2938. this.never20secTimer = True
  2939.  
  2940. elif this.roomName.startswith("*" + chr(3)):
  2941. this.countStats = False
  2942. this.isTribeHouse = True
  2943. this.autoRespawn = True
  2944. this.never20secTimer = True
  2945.  
  2946. elif this.roomName.startswith("music"):
  2947. this.isMusic = True
  2948.  
  2949. elif this.roomName.startswith("racing"):
  2950. this.isRacing = True
  2951. this.noShaman = True
  2952. this.never15secTimer = True
  2953. this.roundTime = 63
  2954.  
  2955. elif this.roomName.startswith("bootcamp"):
  2956. this.isBootcamp = True
  2957. this.countStats = False
  2958. this.roundTime = 360
  2959. this.never2secTimer = True
  2960. this.autoRespawn = True
  2961. this.noShaman = True
  2962.  
  2963. elif this.roomName.startswith("vanilla"):
  2964. this.isVanilla = True
  2965.  
  2966. elif this.roomName.startswith("survivor"):
  2967. this.isSurvivor = True
  2968. this.roundTime = 90
  2969.  
  2970. elif this.roomName.startswith("defilante"):
  2971. this.isDefilante = True
  2972. this.noShaman = True
  2973. this.countStats = False
  2974. this.noAutoScore = True
  2975.  
  2976. elif this.roomName.startswith("village"):
  2977. this.isVillage = True
  2978. this.roundTime = 0
  2979. this.never20secTimer = True
  2980. this.autoRespawn = True
  2981. this.countStats = False
  2982. this.noShaman = True
  2983. this.isFixedMap = True
  2984.  
  2985. elif this.roomName in ("801", "*801"):
  2986. this.is801Room = True
  2987. this.roundTime = 0
  2988. this.never20secTimer = True
  2989. this.autoRespawn = True
  2990. this.countStats = False
  2991. this.noShaman = True
  2992. this.isFixedMap = True
  2993. else:
  2994. this.isNormRoom = True
  2995.  
  2996. if this.name.startswith("#"):
  2997. this.minigameSearchName = this.name[1:]
  2998.  
  2999. if this.name.startswith("*#"):
  3000. this.minigameSearchName = this.name[2:]
  3001.  
  3002. this.mapChange()
  3003.  
  3004. def startTimer(this):
  3005. for client in this.clients.values():
  3006. client.sendMapStartTimerEnd()
  3007.  
  3008. def mapChange(this):
  3009. if this.changeMapTimer:
  3010. try:
  3011. this.changeMapTimer.cancel()
  3012. except:
  3013. this.changeMapTimer = None
  3014. if not this.canChangeMap:
  3015. this.changeMapAttemps += 1
  3016. if this.changeMapAttemps < 5:
  3017. this.changeMapTimer = reactor.callLater(1, this.mapChange)
  3018. return
  3019. if this.killAfkTimer:
  3020. try:
  3021. this.killAfkTimer.cancel()
  3022. except:
  3023. this.killAfkTimer = None
  3024. if this.autoRespawnTimer:
  3025. try:
  3026. this.autoRespawnTimer.cancel()
  3027. except:
  3028. this.autoRespawnTimer = None
  3029. if this.startTimerLeft:
  3030. try:
  3031. this.startTimerLeft.cancel()
  3032. except:
  3033. this.startTimerLeft = None
  3034. this.checkSuspectHacks()
  3035. this.suspectHacks = []
  3036. if this.isSurvivor:
  3037. for client in this.clients.values():
  3038. if not client.isDead and (not client.isVampire if this.isSurvivorVamp else not client.isShaman):
  3039. if not this.noAutoScore: client.playerScore += 10
  3040. if this.catchTheCheeseMap:
  3041. this.catchTheCheeseMap = False
  3042. else:
  3043. numCom2 = 0
  3044. if this.isDoubleMap:
  3045. numCom = this.FSnumCompleted - 1
  3046. numCom2 = this.SSnumCompleted - 1
  3047. else:
  3048. numCom = this.numCompleted - 1
  3049. if numCom < 0:
  3050. numCom = 0
  3051. if numCom2 < 0:
  3052. numCom2 = 0
  3053. player = this.clients.get(this.currentShamanName)
  3054. if player != None:
  3055. this.sendAll(Identifiers.old.send.Shaman_Perfomance, [this.currentShamanName, numCom])
  3056. if not this.noAutoScore: player.playerScore = numCom
  3057. if numCom > 0:
  3058. player.skillModule.getPlayerExp(True, numCom)
  3059. player2 = this.clients.get(this.currentSecondShamanName)
  3060. if player2 != None:
  3061. this.sendAll(Identifiers.old.send.Shaman_Perfomance, [this.currentSecondShamanName, numCom2])
  3062. if not this.noAutoScore: player2.playerScore = numCom2
  3063. if numCom2 > 0:
  3064. player2.skillModule.getPlayerExp(True, numCom2)
  3065. if this.isSurvivor and this.getPlayerCount() >= this.server.needToFirst:
  3066. this.giveSurvivorStats()
  3067. elif this.isRacing and this.getPlayerCount() >= this.server.needToFirst:
  3068. this.giveRacingStats()
  3069. this.currentSyncCode = -1
  3070. this.currentSyncName = ""
  3071. this.currentShamanCode = -1
  3072. this.currentSecondShamanCode = -1
  3073. this.currentShamanName = ""
  3074. this.currentSecondShamanName = ""
  3075. this.currentShamanType = -1
  3076. this.currentSecondShamanType = -1
  3077. this.currentShamanSkills = {}
  3078. this.currentSecondShamanSkills = {}
  3079. this.changed20secTimer = False
  3080. this.isDoubleMap = False
  3081. this.isNoShamanMap = False
  3082. this.FSnumCompleted = 0
  3083. this.SSnumCompleted = 0
  3084. this.numCompleted = 0
  3085. this.iceEnabled = False
  3086. this.iceCount = 2
  3087. this.objectID = 0
  3088. this.tempTotemCount = -1
  3089. this.addTime = 0
  3090. this.cloudID = -1
  3091. this.companionBox = -1
  3092. this.lastHandymouse = [-1, -1]
  3093. this.isTribeHouseMap = False
  3094. this.canChangeMap = True
  3095. this.changeMapAttemps = 0
  3096. this.getSyncCode()
  3097. this.anchors = []
  3098. this.mapStatus += 1
  3099. this.mapStatus %= 13
  3100. this.musicMapStatus += 1
  3101. this.musicMapStatus %= 6
  3102. this.survivorMapStatus += 1
  3103. this.survivorMapStatus %= 11
  3104. this.isRacingP17 = not this.isRacingP17
  3105. this.isBootcampP13 = not this.isBootcampP13
  3106. this.currentMap = this.selectMap()
  3107. this.checkVanillaXML()
  3108. if this.currentMap in [44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 138, 139, 140, 141, 142, 143] or this.mapPerma == 8 and this.getPlayerCount() >= 1:
  3109. this.isDoubleMap = True
  3110. if this.mapPerma == 7 or this.isSurvivorVamp:
  3111. this.isNoShamanMap = True
  3112. if this.currentMap in [108, 109, 110, 111, 112, 113]:
  3113. this.catchTheCheeseMap = True
  3114. this.gameStartTime = TFMUtils.getTime()
  3115. this.gameStartTimeMillis = time.time()
  3116. this.isCurrentlyPlay = False
  3117. if not this.isFixedMap:
  3118. this.changeMapTimer = reactor.callLater(this.roundTime, this.mapChange)
  3119. for client in this.clients.values():
  3120. client.resetPlay()
  3121. for client in this.clients.values():
  3122. client.startPlay()
  3123. if client.isHidden:
  3124. client.sendPlayerDisconnect()
  3125. this.startTimerLeft = reactor.callLater(3, this.startTimer)
  3126. if this.isSurvivorVamp:
  3127. reactor.callLater(5, this.sendVampireMode)
  3128. if this.isMulodrome:
  3129. this.mulodromeRoundCount += 1
  3130. this.sendMulodromeRound()
  3131. if this.mulodromeRoundCount <= 10:
  3132. for client in this.clients.values():
  3133. if client.Username in this.blueTeam:
  3134. this.setNameColor(client.Username, int("979EFF", 16))
  3135. else:
  3136. this.setNameColor(client.Username, int("FF9396", 16))
  3137. else:
  3138. this.sendAllBin(Identifiers.send.Mulodrome_End, "")
  3139. if this.isRacing or this.isDefilante:
  3140. this.roundsCount += 1
  3141. this.roundsCount %= 10
  3142. this.sendAllBin(Identifiers.send.Rounds_Count, ByteArray().writeByte(this.roundsCount).writeInt(this.getHighestScore()).toByteArray())
  3143. this.closeRoomRoundJoinTimer = reactor.callLater(3, setattr, this, "isCurrentlyPlay", True)
  3144. this.killAfkTimer = reactor.callLater(30, this.killAfk)
  3145. if this.autoRespawn or this.isTribeHouseMap:
  3146. this.autoRespawnTimer = reactor.callLater(5, this.respawnMice)
  3147.  
  3148. def getPlayerCount(this):
  3149. return len(this.clients.values())
  3150.  
  3151. def getPlayerCountUnique(this):
  3152. ipList = []
  3153. for client in this.clients.values():
  3154. if not client.ipAddress in ipList:
  3155. ipList.append(client.ipAddress)
  3156. return len(ipList)
  3157.  
  3158. def getPlayerList(this):
  3159. result = []
  3160. for client in this.clients.values():
  3161. result.append(client.getPlayerData())
  3162. return result
  3163.  
  3164. def addClient(this, client):
  3165. this.clients[client.Username] = client
  3166.  
  3167. client.room = this
  3168. client.isDead = this.isCurrentlyPlay
  3169. this.sendAllOthers(client, Identifiers.old.send.Player_Respawn, [client.getPlayerData()])
  3170. client.startPlay()
  3171.  
  3172. def removeClient(this, client):
  3173. if client.Username in this.clients:
  3174. del this.clients[client.Username]
  3175.  
  3176. client.resetPlay()
  3177. client.playerScore = 0
  3178.  
  3179. client.sendPlayerDisconnect()
  3180.  
  3181. if this.isMulodrome:
  3182. if client.Username in this.redTeam: this.redTeam.remove(client.Username)
  3183. if client.Username in this.blueTeam: this.blueTeam.remove(client.Username)
  3184.  
  3185. if len(this.redTeam) == 0 and len(this.blueTeam) == 0:
  3186. this.mulodromeRoundCount = 10
  3187. this.sendMulodromeRound()
  3188.  
  3189. if len(this.clients) == 0:
  3190. #for timer in [this.autoRespawnTimer, this.changeMapTimer, this.closeRoomRoundJoinTimer, this.endSnowTimer, this.killAfkTimer, this.voteCloseTimer]:
  3191. # if timer != None:
  3192. # timer.cancel()
  3193.  
  3194. this.isClosed = True
  3195. del this.server.rooms[this.name]
  3196. else:
  3197. if client.playerCode == this.currentSyncCode:
  3198. this.currentSyncCode = -1
  3199. this.currentSyncName = ""
  3200. this.getSyncCode()
  3201. for clientOnline in this.clients.values():
  3202. clientOnline.sendSync(this.currentSyncCode)
  3203. if clientOnline.playerCode == this.currentSyncCode:
  3204. clientOnline.isSync = True
  3205.  
  3206. this.checkShouldChangeMap()
  3207.  
  3208. def checkShouldChangeMap(this):
  3209. if this.isBootcamp or this.autoRespawn or this.isFixedMap:
  3210. pass
  3211. else:
  3212. allDead = True
  3213. for client in this.clients.values():
  3214. if not client.isDead:
  3215. allDead = False
  3216.  
  3217. if allDead:
  3218. this.mapChange()
  3219.  
  3220. def sendAllOthers(this, senderClient, Tokens, packet=""):
  3221. for client in this.clients.values():
  3222. if not client == senderClient:
  3223. client.sendPacket(Tokens, packet)
  3224.  
  3225. def sendAll(this, identifiers, packet=""):
  3226. for client in this.clients.values():
  3227. client.sendPacket(identifiers, packet)
  3228.  
  3229. def sendAllBin(this, Tokens, packet):
  3230. for client in this.clients.values():
  3231. client.sendPacket(Tokens, packet, True)
  3232.  
  3233. def sendAllOthersBin(this, senderClient, Tokens, packet):
  3234. for client in this.clients.values():
  3235. if not client == senderClient:
  3236. client.sendPacket(Tokens, packet, True)
  3237.  
  3238. def sendAllChat(this, playerCode, playerName, message, LangueByte, isOnly):
  3239. p = ByteArray().writeInt(playerCode).writeUTF(playerName).writeByte(LangueByte).writeUTF(message)
  3240. if not isOnly:
  3241. for client in this.clients.values():
  3242. client.sendPacket(Identifiers.send.All_Chat, p.toByteArray(), True)
  3243. else:
  3244. client = this.clients.get(playerName)
  3245. if client != None:
  3246. client.sendPacket(Identifiers.send.All_Chat, p.toByteArray(), True)
  3247.  
  3248. def getSyncCode(this):
  3249. if this.getPlayerCount() > 0:
  3250. if this.currentSyncCode == -1:
  3251. players = this.clients
  3252. values = players.values()
  3253. client = random.choice(values)
  3254. this.currentSyncCode = client.playerCode
  3255. this.currentSyncName = client.Username
  3256. else:
  3257. if this.currentSyncCode == -1:
  3258. this.currentSyncCode = 0
  3259. this.currentSyncName = ""
  3260.  
  3261. return this.currentSyncCode
  3262.  
  3263. def selectMap(this):
  3264. if not this.forceNextMap == "-1":
  3265. force = this.forceNextMap
  3266. this.forceNextMap = "-1"
  3267. this.mapCode = -1
  3268.  
  3269. if force.isdigit():
  3270. return this.selectMapSpecificic(force, "Vanilla")
  3271. elif force.startswith("@"):
  3272. return this.selectMapSpecificic(force[1:], "Custom")
  3273. elif force.startswith("#"):
  3274. return this.selectMapSpecificic(force[1:], "Perm")
  3275. elif force.startswith("<"):
  3276. return this.selectMapSpecificic(force, "Xml")
  3277. else:
  3278. return 0
  3279.  
  3280. elif this.specificMap:
  3281. this.mapCode = -1
  3282. return this.currentMap
  3283. else:
  3284. if this.isEditeur:
  3285. return this.EMapCode
  3286.  
  3287. elif this.isTribeHouse:
  3288. tribeName = this.roomName[2:]
  3289. runMap = this.server.getTribeHouse(tribeName)
  3290.  
  3291. if runMap == 0:
  3292. this.mapCode = 0
  3293. this.mapName = "Tigrounette"
  3294. this.mapXML = "<C><P /><Z><S><S Y=\"360\" T=\"0\" P=\"0,0,0.3,0.2,0,0,0,0\" L=\"800\" H=\"80\" X=\"400\" /></S><D><P Y=\"0\" T=\"34\" P=\"0,0\" X=\"0\" C=\"719b9f\" /><T Y=\"320\" X=\"49\" /><P Y=\"320\" T=\"16\" X=\"224\" P=\"0,0\" /><P Y=\"319\" T=\"17\" X=\"311\" P=\"0,0\" /><P Y=\"284\" T=\"18\" P=\"1,0\" X=\"337\" C=\"57703e,e7c3d6\" /><P Y=\"284\" T=\"21\" X=\"294\" P=\"0,0\" /><P Y=\"134\" T=\"23\" X=\"135\" P=\"0,0\" /><P Y=\"320\" T=\"24\" P=\"0,1\" X=\"677\" C=\"46788e\" /><P Y=\"320\" T=\"26\" X=\"588\" P=\"1,0\" /><P Y=\"193\" T=\"14\" P=\"0,0\" X=\"562\" C=\"95311e,bde8f3,faf1b3\" /></D><O /></Z></C>"
  3295. this.mapYesVotes = 0
  3296. this.mapNoVotes = 0
  3297. this.mapPerma = 22
  3298. this.mapInverted = False
  3299. else:
  3300. run = this.selectMapSpecificic(runMap, "Custom")
  3301. if run != -1:
  3302. this.mapCode = 0
  3303. this.mapName = "Tigrounette"
  3304. this.mapXML = "<C><P /><Z><S><S Y=\"360\" T=\"0\" P=\"0,0,0.3,0.2,0,0,0,0\" L=\"800\" H=\"80\" X=\"400\" /></S><D><P Y=\"0\" T=\"34\" P=\"0,0\" X=\"0\" C=\"719b9f\" /><T Y=\"320\" X=\"49\" /><P Y=\"320\" T=\"16\" X=\"224\" P=\"0,0\" /><P Y=\"319\" T=\"17\" X=\"311\" P=\"0,0\" /><P Y=\"284\" T=\"18\" P=\"1,0\" X=\"337\" C=\"57703e,e7c3d6\" /><P Y=\"284\" T=\"21\" X=\"294\" P=\"0,0\" /><P Y=\"134\" T=\"23\" X=\"135\" P=\"0,0\" /><P Y=\"320\" T=\"24\" P=\"0,1\" X=\"677\" C=\"46788e\" /><P Y=\"320\" T=\"26\" X=\"588\" P=\"1,0\" /><P Y=\"193\" T=\"14\" P=\"0,0\" X=\"562\" C=\"95311e,bde8f3,faf1b3\" /></D><O /></Z></C>"
  3305. this.mapYesVotes = 0
  3306. this.mapNoVotes = 0
  3307. this.mapPerma = 22
  3308. this.mapInverted = False
  3309.  
  3310. elif this.is801Room:
  3311. return this.getMap801("801", "801", 801, "_Atelier 801")
  3312.  
  3313. elif this.isVillage:
  3314. return this.getMap801("801", "801", 801, "_Village")
  3315.  
  3316. elif this.isVanilla:
  3317. this.mapCode = -1
  3318. this.mapName = "Invalid";
  3319. this.mapXML = "<C><P /><Z><S /><D /><O /></Z></C>"
  3320. this.mapYesVotes = 0
  3321. this.mapNoVotes = 0
  3322. this.mapPerma = -1
  3323. this.mapInverted = False
  3324. map = random.choice(this.MapList)
  3325. while map == this.currentMap:
  3326. map = random.choice(this.MapList)
  3327. return map
  3328.  
  3329. else:
  3330. this.mapCode = -1
  3331. this.mapName = "Invalid";
  3332. this.mapXML = "<C><P /><Z><S /><D /><O /></Z></C>"
  3333. this.mapYesVotes = 0
  3334. this.mapNoVotes = 0
  3335. this.mapPerma = -1
  3336. this.mapInverted = False
  3337. return this.selectMapStatus(this.mapStatus)
  3338. return -1
  3339.  
  3340. def selectMapStatus(this, mapStatus):
  3341. customMaps = [1, 2, 3, 5, 6, 7, 9, 10, 11]
  3342. mapList = []
  3343.  
  3344. if this.isVanilla:
  3345. map = random.choice(this.MapList)
  3346. while map == this.currentMap:
  3347. map = random.choice(this.MapList)
  3348. return map
  3349.  
  3350. elif this.isMusic:
  3351. if this.musicMapStatus == 5:
  3352. this.Cursor.execute("select Code from MapEditor where Perma = 19")
  3353. r = this.Cursor.fetchall()
  3354. for rs in r:
  3355. mapList.append(rs[0])
  3356.  
  3357. elif this.isRacing:
  3358. P7List = []
  3359. P17List = []
  3360.  
  3361. this.Cursor.execute("select Code, Perma from MapEditor where Perma = 7 or Perma = 17")
  3362. r = this.Cursor.fetchall()
  3363. for rs in r:
  3364. perma = rs[1]
  3365. if perma == 7:
  3366. P7List.append(rs[0])
  3367. else:
  3368. P17List.append(rs[0])
  3369.  
  3370. if this.isRacingP17 or this.isMulodrome:
  3371. mapList = P7List if len(P17List) == 0 else P17List
  3372. else:
  3373. mapList = P17List if len(P7List) == 0 else P7List
  3374.  
  3375. elif this.isBootcamp:
  3376. P3List = []
  3377. P13List = []
  3378.  
  3379. this.Cursor.execute("select Code, Perma from MapEditor where Perma = 3 or Perma = 13")
  3380. r = this.Cursor.fetchall()
  3381. for rs in r:
  3382. perma = rs[1]
  3383. if perma == 3:
  3384. P3List.append(rs[0])
  3385. else:
  3386. P13List.append(rs[0])
  3387.  
  3388. if this.isBootcampP13:
  3389. mapList = P3List if len(P13List) == 0 else P13List
  3390. else:
  3391. mapList = P13List if len(P3List) == 0 else P3List
  3392.  
  3393. elif this.isSurvivor:
  3394. this.isSurvivorVamp = this.survivorMapStatus == 10
  3395.  
  3396. this.Cursor.execute("select Code from MapEditor where Perma = ?", [11 if this.isSurvivorVamp else 10])
  3397. r = this.Cursor.fetchall()
  3398. for rs in r:
  3399. mapList.append(rs[0])
  3400.  
  3401. elif this.isDefilante:
  3402. this.Cursor.execute("select Code from MapEditor where Perma = 18")
  3403. r = this.Cursor.fetchall()
  3404. for rs in r:
  3405. mapList.append(rs[0])
  3406.  
  3407. elif this.is801Room:
  3408. return 801
  3409.  
  3410. elif this.isVillage:
  3411. return Village
  3412.  
  3413. elif mapStatus in customMaps:
  3414. multiple = False
  3415. selectCode = 0
  3416.  
  3417. if mapStatus == 1 or mapStatus == 9:
  3418. multiple = True
  3419. elif mapStatus == 2:
  3420. selectCode = 5
  3421. elif mapStatus == 3:
  3422. selectCode = 9
  3423. elif mapStatus == 5 or mapStatus == 11:
  3424. selectCode = 6
  3425. elif mapStatus == 6:
  3426. selectCode = 7
  3427. elif mapStatus == 7:
  3428. selectCode = 8
  3429. elif mapStatus == 10:
  3430. selectCode = 4
  3431.  
  3432. if multiple:
  3433. this.Cursor.execute("select Code from MapEditor where Perma = 0")
  3434. r = this.Cursor.fetchall()
  3435. for rs in r:
  3436. mapList.append(rs[0])
  3437.  
  3438. this.Cursor.execute("select Code from MapEditor where Perma = 1")
  3439. r = this.Cursor.fetchall()
  3440. for rs in r:
  3441. mapList.append(rs[0])
  3442. else:
  3443. this.Cursor.execute("select Code from MapEditor where Perma = ?", [selectCode])
  3444. r = this.Cursor.fetchall()
  3445. for rs in r:
  3446. mapList.append(rs[0])
  3447. else:
  3448. map = random.choice(this.MapList)
  3449. while map == this.currentMap:
  3450. map = random.choice(this.MapList)
  3451. return map
  3452.  
  3453. if len(mapList) >= 1:
  3454. runMap = random.choice(mapList)
  3455. else:
  3456. runMap = 0
  3457.  
  3458. if len(mapList) >= 2:
  3459. while runMap == this.currentMap:
  3460. runMap = random.choice(mapList)
  3461.  
  3462. if runMap == 0:
  3463. map = random.choice(this.MapList)
  3464. while map == this.currentMap:
  3465. map = random.choice(this.MapList)
  3466. return map
  3467. else:
  3468. mapInfo = this.getMapInfo(runMap)
  3469. this.mapCode = runMap
  3470. this.mapName = str(mapInfo[0])
  3471. this.mapXML = str(mapInfo[1])
  3472. this.mapYesVotes = int(mapInfo[2])
  3473. this.mapNoVotes = int(mapInfo[3])
  3474. this.mapPerma = int(mapInfo[4])
  3475. this.mapInverted = random.randint(0, 100) > 85
  3476. return -1
  3477.  
  3478. def selectMapSpecificic(this, code, type):
  3479. if type == "Vanilla":
  3480. return int(code)
  3481.  
  3482. elif type == "Custom":
  3483. mapInfo = this.getMapInfo(int(code))
  3484. if mapInfo[0] == None:
  3485. return 0
  3486. else:
  3487. this.mapCode = int(code)
  3488. this.mapName = str(mapInfo[0])
  3489. this.mapXML = str(mapInfo[1])
  3490. this.mapYesVotes = int(mapInfo[2])
  3491. this.mapNoVotes = int(mapInfo[3])
  3492. this.mapPerma = int(mapInfo[4])
  3493. this.mapInverted = False
  3494. return -1
  3495.  
  3496. elif type == "Perm":
  3497. mapList = []
  3498. this.Cursor.execute("SELECT Code FROM MapEditor WHERE Perma = ?", [int(str(code))])
  3499. r = this.Cursor.fetchall()
  3500. for rs in r:
  3501. mapList.append(rs["Code"])
  3502.  
  3503. if len(mapList) >= 1:
  3504. runMap = random.choice(mapList)
  3505. else:
  3506. runMap = 0
  3507.  
  3508. if len(mapList) >= 2:
  3509. while runMap == this.currentMap:
  3510. runMap = random.choice(mapList)
  3511.  
  3512. if runMap == 0:
  3513. map = random.choice(this.MapList)
  3514. while map == this.currentMap:
  3515. map = random.choice(this.MapList)
  3516. return map
  3517. else:
  3518. mapInfo = this.getMapInfo(runMap)
  3519. this.mapCode = runMap
  3520. this.mapName = str(mapInfo[0])
  3521. this.mapXML = str(mapInfo[1])
  3522. this.mapYesVotes = int(mapInfo[2])
  3523. this.mapNoVotes = int(mapInfo[3])
  3524. this.mapPerma = int(mapInfo[4])
  3525. this.mapInverted = False
  3526. return -1
  3527.  
  3528. elif type == "Xml":
  3529. this.mapCode = 0
  3530. this.mapName = "#Module"
  3531. this.mapXML = str(code)
  3532. this.mapYesVotes = 0
  3533. this.mapNoVotes = 0
  3534. this.mapPerma = 22
  3535. this.mapInverted = False
  3536. return -1
  3537.  
  3538. def getMapInfo(this, mapCode):
  3539. mapInfo = ["", "", 0, 0, 0]
  3540. this.Cursor.execute("SELECT Name, XML, YesVotes, NoVotes, Perma from MapEditor where Code = ?", [mapCode])
  3541. rs = this.Cursor.fetchone()
  3542. if rs:
  3543. mapInfo = rs["Name"], rs["XML"], rs["YesVotes"], rs["NoVotes"], rs["Perma"]
  3544.  
  3545. return mapInfo
  3546.  
  3547. def checkDeathCount(this):
  3548. counts = [0, 0]
  3549. for client in this.clients.values():
  3550. counts[0 if client.isDead else 1] += 1
  3551. return counts
  3552.  
  3553. def checkDeathCountNoShaman(this):
  3554. count = 0
  3555. for client in this.clients.values():
  3556. if not client.isShaman and client.isDead and not client.isNewPlayer:
  3557. count += 1
  3558. return count
  3559.  
  3560. def getHighestScore(this):
  3561. scores = []
  3562.  
  3563. for client in this.clients.values():
  3564. scores.append(client.playerScore)
  3565.  
  3566. try:
  3567. for client in this.clients.values():
  3568. if client.playerScore == max(scores):
  3569. return client.playerCode
  3570. except:
  3571. pass
  3572. return 0
  3573.  
  3574. def getSecondHighestScore(this):
  3575. scores = []
  3576.  
  3577. for client in this.clients.values():
  3578. scores.append(client.playerScore)
  3579.  
  3580. scores.remove(max(scores))
  3581.  
  3582. try:
  3583. for client in this.clients.values():
  3584. if client.playerScore == max(scores):
  3585. return client.playerCode
  3586. except:
  3587. pass
  3588. return 0
  3589.  
  3590. def getShamanCode(this):
  3591. if this.currentShamanCode == -1:
  3592. if this.currentMap in this.noShamanMaps or this.isNoShamanMap:
  3593. pass
  3594. elif this.noShaman or this.survivorMapStatus == 7 and this.isSurvivor:
  3595. pass
  3596. else:
  3597. if this.forceNextShaman > 0:
  3598. this.currentShamanCode = this.forceNextShaman
  3599. this.forceNextShaman = 0
  3600. else:
  3601. this.currentShamanCode = this.getHighestScore()
  3602.  
  3603. if this.currentShamanCode == -1:
  3604. this.currentShamanName = ""
  3605. else:
  3606. for client in this.clients.values():
  3607. if client.playerCode == this.currentShamanCode:
  3608. this.currentShamanName = client.Username
  3609. this.currentShamanType = client.shamanType
  3610. this.currentShamanSkills = client.playerSkills
  3611. break
  3612. return this.currentShamanCode
  3613.  
  3614. def getDoubleShamanCode(this):
  3615. if this.currentShamanCode == -1 and this.currentSecondShamanCode == -1:
  3616.  
  3617. if this.forceNextShaman > 0:
  3618. this.currentShamanCode = this.forceNextShaman
  3619. this.forceNextShaman = 0
  3620. else:
  3621. this.currentShamanCode = this.getHighestScore()
  3622.  
  3623. if this.currentSecondShamanCode == -1:
  3624. this.currentSecondShamanCode = this.getSecondHighestScore()
  3625.  
  3626. if this.currentSecondShamanCode == this.currentShamanCode:
  3627. values = this.clients.values()
  3628. tempClient = random.choice(values)
  3629. this.currentSecondShamanCode = tempClient.playerCode
  3630.  
  3631. for client in this.clients.values():
  3632. if client.playerCode == this.currentShamanCode:
  3633. this.currentShamanName = client.Username
  3634. this.currentShamanType = client.shamanType
  3635. this.currentShamanSkills = client.playerSkills
  3636. break
  3637.  
  3638. for client in this.clients.values():
  3639. if client.playerCode == this.currentSecondShamanCode:
  3640. this.currentSecondShamanName = client.Username
  3641. this.currentSecondShamanType = client.shamanType
  3642. this.currentSecondShamanSkills = client.playerSkills
  3643. break
  3644.  
  3645. return [this.currentShamanCode, this.currentSecondShamanCode]
  3646.  
  3647. def closeVoting(this):
  3648. this.initVotingMode = False
  3649. this.isVotingBox = False
  3650. if this.voteCloseTimer != None: this.voteCloseTimer.cancel()
  3651. this.mapChange()
  3652.  
  3653. def killAllNoDie(this):
  3654. for client in this.clients.values():
  3655. if not client.isDead:
  3656. client.isDead = True
  3657. this.checkShouldChangeMap()
  3658.  
  3659. def killAll(this):
  3660. for client in this.clients.values():
  3661. if not client.isDead:
  3662. client.sendPlayerDied()
  3663. client.isDead = True
  3664. this.checkShouldChangeMap()
  3665.  
  3666. def killShaman(this):
  3667. for client in this.clients.values():
  3668. if client.playerCode == this.currentShamanCode:
  3669. client.isDead = True
  3670. client.sendPlayerDied()
  3671. this.checkShouldChangeMap()
  3672.  
  3673. def killAfk(this):
  3674. if this.isEditeur or this.isTotemEditeur or this.isBootcamp or this.isTribeHouseMap or this.disableAfkKill:
  3675. pass
  3676. else:
  3677. if ((TFMUtils.getTime() - this.gameStartTime) < 32 and (TFMUtils.getTime() - this.gameStartTime) > 28):
  3678. for client in this.clients.values():
  3679. if not client.isDead and client.isAfk:
  3680. client.isDead = True
  3681. if not this.noAutoScore: client.playerScore += 1
  3682. client.sendPlayerDied()
  3683. this.checkShouldChangeMap()
  3684.  
  3685. def checkIfDoubleShamansAreDead(this):
  3686. client1 = this.clients.get(this.currentShamanName)
  3687. client2 = this.clients.get(this.currentSecondShamanName)
  3688. return (False if client1 == None else client1.isDead) and (False if client2 == None else client2.isDead)
  3689.  
  3690. def checkIfShamanIsDead(this):
  3691. client = this.clients.get(this.currentShamanName)
  3692. return False if client == None else client.isDead
  3693.  
  3694. def getAliveCount(this):
  3695. return len(filter(lambda player: not player.isDead, this.clients.values()))
  3696.  
  3697. def checkIfTooFewRemaining(this):
  3698. count = 0
  3699. for client in this.clients.values():
  3700. if not client.isDead:
  3701. count += 1
  3702.  
  3703. if this.getPlayerCount() >= 3:
  3704. if count <= 2:
  3705. return True
  3706. return False
  3707.  
  3708. def checkIfShamanCanGoIn(this):
  3709. for client in this.clients.values():
  3710. if client.playerCode != this.currentShamanCode:
  3711. if not client.isDead:
  3712. return False
  3713. return True
  3714.  
  3715. def checkIfDoubleShamanCanGoIn(this):
  3716. for client in this.clients.values():
  3717. if client.playerCode != this.currentShamanCode and client.playerCode != this.currentSecondShamanCode:
  3718. if not client.isDead:
  3719. return False
  3720. return True
  3721.  
  3722. def giveShamanSave(this, shamanName, type):
  3723. if not this.countStats:
  3724. return
  3725.  
  3726. client = this.clients.get(shamanName)
  3727. if client != None:
  3728. if type == 0:
  3729. client.shamanSaves += 1
  3730. elif type == 1:
  3731. client.hardModeSaves += 1
  3732. elif type == 2:
  3733. client.divineModeSaves += 1
  3734.  
  3735. if client.privLevel != 0:
  3736. counts = [client.shamanSaves, client.hardModeSaves, client.divineModeSaves]
  3737. checks = [this.server.ShamanTitleListCheck, this.server.HardModeTitleListCheck, this.server.DivineModeTitleListCheck]
  3738. titles = [this.server.ShamanTitleList, this.server.HardModeTitleList, this.server.DivineModeTitleList]
  3739. rebuilds = ["shaman", "hardmode", "divinemode"]
  3740.  
  3741. if counts[type] in checks[type]:
  3742. unlockedTitle = titles[type][counts[type]]
  3743. stitle = str(unlockedTitle).split(".")
  3744.  
  3745. client.checkAndRebuildTitleList(rebuilds[type])
  3746. client.sendUnlockedTitle(stitle[0], stitle[1])
  3747.  
  3748. client.sendCompleteTitleList()
  3749. client.sendTitleList()
  3750.  
  3751. def respawnMice(this):
  3752. for client in this.clients.values():
  3753. if client.isDead:
  3754. client.isDead = False
  3755. client.playerStartTimeMillis = time.time()
  3756. this.sendAll(Identifiers.old.send.Player_Respawn, [client.getPlayerData(), 0 if this.isBootcamp else 1])
  3757.  
  3758. if this.autoRespawn:
  3759. this.autoRespawnTimer = reactor.callLater(2, this.respawnMice)
  3760.  
  3761. def respawnSpecific(this, playerName, isResetPlay=False):
  3762. client = this.clients.get(playerName)
  3763. if client != None and client.isDead:
  3764. client.resetPlay(isResetPlay)
  3765. client.isAfk = False
  3766. client.playerStartTimeMillis = time.time()
  3767. this.sendAll(Identifiers.old.send.Player_Respawn, [client.getPlayerData(), 0 if this.isBootcamp else 1])
  3768.  
  3769. def sendMulodromeRound(this):
  3770. this.sendAllBin(Identifiers.send.Mulodrome_Result, ByteArray().writeByte(this.mulodromeRoundCount).writeShort(this.blueCount).writeShort(this.redCount).toByteArray())
  3771.  
  3772. if this.mulodromeRoundCount > 10:
  3773. this.sendAllBin(Identifiers.send.Mulodrome_End, "")
  3774. winner = 2 if this.blueCount == this.redCount else (1 if this.blueCount < this.redCount else 0)
  3775.  
  3776. this.sendAllBin(Identifiers.send.Mulodrome_Winner, ByteArray().writeByte(winner).writeShort(this.blueCount).writeShort(this.redCount).toByteArray())
  3777.  
  3778. this.isMulodrome = False
  3779. this.mulodromeRoundCount = 0
  3780. this.redCount = 0
  3781. this.blueCount = 0
  3782. this.redCount = []
  3783. this.blueCount = []
  3784. this.isRacing = False
  3785. this.mapStatus = 1
  3786. this.never20secTimer = False
  3787. this.noShaman = False
  3788.  
  3789. def checkVanillaXML(this):
  3790. try:
  3791. with open("./Sukelac1/vanilla/"+str(this.currentMap)+".xml", "r") as f:
  3792. XML = f.read()
  3793. f.close()
  3794.  
  3795. this.mapCode = int(this.currentMap)
  3796. this.mapName = "Transformice"
  3797. this.mapXML = str(XML)
  3798. this.mapYesVotes = 0
  3799. this.mapNoVotes = 0
  3800. this.mapPerma = 2
  3801. this.currentMap = -1
  3802. this.mapInverted = False
  3803. except: pass
  3804.  
  3805. def getMap801(this, prefix, map, code, name):
  3806. try:
  3807. with open("./Sukelac1/Atelier801/801.xml", "r") as f:
  3808. XML = f.read()
  3809. f.close()
  3810.  
  3811. this.mapCode = code
  3812. this.mapName = name
  3813. this.mapXML = str(XML)
  3814. this.mapYesVotes = 0
  3815. this.mapNoVotes = 0
  3816. this.mapPerma = 41
  3817. this.currentMap = -1
  3818. this.mapInverted = False
  3819. except: pass
  3820.  
  3821. def sendVampireMode(this):
  3822. client = this.clients.get(this.currentSyncName)
  3823. if client != None:
  3824. client.sendVampireMode(False)
  3825.  
  3826. def addImage(this, imageName, target, xPosition, yPosition, targetPlayer):
  3827. target = target[1:]
  3828. p = ByteArray().writeInt(this.lastImageID + 1).writeUTF(imageName).writeByte(1 if target.startswith("#") else 2 if target.startswith("$") else 3 if target.startswith("%") else 4 if target.startswith("?") else 5 if target.startswith("_") else 6 if target.startswith("!") else 7 if target.startswith("&") else 0).writeInt(int(target) if target.isdigit() else this.server.getPlayerCode(target)).writeShort(xPosition).writeShort(yPosition)
  3829. if targetPlayer == "":
  3830. this.sendAllBin(Identifiers.send.Add_Image, p.toByteArray())
  3831. else:
  3832. client = this.clients.get(playerName)
  3833. if client != None:
  3834. client.sendPacket(Identifiers.send.Add_Image, p.toByteArray(), True)
  3835.  
  3836. def bindKeyBoard(this, playerName, key, down, yes):
  3837. client = this.clients.get(playerName)
  3838. if client != None:
  3839. client.sendPacket(Identifiers.send.Bind_Key_Board, ByteArray().writeShort(key).writeBool(down).writeBool(yes).toByteArray(), True)
  3840.  
  3841. def chatMessage(this, message, playerName):
  3842. p = ByteArray().writeUTF(message)
  3843. if playerName == "":
  3844. this.sendAllBin(Identifiers.send.Message, p.toByteArray())
  3845. else:
  3846. client = this.clients.get(playerName)
  3847. if client != None:
  3848. client.sendPacket(Identifiers.send.Message, p.toByteArray(), True)
  3849.  
  3850. def movePlayer(this, playerName, xPosition, yPosition, pOffSet, xSpeed, ySpeed, sOffSet):
  3851. client = this.clients.get(playerName)
  3852. if client != None:
  3853. client.sendPacket(Identifiers.send.Move_Player, ByteArray().writeShort(xPosition).writeShort(yPosition).writeBool(pOffSet).writeShort(xSpeed).writeShort(ySpeed).writeBool(sOffSet).toByteArray(), True)
  3854.  
  3855. def removeObject(this, objectId):
  3856. this.sendAllBin(Identifiers.send.Remove_Object, ByteArray().writeInt(objectId).writeBool(True).toByteArray())
  3857.  
  3858. def setNameColor(this, playerName, color):
  3859. if this.clients.has_key(playerName):
  3860. this.sendAllBin(Identifiers.send.Set_Name_Color, ByteArray().writeInt(this.clients.get(playerName).playerCode).writeInt(color).toByteArray())
  3861.  
  3862. def setPlayerScore(this, playerCode, score):
  3863. this.sendAllBin(Identifiers.send.Set_Player_Score, ByteArray().writeInt(playerCode).writeShort(score).toByteArray())
  3864.  
  3865. def setUIMapName(this, text):
  3866. this.sendAllBin(Identifiers.send.Set_UI_Map_Name, ByteArray().writeUTF(text).toByteArray())
  3867.  
  3868. def setUIShamanName(this, text):
  3869. this.sendAllBin(Identifiers.send.Set_UI_Shaman_Name, ByteArray().writeUTF(text).toByteArray())
  3870.  
  3871. def bindMouse(this, playerName, yes):
  3872. client = this.clients.get(playerName)
  3873. if client != None:
  3874. client.sendPacket(Identifiers.send.Bind_Mouse, ByteArray().writeBool(yes).toByteArray(), True)
  3875.  
  3876. def addPopup(this, id, type, text, targetPlayer, x, y, width, fixedPos):
  3877. p = ByteArray().writeInt(id).witeByte(type).witeUTF(text).writeShort(x).writeShort(y).writeShort(width).writeBool(fixedPos)
  3878. if targetPlayer == "":
  3879. this.sendAllBin(Identifiers.send.Add_Popup, p.toByteArray())
  3880. else:
  3881. client = this.clients.get(targetPlayer)
  3882. if client != None:
  3883. client.sendPacket(Identifiers.send.Add_Popup, p.toByteArray(), True)
  3884.  
  3885. def addTextArea(this, id, text, targetPlayer, x, y, width, height, backgroundColor, borderColor, backgroundAlpha, fixedPos):
  3886. p = ByteArray().writeInt(id).writeUTF(text).writeShort(x).writeShort(y).writeShort(width).writeShort(height).writeInt(backgroundColor).writeInt(borderColor).writeByte(100 if backgroundAlpha > 100 else backgroundAlpha).writeBool(fixedPos)
  3887. if targetPlayer == "":
  3888. this.sendAllBin(Identifiers.send.Add_Text_Area, p.toByteArray())
  3889. else:
  3890. client = this.clients.get(targetPlayer)
  3891. if client != None:
  3892. client.sendPacket(Identifiers.send.Add_Text_Area, p.toByteArray(), True)
  3893.  
  3894. def removeTextArea(this, id, targetPlayer):
  3895. p = ByteArray().writeInt(id)
  3896. if targetPlayer == "":
  3897. this.sendAllBin(Identifiers.send.Remove_Text_Area, p.toByteArray())
  3898. else:
  3899. client = this.clients.get(targetPlayer)
  3900. if client != None:
  3901. client.sendPacket(Identifiers.send.Remove_Text_Area, p.toByteArray(), True)
  3902.  
  3903. def updateTextArea(this, id, text, targetPlayer):
  3904. p = ByteArray().writeInt(id).writeUTF(text)
  3905. if targetPlayer == "":
  3906. this.sendAllBin(Identifiers.send.Update_Text_Area, p.toByteArray())
  3907. else:
  3908. client = this.clients.get(targetPlayer)
  3909. if client != None:
  3910. client.sendPacket(Identifiers.send.Update_Text_Area, p.toByteArray(), True)
  3911.  
  3912. def startSnow(this, millis, power, enabled):
  3913. this.isSnowing = enabled
  3914. this.sendAllBin(Identifiers.send.Snow, ByteArray().writeBool(enabled).writeShort(power).toByteArray())
  3915. if enabled:
  3916. if this.isSnowing:
  3917. this.endSnowTimer = reactor.callLater(millis, lambda: this.startSnow(0, power, False))
  3918.  
  3919. def giveSurvivorStats(this):
  3920. for client in this.clients.values():
  3921. if not client.isNewPlayer:
  3922. client.survivorStats[0] += 1
  3923. if client.isShaman:
  3924. client.survivorStats[1] += 1
  3925. client.survivorStats[2] += this.checkDeathCountNoShaman()
  3926. elif not client.isDead:
  3927. client.survivorStats[3] += 1
  3928.  
  3929. if client.survivorStats[0] == 1000 and not 120 in client.shopBadges:
  3930. client.shopModule.sendUnlockedBadge(120)
  3931. client.shopBadges.append(120)
  3932.  
  3933. if client.survivorStats[1] == 800 and not 121 in client.shopBadges:
  3934. client.shopModule.sendUnlockedBadge(121)
  3935. client.shopBadges.append(121)
  3936.  
  3937. if client.survivorStats[2] == 20000 and not 122 in client.shopBadges:
  3938. client.shopModule.sendUnlockedBadge(122)
  3939. client.shopBadges.append(122)
  3940.  
  3941. if client.survivorStats[3] == 10000 and not 123 in client.shopBadges:
  3942. client.shopModule.sendUnlockedBadge(123)
  3943. client.shopBadges.append(123)
  3944.  
  3945. def giveRacingStats(this):
  3946. for client in this.clients.values():
  3947. if not client.isNewPlayer:
  3948. client.racingStats[0] += 3
  3949. if client.hasCheese or client.hasEnter:
  3950. client.racingStats[1] += 3
  3951.  
  3952. if client.hasEnter:
  3953. if client.currentPlace <= 3:
  3954. client.racingStats[2] += 3
  3955.  
  3956. if client.currentPlace == 3:
  3957. client.racingStats[3] += 3
  3958.  
  3959. if client.racingStats[0] == 1500 and not 124 in client.shopBadges:
  3960. client.shopModule.sendUnlockedBadge(124)
  3961. client.shopBadges.append(124)
  3962.  
  3963. if client.racingStats[1] == 10000 and not 125 in client.shopBadges:
  3964. client.shopModule.sendUnlockedBadge(125)
  3965. client.shopBadges.append(125)
  3966.  
  3967. if client.racingStats[2] == 10000 and not 127 in client.shopBadges:
  3968. client.shopModule.sendUnlockedBadge(127)
  3969. client.shopBadges.append(127)
  3970.  
  3971. if client.racingStats[3] == 10000 and not 126 in client.shopBadges:
  3972. client.shopModule.sendUnlockedBadge(126)
  3973. client.shopBadges.append(126)
  3974.  
  3975. def checkSuspectHacks(this):
  3976. if this.getPlayerCountUnique() >= this.server.needToFirst and this.countStats:
  3977. if len(this.suspectHacks) < this.getPlayerCount() / 3:
  3978. for client in this.suspectHacks:
  3979. this.server.sendModMessage(7, "Player <V>"+client.Username+"<BL> Foi Kikado Do Servidor.")
  3980. client.sendPlayerBan(0, "Atividade Suspeita.", False)
  3981.  
  3982. def send20SecRemainingTimer(this):
  3983. if not this.changed20secTimer:
  3984. this.changed20secTimer = True
  3985. calc = this.roundTime + (this.gameStartTime - TFMUtils.getTime())
  3986.  
  3987. if this.never20secTimer or calc < 21 or this.roundTime == 0 or this.isEditeur:
  3988. pass
  3989. else:
  3990. this.sendAll(Identifiers.send.Time_15Sec, [])
  3991. if this.changeMapTimer != None: this.changeMapTimer.cancel()
  3992. this.changeMapTimer = reactor.callLater(20, this.mapChange)
  3993. for client in this.clients.values():
  3994. client.sendRoundTime(15)
  3995.  
  3996. def changeMapTimers(this, seconds):
  3997. if this.changeMapTimer != None: this.changeMapTimer.cancel()
  3998. this.changeMapTimer = reactor.callLater(seconds, this.mapChange)
  3999.  
  4000. def newConsumableTimer(this, objectID):
  4001. this.roomTimers.append(reactor.callLater(10, lambda: this.removeObject(objectID)))
  4002.  
  4003. if __name__ == "__main__":
  4004. os.system("title Source 1.368")
  4005. os.system('color FC')
  4006. TFM = Server()
  4007. iniports = []
  4008. for port in [443, 44440, 44444, 5555, 3724, 6112]:
  4009. try:
  4010. reactor.listenTCP(port, TFM)
  4011. iniports.append(port)
  4012. except: pass
  4013. print(""+str(iniports).center(79))
  4014. print("================================================================================")
  4015. print(" MiceBolt")
  4016. print("================================================================================")
  4017. print(" 1.368 Version")
  4018. print("================================================================================")
  4019. print(" Musica Adicionado ")
  4020. print("================================================================================")
  4021. print(" Lag %0")
  4022. print("================================================================================")
  4023. print(" %100 Brasileiro ")
  4024. print("================================================================================")
  4025. reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement