GameBlonD Posted August 15, 2016 Posted August 15, 2016 Hello , i am trying to make a code in order if a player has one Item in inventory to get one active/passive skill without equip the item.What i should put in enterworld?if (activeChar.getInventory().getItemByItemId(example) ??????
0 GameBlonD Posted August 15, 2016 Author Posted August 15, 2016 Kanw mia dokimh me ayto ala den kserw pos na to kano to !=null na diabazei oti ean uparxei 1 tetio item sto inventory if (activeChar.getInventory().getItemByItemId(9819) != null) { L2Skill skill = SkillTable.getInstance().getInfo(294, 1); if (skill != null && activeChar.getSkillLevel(294) == 1) { if (GameTimeController.getInstance().isNowNight()) { SystemMessage sm = new SystemMessage(SystemMessageId.NIGHT_EFFECT_S1_APPLIES); sm.addSkillName(294); sendPacket(sm); } else { SystemMessage sm = new SystemMessage(SystemMessageId.DAY_EFFECT_S1_DISAPPEARS); sm.addSkillName(294); sendPacket(sm); } } }
0 melron Posted August 15, 2016 Posted August 15, 2016 (edited) if (activeChar.getInventory().getItemByItemId(9819) != null) { final L2Skill skill = SkillTable.getInstance().getInfo(294, 1); if (skill != null && activeChar.getSkillLevel(294) == 1) { if (GameTimeController.getInstance().isNowNight()) { final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.NIGHT_EFFECT_APPLIES); sm.addSkillName(294); sendPacket(sm); } else { final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.DAY_EFFECT_DISAPPEARS); sm.addSkillName(294); sendPacket(sm); } } Edited August 16, 2016 by ⏇Melron⏇℠Abs
0 SweeTs Posted August 16, 2016 Posted August 16, 2016 And where is the add skill logic? You only check of you have item and skill atm, if item and skill found, send msg.
0 melron Posted August 16, 2016 Posted August 16, 2016 And where is the add skill logic? You only check of you have item and skill atm, if item and skill found, send msg. he just want to take buff in enter not add skill :happyforever:
0 SweeTs Posted August 16, 2016 Posted August 16, 2016 (edited) he just want to take buff in enter not add skill :happyforever: if a player has one Item in inventory to get one active/passive skill And topic title "add skill", so he should make up him minds. The code above first check for item, then check for skill level (why the heck check for level..). If skill found -> send msg as I said before. There is nothing about add/give/take skill/buff. That's my point. Edited August 16, 2016 by SweeTs
0 melron Posted August 16, 2016 Posted August 16, 2016 (edited) And topic title "add skill", so he should make up him minds. The code above first check for item, then check for skill level (why the heck check for level..). If skill found -> send msg as I said before. There is nothing about add/give/take skill/buff. That's my point. Yeah u right. i think he just wanna find how to do the check for the item ... cause he saw a few lines before : if (activeChar.getRace().ordinal() == 2) { final L2Skill skill = SkillTable.getInstance().getInfo(294, 1); if (skill != null && activeChar.getSkillLevel(294) == 1) { if (GameTimeController.getInstance().isNowNight()) { final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.NIGHT_EFFECT_APPLIES); sm.addSkillName(294); sendPacket(sm); } else { final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.DAY_EFFECT_DISAPPEARS); sm.addSkillName(294); sendPacket(sm); } } Edited August 16, 2016 by ⏇Melron⏇℠Abs
0 SweeTs Posted August 16, 2016 Posted August 16, 2016 Yup, the item check is fine, now he have to code the add buff part.
0 'Baggos' Posted August 16, 2016 Posted August 16, 2016 This better than above shit. http://pastebin.com/RT2bJr58 Add your night/day check. This for EnterWorld.java CustomItemSkill Item = new CustomItemSkill(); Item.CustomItem(activeChar); If you need Buff and not a skill L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
0 SweeTs Posted August 16, 2016 Posted August 16, 2016 (edited) This better than above shit.. Sorry, but nop. Also the logic/code is bad :dat: Edited August 16, 2016 by SweeTs
0 'Baggos' Posted August 16, 2016 Posted August 16, 2016 (edited) Sorry, but nop. :dat: Why not? because I have new file? it is not 2 lines code. He need race check as I see. Like: if (activeChar.getRace().ordinal() == 2) and Night/Day check. or this is better? sm.addSkillName(294); :dat: The code will be more than "2 lines" like you said. Edited August 16, 2016 by 'Baggos'
0 SweeTs Posted August 16, 2016 Posted August 16, 2016 (edited) - It's not the code he want to add, it's just an code example he found inside EnterWorld, which could be reduced to 2 lines, btw. - Yeah, there is no point for new file, since it's like 5 lines code, with brackets. If you want 'external' method, simply create new method inside the class, but not new file, lol. if (activeChar.getInventory().getItemByItemId(57) != null) { activeChar.addSkill(SkillTable.getInstance().getInfo(1323, 1), false); activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(1323)); } Edited August 16, 2016 by SweeTs
0 GameBlonD Posted August 16, 2016 Author Posted August 16, 2016 (edited) - It's not the code he want to add, it's just an code example he found inside EnterWorld, which could be reduced to 2 lines, btw. - Yeah, there is no point for new file, since it's like 5 lines code, with brackets. If you want 'external' method, simply create new method inside the class, but not new file, lol. if (activeChar.getInventory().getItemByItemId(57) != null) { activeChar.addSkill(SkillTable.getInstance().getInfo(1323, 1), false); activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(1323)); } Thanks dude that was excactly what i wanted! One Question in add skill ,false=? what false does? Edited August 16, 2016 by GameBlonD
0 GameBlonD Posted August 16, 2016 Author Posted August 16, 2016 (edited) in add skill ,false=? what false does? Also I want to add some additionsI tried to send the message in party chat but with this code the message goes String name = activeChar.getName(); activeChar.sendPacket(new CreatureSay(0, Say2.PARTY, name, "Skill Enabled"));Player name: Skill EnabledHow it can be like this:System: Skill Enabled Edited August 16, 2016 by GameBlonD
0 SweeTs Posted August 16, 2016 Posted August 16, 2016 false means the skill is NOT gonna be saved to the database. Skill is gone when you restart. Add activeChar.sendMessage("System: Skill enabled."); else you can use CreatureSay as in your example.
Question
GameBlonD
Hello , i am trying to make a code in order if a player has one Item in inventory to get one active/passive skill without equip the item.
What i should put in enterworld?
if (activeChar.getInventory().getItemByItemId(example) ??????
18 answers to this question
Recommended Posts