GsL Posted September 2, 2012 Posted September 2, 2012 this code is a little diffrent can be adapt? ( http://maxcheaters.com/forum/index.php?topic=176139.0 ) To * I want if enemy wear S grade armor and u kill he drop with chance or not S Grade PvP reward if wear A grade drop A Grade PvP reward B Grade B Grade Reward C grade C grade PvP reward * If this request isnt allowed lock it :/ Adapt to L2jfrozen Interlude*
0 Fanky Posted September 2, 2012 Posted September 2, 2012 Ιt would be nice if you share the code with us instead of giving us a link to download it. are we supposed to download it in order to help you?:P post it here,please.
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 Adapt this code to **** chronicle? **** pack?
0 GsL Posted September 2, 2012 Author Posted September 2, 2012 Adapt this code to **** chronicle? **** pack? L2jfrozen Interlude* for i forget that*
0 GsL Posted September 2, 2012 Author Posted September 2, 2012 Ιt would be nice if you share the code with us instead of giving us a link to download it. are we supposed to download it in order to help you?:P post it here,please. Sory here is the code * /* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ package com.l2jserver.gameserver.datatables; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; import javolution.util.FastMap; import com.l2jserver.L2DatabaseFactory; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.util.Rnd; /** * @author hNoke * */ public class PvPRewardsTable { private Map<Integer, PvPRewardItem> _rewards; public static PvPRewardsTable getInstance() { return SingletonHolder._instance; } public PvPRewardsTable() { load(); } public void rewardLastHit(L2PcInstance winner, L2PcInstance target) { int random = Rnd.get(100000); int ammount; for(Map.Entry<Integer, PvPRewardItem> item : _rewards.entrySet()) { if(random < item.getKey() && item.getValue().checkConsecutiveShits(winner)) { ammount = item.getValue().getAmmount(winner); if(ammount > 0) winner.addItem("PvPReward", item.getValue().id, ammount, null, true); } } } public class PvPRewardItem { public int id; public int minAmmount; public int maxAmmount; public int chance; public int pvpRequired; public int levelRequired; public int rewardAfter; public PvPRewardItem(int id, int minAmmount, int maxAmmount, int chance, int pvpRequired, int levelRequired, int rewardAfter) { this.id = id; this.minAmmount = minAmmount; this.maxAmmount = maxAmmount; this.chance = chance; this.pvpRequired = pvpRequired; this.levelRequired = levelRequired; this.rewardAfter = rewardAfter; } public boolean checkConsecutiveShits(L2PcInstance player) { if(rewardAfter == 0) return true; if(player.getPvpKills() != 0 && player.getPvpKills() % rewardAfter == 0) return true; return false; } public int getAmmount(L2PcInstance player) { if(player.getLevel() >= levelRequired && player.getPvpKills() >= pvpRequired) return Rnd.get(minAmmount, maxAmmount); else return 0; } } private void load() { _rewards = new FastMap<Integer, PvPRewardItem>(); Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM pvp_rewards"); ResultSet rset = statement.executeQuery(); while (rset.next()) { _rewards.put(rset.getInt("chance"), new PvPRewardItem(rset.getInt("id"), rset.getInt("minAmmount"), rset.getInt("maxAmmount"), rset.getInt("chance"), rset.getInt("pvpsRequired"), rset.getInt("levelRequired"), rset.getInt("rewardAfter"))); } rset.close(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { con.close(); } catch (Exception e) { } } } @SuppressWarnings("synthetic-access") private static class SingletonHolder { protected static final PvPRewardsTable _instance = new PvPRewardsTable(); } }
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 /* /* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ package com.l2jfrozen.gameserver.datatables; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Map; import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; import com.l2jfrozen.util.CloseUtil; import com.l2jfrozen.util.database.L2DatabaseFactory; import com.l2jfrozen.util.random.Rnd; import javolution.util.FastMap; /** * @author hNoke * @adapted Wyatt */ public class PvPRewardsTable { private Map<Integer, PvPRewardItem> _rewards; public static PvPRewardsTable getInstance() { return SingletonHolder._instance; } public PvPRewardsTable() { load(); } public void rewardLastHit(L2PcInstance winner, L2PcInstance target) { int random = Rnd.get(100000); int amount; for(Map.Entry<Integer, PvPRewardItem> item : _rewards.entrySet()) { if(random < item.getKey() && item.getValue().checkConsecutiveShits(winner)) { amount = item.getValue().getamount(winner); if(amount > 0) winner.addItem("PvPReward", item.getValue().id, amount, null, true); } } } public class PvPRewardItem { public int id; public int minamount; public int maxamount; public int chance; public int pvpRequired; public int levelRequired; public int rewardAfter; public PvPRewardItem(int id, int minamount, int maxamount, int chance, int pvpRequired, int levelRequired, int rewardAfter) { this.id = id; this.minamount = minamount; this.maxamount = maxamount; this.chance = chance; this.pvpRequired = pvpRequired; this.levelRequired = levelRequired; this.rewardAfter = rewardAfter; } public boolean checkConsecutiveShits(L2PcInstance player) { if(rewardAfter == 0) return true; if(player.getPvpKills() != 0 && player.getPvpKills() % rewardAfter == 0) return true; return false; } public int getamount(L2PcInstance player) { if(player.getLevel() >= levelRequired && player.getPvpKills() >= pvpRequired) return Rnd.get(minamount, maxamount); return 0; } } private void load() { _rewards = new FastMap<Integer, PvPRewardItem>(); Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM pvp_rewards"); ResultSet rset = statement.executeQuery(); while (rset.next()) { _rewards.put(rset.getInt("chance"), new PvPRewardItem(rset.getInt("id"), rset.getInt("minamount"), rset.getInt("maxamount"), rset.getInt("chance"), rset.getInt("pvpsRequired"), rset.getInt("levelRequired"), rset.getInt("rewardAfter"))); } rset.close(); statement.close(); } catch (Exception e) { e.printStackTrace(); } finally { CloseUtil.close(con); } } private static class SingletonHolder { protected static final PvPRewardsTable _instance = new PvPRewardsTable(); } }
0 GsL Posted September 2, 2012 Author Posted September 2, 2012 /* /* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ package com.l2jfrozen.gameserver.datatables; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Map; import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; import com.l2jfrozen.util.CloseUtil; import com.l2jfrozen.util.database.L2DatabaseFactory; import com.l2jfrozen.util.random.Rnd; import javolution.util.FastMap; /** * @author hNoke * @adapted Wyatt */ public class PvPRewardsTable { private Map<Integer, PvPRewardItem> _rewards; public static PvPRewardsTable getInstance() { return SingletonHolder._instance; } public PvPRewardsTable() { load(); } public void rewardLastHit(L2PcInstance winner, L2PcInstance target) { int random = Rnd.get(100000); int a-beep-t; for(Map.Entry<Integer, PvPRewardItem> item : _rewards.entrySet()) { if(random < item.getKey() && item.getValue().checkConsecutiveShits(winner)) { a-beep-t = item.getValue().geta-beep-t(winner); if(a-beep-t > 0) winner.addItem("PvPReward", item.getValue().id, a-beep-t, null, true); } } } public class PvPRewardItem { public int id; public int mina-beep-t; public int maxa-beep-t; public int chance; public int pvpRequired; public int levelRequired; public int rewardAfter; public PvPRewardItem(int id, int mina-beep-t, int maxa-beep-t, int chance, int pvpRequired, int levelRequired, int rewardAfter) { this.id = id; this.mina-beep-t = mina-beep-t; this.maxa-beep-t = maxa-beep-t; this.chance = chance; this.pvpRequired = pvpRequired; this.levelRequired = levelRequired; this.rewardAfter = rewardAfter; } public boolean checkConsecutiveShits(L2PcInstance player) { if(rewardAfter == 0) return true; if(player.getPvpKills() != 0 && player.getPvpKills() % rewardAfter == 0) return true; return false; } public int geta-beep-t(L2PcInstance player) { if(player.getLevel() >= levelRequired && player.getPvpKills() >= pvpRequired) return Rnd.get(mina-beep-t, maxa-beep-t); return 0; } } private void load() { _rewards = new FastMap<Integer, PvPRewardItem>(); Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM pvp_rewards"); ResultSet rset = statement.executeQuery(); while (rset.next()) { _rewards.put(rset.getInt("chance"), new PvPRewardItem(rset.getInt("id"), rset.getInt("mina-beep-t"), rset.getInt("maxa-beep-t"), rset.getInt("chance"), rset.getInt("pvpsRequired"), rset.getInt("levelRequired"), rset.getInt("rewardAfter"))); } rset.close(); statement.close(); } catch (Exception e) { e.printStackTrace(); } finally { CloseUtil.close(con); } } private static class SingletonHolder { protected static final PvPRewardsTable _instance = new PvPRewardsTable(); } } I need to change that to check armorset* if enemy wear S Grade armorset (Draconic Major Arcana ImpC) Drop S PvP Reward with some chance If Enemy wear A Grade armor set Drop A Grade reward same for B grade And C Grade if this one is hard ingore it .
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 I need to change that to check armorset* if enemy wear S Grade armorset (Draconic Major Arcana ImpC) Drop S PvP Reward with some chance If Enemy wear A Grade armor set Drop A Grade reward same for B grade And C Grade if this one is hard ingore it . Ah lol, I supposed that the code was already doing it and you only wanted to adapt it, w8 I'm checking.
0 GsL Posted September 2, 2012 Author Posted September 2, 2012 Ah lol, I supposed that the code was already doing it and you only wanted to adapt it, w8 I'm checking. something that forget can be done with only armorsets not example A weapon or A Tatoo or jewels? is that easy? and if some1 wear that armor sets drop that reward*
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 Try something like that... ### Eclipse Workspace Patch 1.0 #P L2jFrozen_GameServer Index: head-src/com/l2jfrozen/gameserver/datatables/PvPReward.java =================================================================== --- head-src/com/l2jfrozen/gameserver/datatables/PvPReward.java (revision 0) +++ head-src/com/l2jfrozen/gameserver/datatables/PvPReward.java (revision 0) @@ -0,0 +1,95 @@ +/* + /* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.l2jfrozen.gameserver.datatables; + +import com.l2jfrozen.gameserver.model.Inventory; +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; +import com.l2jfrozen.util.random.Rnd; + + +/** + * + * @author Wyatt + * + */ + +public class PvPReward +{ + private static int [] Sgrade = {};//Add here + private static int [] Agrade = {};//the items + private static int [] Bgrade = {};//that will be + private static int [] Cgrade = {};//checked to know + private static int [] Dgrade = {};//the grade (chests) + + private static int [] Srew = {};//Add here + private static int [] Arew = {};//the items + private static int [] Brew = {};//that you want + private static int [] Crew = {};//specify as possible + private static int [] Drew = {};//rewards, by grade + private static String grade = ""; + + public static void checkReward(L2PcInstance killer, L2PcInstance killed) + { + int id = 0; + L2ItemInstance armor = killed.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (armor != null) + { + id = armor.getItemId(); + } + + for(int i : Sgrade) + { + if(i == id) + grade = "S"; + } + + for(int i : Agrade) + { + if(i == id) + grade = "A"; + } + + for(int i : Bgrade) + { + if(i == id) + grade = "B"; + } + + for(int i : Cgrade) + { + if(i == id) + grade = "C"; + } + + for(int i : Dgrade) + { + if(i == id) + grade = "D"; + } + + if(grade.equals("S")) + killer.addItem("PvP Reward", Srew[Rnd.get(Srew.length)], 1, killer, true); + if(grade.equals("A")) + killer.addItem("PvP Reward", Arew[Rnd.get(Arew.length)], 1, killer, true); + if(grade.equals("B")) + killer.addItem("PvP Reward", Brew[Rnd.get(Brew.length)], 1, killer, true); + if(grade.equals("C")) + killer.addItem("PvP Reward", Crew[Rnd.get(Crew.length)], 1, killer, true); + if(grade.equals("D")) + killer.addItem("PvP Reward", Drew[Rnd.get(Drew.length)], 1, killer, true); + } +} \ No newline at end of file Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 948) +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -59,6 +59,7 @@ import com.l2jfrozen.gameserver.datatables.GmListTable; import com.l2jfrozen.gameserver.datatables.HeroSkillTable; import com.l2jfrozen.gameserver.datatables.NobleSkillTable; +import com.l2jfrozen.gameserver.datatables.PvPReward; import com.l2jfrozen.gameserver.datatables.SkillTable; import com.l2jfrozen.gameserver.datatables.csv.FishTable; import com.l2jfrozen.gameserver.datatables.csv.HennaTable; @@ -7291,6 +7292,8 @@ pk.kills.add(getName()); } + PvPReward.checkReward(pk, this); + if(_inEventTvT && pk._inEventTvT) { if(TvT.is_teleport() || TvT.is_started())
0 GsL Posted September 2, 2012 Author Posted September 2, 2012 can u give an example with random id?? in this lines ? private static int [] Sgrade = {};//Add here + private static int [] Agrade = {};//the items + private static int [] Bgrade = {};//that will be + private static int [] Cgrade = {};//checked to know + private static int [] Dgrade = {};//the grade (chests) + + private static int [] Srew = {};//Add here + private static int [] Arew = {};//the items + private static int [] Brew = {};//that you want + private static int [] Crew = {};//specify as possible + private static int [] Drew = {};//rewards, by grade + private static String grade = ""; I add in this line this id* private static int [] Sgrade = {6379};//Add here [/code] dragonic main(6379 private static int [] Srew = {7569};//Add here coin (7569) If i kill i get reward but always if he wear armor or not i want only if he wear not if armor exist in invetory and if i pk i get reward i dont want that because i hate pk. this can be fixed?
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 ### Eclipse Workspace Patch 1.0 #P L2jFrozen_GameServer Index: head-src/com/l2jfrozen/gameserver/datatables/PvPReward.java =================================================================== --- head-src/com/l2jfrozen/gameserver/datatables/PvPReward.java (revision 0) +++ head-src/com/l2jfrozen/gameserver/datatables/PvPReward.java (revision 0) @@ -0,0 +1,67 @@ +/* + /* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.l2jfrozen.gameserver.datatables; + +import com.l2jfrozen.gameserver.model.Inventory; +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; +import com.l2jfrozen.util.random.Rnd; + + +/** + * + * @author Wyatt + * + */ + +public class PvPReward +{ + private static int [] Srew = {};//Add here + private static int [] Arew = {};//the items + private static int [] Brew = {};//that you want + private static int [] Crew = {};//specify as possible + private static int [] Drew = {};//rewards, by grade + private static int chance = 30; //set chance to get item reward + + public static void checkReward(L2PcInstance killer, L2PcInstance killed) + { + int c = Rnd.get(100); + if(c > chance) + return; + + int id = 0; + L2ItemInstance armor = killed.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (armor != null) + { + id = armor.getItem().getCrystalType(); + } + else + { + return; + } + + if(id == 0x01) + killer.addItem("PvP Reward", Drew[Rnd.get(Drew.length)], 1, killer, true); + else if(id == 0x02) + killer.addItem("PvP Reward", Crew[Rnd.get(Crew.length)], 1, killer, true); + else if(id == 0x03) + killer.addItem("PvP Reward", Brew[Rnd.get(Brew.length)], 1, killer, true); + else if(id == 0x04) + killer.addItem("PvP Reward", Arew[Rnd.get(Arew.length)], 1, killer, true); + else if(id == 0x05) + killer.addItem("PvP Reward", Srew[Rnd.get(Srew.length)], 1, killer, true); + } +} \ No newline at end of file Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 948) +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -59,6 +59,7 @@ import com.l2jfrozen.gameserver.datatables.GmListTable; import com.l2jfrozen.gameserver.datatables.HeroSkillTable; import com.l2jfrozen.gameserver.datatables.NobleSkillTable; +import com.l2jfrozen.gameserver.datatables.PvPReward; import com.l2jfrozen.gameserver.datatables.SkillTable; import com.l2jfrozen.gameserver.datatables.csv.FishTable; import com.l2jfrozen.gameserver.datatables.csv.HennaTable; @@ -7744,6 +7745,7 @@ // Check if it's pvp if(checkIfPvP(target) && targetPlayer.getPvpFlag() != 0 || isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)) { + PvPReward.checkReward(this, targetPlayer); increasePvpKills(); } else @@ -7756,6 +7758,7 @@ if(targetPlayer.getClan().isAtWarWith(getClanId())) { // 'Both way war' -> 'PvP Kill' + PvPReward.checkReward(this, targetPlayer); increasePvpKills(); if(target instanceof L2PcInstance && Config.ANNOUNCE_PVP_KILL) {
0 Tryskell Posted September 2, 2012 Posted September 2, 2012 ^Wyatt, that's not helping him than giving source code without explanation. He learnt nothing from it, and as you can see he doesn't even know how to feed an array. And the grade should be seen way before "for" loops, you're making 5 "for" loops no matter the grade is. To see the grade, take the crystal type.
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 I thought that he only wanted to adapt the code... and I did wrong... so then my feeling was to create this (1minute code and bb topic xD) I know what you mean but... and ye the loops... it was fast coded so I didn't pay much attention on what I was doing...
0 GsL Posted September 2, 2012 Author Posted September 2, 2012 i m not here to learn build codes i m here to learn to build my server i spend many hours of day to build my server i havent time to learn create codes this code i believe that code wht was easy to fixed Anyway this code can fixed?? to work? if you cant ^Wyatt np thanks for your time *
0 ^Wyatt Posted September 2, 2012 Posted September 2, 2012 Should be working, check the last one that I posted...
Question
GsL
this code is a little diffrent can be adapt? ( http://maxcheaters.com/forum/index.php?topic=176139.0 )
To * I want if enemy wear S grade armor and u kill he drop with chance or not S Grade PvP reward
if wear A grade drop A Grade PvP reward B Grade B Grade Reward C grade C grade PvP reward *
If this request isnt allowed lock it :/
Adapt to L2jfrozen Interlude*
19 answers to this question
Recommended Posts