Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.20 KB | None | 0 0
  1. from phBot import *
  2. from threading import Timer
  3. import QtBind
  4. import struct
  5. import json
  6. import os
  7.  
  8. # ------------------------------ xControl ~ by ProjeXNET ------------------------------
  9.  
  10. # Character Info
  11. playerData = None
  12.  
  13. # Plugins\xControl path
  14. folderSave = os.path.dirname(os.path.realpath(__file__))+"\\xControl"
  15.  
  16. # Initializing GUI
  17. gui = QtBind.init(__name__,'xControl (EN)')
  18. lblControl = QtBind.createLabel(gui,'Plugin usefull for manage partys. one char or group of characters, by #GeneralChat, #PartyChat or #PrivateMessage\n\n The "Leader(s)" is the character that write commands.\n Them that have the Leader(s) into the list and has receive the message with the command, will execute the function of it.\n\n ➤ ENABLE : Enable #ATTACKs mode\n ➤ DISABLE : Disable #ATTACKs mode\n ➤ ATTACK : Attacking with " Normal Attack " what the leader has previously attacked if is into the range\n ➤ ATTACKS : Same attack mode but using skills from the Skill(s) list \n ➤ STOP : Stop attacking any target\n ➤ INJECT #Opcode #Encrypted #Data : Inject a #Packet. Ex: "INJECT 3091 0" or "INJECT 3091 False 0" ( mean greet )\n ➤ STARTB : Start bot\n ➤ STOPB : Stop Bot\n ➤ TRACE : Start #Trace to leader (nick dont required) or another\n ➤ STOPT : Stop #Trace\n ➤ SIT : Sit or Stand up, depends\n ➤ CAPE #Colour : Use PVP Cape. Ex: "CAPE White" or "CAPE Off"\n ➤ USEZERK : Use #Berserker mode if available\n ➤ USERETURN : Use some " Return Scroll " from inventory',21,11)
  19. cbxEnableAttack = QtBind.createCheckBox(gui, 'cbxEnableAttack_clicked','Enable #ATTACKs',610,10)
  20. cbxEnableAttack_checked = False
  21.  
  22. lblLeaders = QtBind.createLabel(gui,'♯ Leaders list',351,161)
  23. tbxLeaders = QtBind.createLineEdit(gui,"",351,179,100,20)
  24. lstLeaders = QtBind.createList(gui,351,200,176,60)
  25. btnAddLeader = QtBind.createButton(gui,'btnAddLeader_clicked'," Add ",452,178)
  26. btnRemLeader = QtBind.createButton(gui,'btnRemLeader_clicked'," Remove ",400,259)
  27.  
  28. lblSkills = QtBind.createLabel(gui,'♯ Skills list',540,161)
  29. lstSkills = QtBind.createList(gui,540,200,181,60)
  30. cbxRecSkills = QtBind.createCheckBox(gui, 'cbxRecSkills_clicked','Record #Skill',542,179)
  31. cbxRecSkills_checked = False
  32. btnRemSkills = QtBind.createButton(gui,'btnRemSkills_clicked'," Remove ",645,178)
  33. lblTarget = QtBind.createLabel(gui,'TargetID : None',540,264)
  34. cbxDefensive = QtBind.createCheckBox(gui, 'cbxDefensive_clicked','Defensive',654,263)
  35. cbxDefensive_checked = False
  36. cbxSkillsOrder = QtBind.createCheckBox(gui,'cbxSkillsOrder_clicked','Orderly.',520,115)
  37. cbxSkillsRandom = QtBind.createCheckBox(gui,'cbxSkillsRandom_clicked','Random',590,115)
  38. QtBind.setChecked(gui,cbxSkillsOrder,True) # Use like radiobutton
  39. cbxSkillsRandom_checked = False
  40.  
  41. # Sync Mode #ATTACKs
  42. SelectedTargetID = None
  43. ModeAttack = False
  44. useSkills = False
  45. dataSkills = []
  46.  
  47. log('Plugins: xControl Plugin Successfully loaded ~ by ProjeXNET')
  48. # Create folder for save configs
  49. if not os.path.exists(folderSave):
  50. os.makedirs(folderSave)
  51. log('xControl: \"xControl\" folder has been created. Please, dont delete for keep configs.')
  52.  
  53. # ------------------------------------- Functions -------------------------------------
  54. # Load the GUI and data for use like default
  55. def configs_default():
  56. # Clear data needed to sync attacks
  57. global SelectedTargetID,ModeAttack,useSkills,dataSkills
  58. SelectedTargetID = None
  59. ModeAttack = False
  60. useSkills = False
  61. dataSkills = []
  62. # Checkboxs
  63. global cbxEnableAttack_checked,cbxRecSkills_checked,cbxDefensive_checked,cbxSkillsRandom_checked
  64. cbxEnableAttack_checked = False
  65. QtBind.setChecked(gui,cbxEnableAttack,False)
  66. cbxRecSkills_checked = False
  67. QtBind.setChecked(gui,cbxRecSkills,False)
  68. cbxDefensive_checked = False
  69. QtBind.setChecked(gui,cbxDefensive,False)
  70. cbxSkillsRandom_checked = False
  71. QtBind.setChecked(gui,cbxSkillsOrder,True)
  72. QtBind.setChecked(gui,cbxSkillsRandom,False)
  73. # Lists
  74. QtBind.clear(gui,lstLeaders)
  75. QtBind.clear(gui,lstSkills)
  76.  
  77. # Loads lists with the config file
  78. def configs_load():
  79. configs_default()
  80. # Load configs
  81. if os.path.exists(get_xcontrol_path()):
  82. data = {}
  83. with open(get_xcontrol_path(),"r") as f:
  84. data = json.load(f)
  85. if "Leaders" in data:
  86. for charname in data["Leaders"]:
  87. QtBind.append(gui,lstLeaders,charname)
  88. if "Skills" in data:
  89. for skillID in data["Skills"]:
  90. lstSkills_add(skillID)
  91. if "Defensive" in data:
  92. global cbxDefensive_checked
  93. cbxDefensive_checked = data["Defensive"]
  94. QtBind.setChecked(gui,cbxDefensive,data["Defensive"])
  95. if "SkillsRandom" in data:
  96. cbxSkillsRandom_checked = data["SkillsRandom"]
  97. QtBind.setChecked(gui,cbxSkillsRandom,data["SkillsRandom"])
  98. QtBind.setChecked(gui,cbxSkillsOrder,not data["SkillsRandom"])
  99.  
  100. # Return True if nickname exist in the "Leaders" list
  101. def lstLeaders_exist(nickname):
  102. players = QtBind.getItems(gui,lstLeaders)
  103. for i in range(len(players)):
  104. if players[i].lower() == nickname.lower():
  105. return True
  106. return False
  107.  
  108. # Add a new Skill into the list of skills
  109. def lstSkills_add(skillID,save=False):
  110. skill = get_skill(skillID).copy()
  111. skill['id'] = skillID
  112. skill['ready'] = True
  113. global dataSkills
  114. dataSkills.append(skill)
  115. SkillName = skill['name']+" Lv"+str(skill['level'])
  116. if save:
  117. # init dictionary
  118. data = {}
  119. # load config if exist
  120. if os.path.exists(get_xcontrol_path()):
  121. with open(get_xcontrol_path(), 'r') as f:
  122. data = json.load(f)
  123. # add new skill
  124. if not "Skills" in data:
  125. data['Skills'] = []
  126. data['Skills'].append(skillID)
  127. # replace configs
  128. with open(get_xcontrol_path(),"w") as f:
  129. f.write(json.dumps(data, indent=4, sort_keys=True))
  130. log("xControl: #Skill added ["+SkillName+"]")
  131. QtBind.append(gui,lstSkills,SkillName)
  132.  
  133.  
  134. # Return True if skill ID exist in the list of skills
  135. def lstSkills_exist(skillID):
  136. for i in range(len(dataSkills)):
  137. if dataSkills[i]['id'] == skillID:
  138. return True
  139. return False
  140.  
  141. # Return the index of Skill ID ready for use
  142. def lstSkills_useSkill():
  143. if cbxSkillsRandom_checked:
  144. if len(dataSkills) > 0:
  145. import random
  146. record = []
  147. while True:
  148. again = False
  149. pos = random.randint(0,len(dataSkills)-1)
  150. for r in range(len(record)):
  151. if record[r] == pos:
  152. again = True
  153. break
  154. if again:
  155. continue
  156. if dataSkills[pos]['ready']:
  157. return pos
  158. else:
  159. record.append(pos)
  160. else:
  161. for i in range(len(dataSkills)):
  162. if dataSkills[i]['ready']:
  163. return i
  164. return -1
  165.  
  166. # Enable a skill used previously
  167. def lstSkills_enableSkill(index):
  168. try:
  169. global dataSkills
  170. dataSkills[index]['ready'] = True
  171. except: # index not found
  172. pass
  173.  
  174. # Click on "Agregar" from leaders clicked
  175. def btnAddLeader_clicked():
  176. if playerData:
  177. player = QtBind.text(gui,tbxLeaders)
  178. if player and not lstLeaders_exist(player):
  179. # init dictionary
  180. data = {}
  181. # load config if exist
  182. if os.path.exists(get_xcontrol_path()):
  183. with open(get_xcontrol_path(), 'r') as f:
  184. data = json.load(f)
  185. # add new leader
  186. if not "Leaders" in data:
  187. data['Leaders'] = []
  188. data['Leaders'].append(player)
  189. # replace configs
  190. with open(get_xcontrol_path(),"w") as f:
  191. f.write(json.dumps(data, indent=4, sort_keys=True))
  192. QtBind.append(gui,lstLeaders,player)
  193. QtBind.setText(gui, tbxLeaders,"")
  194. log('xControl: Leader added ['+player+']')
  195.  
  196. # Button "Remover" from leaders clicked
  197. def btnRemLeader_clicked():
  198. if playerData:
  199. selectedItem = QtBind.text(gui,lstLeaders)
  200. if selectedItem:
  201. if os.path.exists(get_xcontrol_path()):
  202. data = {"Leaders":[]}
  203. with open(get_xcontrol_path(), 'r') as f:
  204. data = json.load(f)
  205. try:
  206. # remove leader nickname from file if exists
  207. data["Leaders"].remove(selectedItem)
  208. with open(get_xcontrol_path(),"w") as f:
  209. f.write(json.dumps(data, indent=4, sort_keys=True))
  210. except:
  211. pass # just ignore file if don't exist
  212. QtBind.remove(gui,lstLeaders,selectedItem)
  213. log('xControl: Leader removed ['+selectedItem+']')
  214.  
  215. # Button "Remover" from skills clicked
  216. def btnRemSkills_clicked():
  217. if playerData:
  218. selectedIndex = QtBind.currentIndex(gui,lstSkills)
  219. if selectedIndex >= 0:
  220. if os.path.exists(get_xcontrol_path()):
  221. data = {"Skills":[]}
  222. with open(get_xcontrol_path(), 'r') as f:
  223. data = json.load(f)
  224. try:
  225. # remove skill id from file if exists
  226. data["Skills"].pop(selectedIndex)
  227. with open(get_xcontrol_path(),"w") as f:
  228. f.write(json.dumps(data, indent=4, sort_keys=True))
  229. except:
  230. pass # just ignore if don't exist
  231. QtBind.removeAt(gui,lstSkills,selectedIndex)
  232. skill = dataSkills.pop(selectedIndex)
  233. log('xControl: #Skill removed ['+skill['name']+' Lv'+str(skill['level'])+']')
  234.  
  235. # Return the path of the config file
  236. def get_xcontrol_path():
  237. return folderSave+"\\"+ playerData['server'] + "_" + playerData['name'] + ".json"
  238.  
  239. # Checkbox "Habilitar Attack" clicked
  240. def cbxEnableAttack_clicked(checked):
  241. global cbxEnableAttack_checked
  242. cbxEnableAttack_checked = checked
  243.  
  244. # Checkbox "Grabar #Skill" clicked
  245. def cbxRecSkills_clicked(checked):
  246. global cbxRecSkills_checked
  247. cbxRecSkills_checked = checked
  248.  
  249. # Checkbox "Aleatoria" clicked
  250. def cbxSkillsOrder_clicked(checked):
  251. global cbxSkillsRandom_checked
  252. cbxSkillsRandom_checked = not checked
  253. configs_save_key("SkillsRandom",not checked)
  254. QtBind.setChecked(gui,cbxSkillsRandom,not checked)
  255.  
  256. # Checkbox "Random" clicked
  257. def cbxSkillsRandom_clicked(checked):
  258. global cbxSkillsRandom_checked
  259. cbxSkillsRandom_checked = checked
  260. configs_save_key("SkillsRandom",checked)
  261. QtBind.setChecked(gui,cbxSkillsOrder,not checked)
  262.  
  263. # Checkbox "AutoDefensa" clicked
  264. def cbxDefensive_clicked(checked):
  265. global cbxDefensive_checked
  266. cbxDefensive_checked = checked
  267. configs_save_key("Defensive",checked)
  268.  
  269. # Save data into key json
  270. def configs_save_key(key,info):
  271. if playerData:
  272. data = {}
  273. if os.path.exists(get_xcontrol_path()):
  274. with open(get_xcontrol_path(), 'r') as f:
  275. data = json.load(f)
  276. data[key] = info
  277. with open(get_xcontrol_path(),"w") as f:
  278. f.write(json.dumps(data, indent=4, sort_keys=True))
  279.  
  280. # Called when the bot successfully connects to the game server
  281. def connected():
  282. global playerData
  283. playerData = None
  284.  
  285. # Called when the character enters the game world
  286. def joined_game():
  287. global playerData
  288. playerData = get_character_data()
  289. configs_load()
  290.  
  291. # Called when the character teleports and right after joined_game()
  292. def teleported():
  293. global playerData
  294. playerData = get_character_data()
  295.  
  296. # All packets received from Silkroad will be passed to this function
  297. # Returning True will keep the packet and False will not forward it to the game server
  298. def handle_silkroad(opcode, data):
  299. if opcode == 0x7074 and cbxRecSkills_checked:
  300. if data[0] == 0x01: # Flag (Success)
  301. if data[1] == 0x04: # Using skill
  302. SkillID = struct.unpack_from("<i",data,2)[0]
  303. # Need to have target & is not be in the skill list
  304. if data[6] == 0x01 and not lstSkills_exist(SkillID):
  305. lstSkills_add(SkillID,True)
  306. return True
  307.  
  308. # All packets received from Joymax will be passed to this function
  309. # Returning True will keep the packet and False will not forward it to the client
  310. def handle_joymax(opcode, data):
  311. if opcode == 0x3026: # Chat Message
  312. # Packet index
  313. index = 0
  314. # Message type: All or Party or Private
  315. if data[index] == 0x01 or data[index] == 0x02 or data[index] == 0x04:
  316. # Parse nick of character
  317. Character = ""
  318. if data[index] == 0x01:
  319. index += 1
  320. Character = getNickname(struct.unpack_from("<i",data,index)[0])
  321. index += 4
  322. else:
  323. index += 1
  324. CharacterLength = struct.unpack_from('H', data, index)[0]
  325. index += 2
  326. Character = struct.unpack_from(str(CharacterLength) + 's', data, index)[0].decode('ascii')
  327. index += CharacterLength
  328. # Checking nick into the list of leaders
  329. if lstLeaders_exist(Character):
  330. # Load and search command message
  331. MessageLength = struct.unpack_from('H', data, index)[0]
  332. index += 2
  333. Message = struct.unpack_from(str(MessageLength * 2) + 's', data, index)[0].decode('utf-16').strip()
  334. if Message == "ENABLE" and not cbxEnableAttack_checked:
  335. global cbxEnableAttack_checked
  336. cbxEnableAttack_checked = True
  337. QtBind.setChecked(gui,cbxEnableAttack,True)
  338. log('xControl: Enabled #ATTACKs mode')
  339. elif Message == "DISABLE" and cbxEnableAttack_checked:
  340. global cbxEnableAttack_checked
  341. cbxEnableAttack_checked = False
  342. QtBind.setChecked(gui,cbxEnableAttack,False)
  343. log('xControl: Disabled #ATTACKs mode')
  344. elif Message == "ATTACK" or Message == "ATTACKS":
  345. global useSkills
  346. useSkills = False if Message == "ATTACK" else True
  347. if not ModeAttack:
  348. global ModeAttack
  349. ModeAttack = True
  350. AutoAttack()
  351. elif Message == "STOP":
  352. if ModeAttack:
  353. global ModeAttack
  354. ModeAttack = False
  355. Inject_StopAttack()
  356. elif Message == "STARTB":
  357. start_bot()
  358. elif Message == "STOPB":
  359. stop_bot()
  360. elif Message.startswith("TRACE"):
  361. if Message == "TRACE":
  362. if start_trace(Character):
  363. log("xControl: Starting #Trace to ["+Character+"]")
  364. else:
  365. Character = Message[5:].split()
  366. if Character:
  367. if start_trace(Character[0]):
  368. log("xControl: Starting #Trace to ["+Character[0]+"]")
  369. elif Message == "STOPT":
  370. if stop_trace():
  371. log("xControl: Stopping #Trace")
  372. elif Message == "SIT":
  373. Inject_SitDown()
  374. elif Message.startswith("CAPE"):
  375. if Message == "CAPE":
  376. Inject_UseCape(5)
  377. log("xControl: Using PVP Cape (Yellow)")
  378. else:
  379. type = Message[4:].split()
  380. if type:
  381. type = type[0].upper()
  382. if type == "OFF":
  383. Inject_UseCape(0)
  384. log("xControl: Removing PVP Cape")
  385. elif type == "RED":
  386. Inject_UseCape(1)
  387. log("xControl: Using PVP Cape (Red)")
  388. elif type == "GRAY":
  389. Inject_UseCape(2)
  390. log("xControl: Using PVP Cape (Gray)")
  391. elif type == "BLUE":
  392. Inject_UseCape(3)
  393. log("xControl: Using PVP Cape (Blue)")
  394. elif type == "WHITE":
  395. Inject_UseCape(4)
  396. log("xControl: Using PVP Cape (White)")
  397. elif type == "YELLOW":
  398. Inject_UseCape(5)
  399. log("xControl: Using PVP Cape (Yellow)")
  400. elif Message == "USEZERK":
  401. Inject_UseZerk()
  402. elif Message == "USERETURN":
  403. import random # Try avoid High CPU usage with many chars on same time
  404. Timer(random.random(), Inject_UseReturnScroll).start()
  405. elif Message.startswith('INJECT'):
  406. Inject_Packet(Message.split())
  407. elif opcode == 0xB070 and cbxEnableAttack_checked: # Object Action & Enable Attack
  408. if data[0] == 0x01: # Flag (Success)
  409. if data[1] == 0x02: # Type. 0x00: Buff - 0x02: Attack
  410. AttackerID = struct.unpack_from("<i",data,7)[0]
  411. TargetID = struct.unpack_from("<i",data,15)[0]
  412. if AttackerID != TargetID: # Ensure is not a Buff
  413. ScannTarget(AttackerID,TargetID)
  414. elif opcode == 0xB045 and cbxEnableAttack_checked: # Selecting Target & Enable Attack
  415. if data[0] == 0x01: # Flag (Success)
  416. TargetID = struct.unpack_from("<i",data,1)[0]
  417. if TargetID != SelectedTargetID: # Faster
  418. global SelectedTargetID
  419. SelectedTargetID = TargetID
  420. extraInfo = ""
  421. if len(data) > 5: # Not Pet
  422. if data[5] == 0x01: # Not NPC
  423. if data[6] == 0x05:
  424. extraInfo = " - Nickname:"+getNickname(SelectedTargetID)
  425. else:
  426. extraInfo = " - HP:"+str(struct.unpack_from("<i",data,6)[0])
  427. log('xControl: Target selected [ TargetID:'+str(TargetID)+''+extraInfo+' ]')
  428. QtBind.setText(gui,lblTarget,"TargetID : "+str(SelectedTargetID))
  429. return True
  430.  
  431. # Return Nick of player from ID only if is near
  432. def getNickname(PlayerID):
  433. # Load all near players
  434. players = get_players()
  435. # Checking if ID is mine
  436. if PlayerID == playerData['player_id']:
  437. return playerData['name']
  438. # Check the IDs with all players
  439. for key, player in players.items():
  440. if key == PlayerID:
  441. return player['name']
  442. return ""
  443.  
  444. # Select target if some leader is found
  445. def ScannTarget(AttackerID,TargetID):
  446. players = get_players()
  447. if TargetID == playerData['player_id']:
  448. if cbxDefensive_checked:
  449. if SelectedTargetID != AttackerID and lstLeaders_exist(playerData['name']):
  450. Inject_SelectTarget(AttackerID)
  451. return
  452. for key, player in players.items():
  453. if AttackerID == key:
  454. if SelectedTargetID != TargetID and lstLeaders_exist(player['name']):
  455. Inject_SelectTarget(TargetID)
  456. return
  457. elif TargetID == key:
  458. if cbxDefensive_checked:
  459. if SelectedTargetID != AttackerID and lstLeaders_exist(player['name']):
  460. Inject_SelectTarget(AttackerID)
  461. return
  462.  
  463. # Inject Attacks without stop
  464. def AutoAttack():
  465. if ModeAttack:
  466. # Minim delay to check again
  467. delayAttack = 0.5
  468. if SelectedTargetID:
  469. if useSkills:
  470. index = lstSkills_useSkill()
  471. if index >= 0:
  472. delayAttack = (dataSkills[index]['cast_time']/1000)+0.01
  473. delaySkill = (dataSkills[index]['cool_down']/1000)
  474. global dataSkills
  475. dataSkills[index]['ready'] = False
  476. Inject_AttackTarget(SelectedTargetID,dataSkills[index]['id'])
  477. Timer(delaySkill,lstSkills_enableSkill,(index,)).start()
  478. log('xControl: Attacking target with ['+dataSkills[index]['name']+" Lv"+str(dataSkills[index]['level'])+']')
  479. else:
  480. Inject_AttackTarget(SelectedTargetID)
  481. log('xControl: Attacking target with [Normal Attack]')
  482. delayAttack = 1.5
  483. Timer(delayAttack,AutoAttack).start()
  484.  
  485. # Inject Packet (Select Target)
  486. def Inject_SelectTarget(TargetID):
  487. Packet = bytearray()
  488. Packet = Packet + struct.pack('<i',TargetID)
  489. inject_joymax(0x7045,Packet, False)
  490.  
  491. # Inject Packet Attack (Skill Attack)
  492. def Inject_AttackTarget(TargetID,SkillID=None):
  493. Packet = bytearray()
  494. Packet.append(0x01) # Flag (Attack)
  495. if SkillID:
  496. Packet.append(0x04) # Use Skill
  497. Packet = Packet + struct.pack('<i',SkillID)
  498. else:
  499. Packet.append(0x01) # Use Normal Attack
  500. Packet.append(0x01) # Flag (Target)
  501. Packet = Packet + struct.pack('<i',TargetID)
  502. inject_joymax(0x7074,Packet, False)
  503.  
  504. # Inject Packet (Stop Attack)
  505. def Inject_StopAttack():
  506. Packet = bytearray()
  507. Packet.append(0x02) # Flag (Stop)
  508. inject_joymax(0x7074,Packet, False)
  509. log("xControl: Stopping attack")
  510.  
  511. # Inject Packet (Sit down / Stand up)
  512. def Inject_SitDown():
  513. Packet = bytearray()
  514. Packet.append(0x04) # Flag (Stop)
  515. inject_joymax(0x704F,Packet, False)
  516. log("xControl: Sit / Stand")
  517.  
  518. # Inject Packet (Cape)
  519. def Inject_UseCape(option):
  520. if option >= 0 and option <= 5:
  521. Packet = bytearray()
  522. Packet.append(option)
  523. inject_joymax(0x7516, Packet, False)
  524.  
  525. # Inject Packet (Use Zerk)
  526. def Inject_UseZerk():
  527. Packet = bytearray()
  528. Packet.append(0x01)
  529. inject_joymax(0x70A7, Packet, False)
  530. log("xControl: Using Berserker mode")
  531.  
  532. # Inject Packet (Use Return Scroll)
  533. def Inject_UseReturnScroll():
  534. nSlot = 0
  535. items = get_inventory()['items']
  536. for item in items:
  537. if item != None:
  538. if item['name'] == 'Return Scroll' or item['name'] == 'Special Return Scroll' or item['name'] == 'Token Return Scroll' or item['name'] == 'Beginner instant recall scroll' or item['name'] == 'Instant Return Scroll':
  539. Packet = bytearray()
  540. Packet.append(nSlot)
  541. Packet.append(0x30)
  542. Packet.append(0x0C)
  543. Packet.append(0x03)
  544. Packet.append(0x01)
  545. inject_joymax(0x704C, Packet, True)
  546. log('xControl: Using "'+item['name']+'" ')
  547. return
  548. nSlot += 1
  549. log('xControl: Has not been found "Return Scroll" from your inventory.')
  550.  
  551. # Inject Packet parsing from Command
  552. def Inject_Packet(arguments):
  553. if len(arguments) >= 3:
  554. opcode = int(arguments[1],16)
  555. encrypted = False
  556. iniPos = 2
  557. if arguments[2].lower() == "true" or arguments[2].lower() == "false":
  558. encrypted = True if arguments[2].lower() == "true" else False
  559. iniPos += 1
  560. Packet = bytearray()
  561. for i in range(iniPos, len(arguments) ):
  562. Packet.append(int(arguments[i],16))
  563. inject_joymax(opcode,Packet,encrypted)
  564. log("xControl: Injecting #Packet")
  565. log("[Opcode:"+arguments[1]+"][Data:"+' '.join('{:02X}'.format(int(arguments[x],16)) for x in range(iniPos, len(arguments)))+"][Encrypted:"+("Yes" if encrypted else "No")+"]")
  566. else:
  567. log("xControl: Incorrect structure for inject the #Packet")
  568. return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement