Jump to content
  • 0

Hero Custom Day L2Jfrozen For L2Jacis


Question

Posted

I took this code in another forum, however added is of the same error that the low image

5PLx7qm.jpg

 

Code:

 

 

# -----------------------------------------------------

# Hero Custom Item Configuration -
# -----------------------------------------------------
# When ActiveChar will use this item will gain Hero Status.
EnableHeroCustomItem = False
# Id Itemn Need's 
HeroCustomItemId = 3481
# Hero for X days, 0 forever.
HeroCustomDay = 0
 
 
 
config.java
 
+public static boolean HERO_CUSTOM_ITEMS;
+public static int HERO_CUSTOM_ITEM_ID;
+public static int HERO_CUSTOM_DAY;
 
+HERO_CUSTOM_ITEMS = Boolean.parseBoolean(L2JFrozenSettings.getProperty("EnableHeroCustomItem", "true"));
+HERO_CUSTOM_ITEM_ID = Integer.parseInt(L2JFrozenSettings.getProperty("HeroCustomItemId", "3481"));
+HERO_CUSTOM_DAY = Integer.parseInt(L2JFrozenSettings.getProperty("HeroCustomDay", "0"));
 
 
 
 
 
 
gameserver.handler.ItemHandler.java
 
 
+import com.l2jfrozen.gameserver.handler.itemhandlers.HeroCustomItem;
 
 
 
 
registerItemHandler(new JackpotSeed());
  +registerItemHandler(new HeroCustomItem());
registerItemHandler(new MOSKey());
registerItemHandler(new BreakingArrow());
 
 
 
 
L2DatabaseFactory.java
 
public static void close(final Connection con)
{
if (con == null)
return;
 
try
{
con.close();
}
catch (final SQLException e)
{
_log.warning("Failed to close database connection!");
}
}
 
+/**
+ * @param b
+ * @return
+ * @throws SQLException 
+ */
+public Connection getConnection(boolean B) throws SQLException
+{
+ return getConnection(true);
+}
}
 
 
 
instance.L2PcInstance.java
 
// "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point,banchat_time,name_color,title_color,first_log,aio,aio_end FROM characters WHERE obj_id=?";
private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon,punish_level,punish_timer," + /*
+
+/** The Constant STATUS_DATA_GET. */
+private static final String STATUS_DATA_GET = "SELECT hero, hero_end_date FROM characters_custom_data WHERE obj_Id = ?";
+
/** The Constant RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS. */
private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
 
// ---------------------- L2JFrozen Addons ---------------------------------- //
/** The Constant RESTORE_CHAR_SUBCLASSES. */
private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
 
 
public void reduceDeathPenaltyBuffLevel()
{
if (getDeathPenaltyBuffLevel() <= 0)
return;
 
L2Skill skill = SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel());
 
if (skill != null)
{
removeSkill(skill, true);
skill = null;
sendSkillList();
}
 
_deathPenaltyBuffLevel--;
 
if (getDeathPenaltyBuffLevel() > 0)
{
addSkill(SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel()), false);
sendPacket(new EtcStatusUpdate(this));
SystemMessage sm = new SystemMessage(SystemMessageId.DEATH_PENALTY_LEVEL_S1_ADDED);
sm.addNumber(getDeathPenaltyBuffLevel());
sendPacket(sm);
sm = null;
sendSkillList();
}
else
{
sendPacket(new EtcStatusUpdate(this));
sendPacket(new SystemMessage(SystemMessageId.DEATH_PENALTY_LIFTED));
}
}
 
+/**
+* restore all Custom Data hero.
+*/
+public void restoreCustomStatus()
+{
+ if (Config.DEVELOPER)
+ {
+ _log.info("Restoring character status " + getName() + " from database...");
+ }
+ int hero = 0;
+ long hero_end = 0;
+ Connection con = null;
+ try
+ {
+ con = L2DatabaseFactory.getInstance().getConnection(false);
+ PreparedStatement statement = con.prepareStatement(STATUS_DATA_GET);
+ statement.setInt(1, getObjectId());
+ ResultSet rset = statement.executeQuery();
+ while (rset.next())
+ {
+ hero = rset.getInt("hero");
+ hero_end = rset.getLong("hero_end_date");
+ }
+ rset.close();
+ statement.close();
+ statement = null;
+ rset = null;
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+ _log.warning("Error: could not restore char custom data info: " + e);
+ }
+ finally
+ {
+ try
+ {
+ if (con != null)
+ con.close();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ if (hero > 0 && (hero_end == 0 || hero_end > System.currentTimeMillis()))
+ {
+ setHero(true);
+ }
+ else
+ {
+ // delete wings of destiny
+ destroyItem("HeroEnd", 6842, 1, null, false);
+ }
+}
/**
* Restore death penalty buff level.
*/
public void restoreDeathPenaltyBuffLevel()
{
L2Skill skill = SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel());
 
if (skill != null)
{
removeSkill(skill, true);
skill = null;
}
 
 
 
 
 
 
 
 
+net.sf.l2j.gameserver.handler.itemhandlers.HeroCustomItem.java
 
// Hero Custom Item , Created By Stefoulis15
// Added From Stefoulis15 Into The Core.
// Visit www.MaxCheaters.com For Support 
// Source File Name:   HeroCustomItem.java
// Modded by programmos, sword dev
 
package net.sf.l2j.gameserver.handler.itemhandlers;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Logger;
 
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.L2Playable;
import net.sf.l2j.L2DatabaseFactory;
 
public class HeroCustomItem implements IItemHandler
{
 
public HeroCustomItem()
{
// null
}
 
protected static final Logger _log = Logger.getLogger(HeroCustomItem.class.getName());
 
String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
 
@Override
public void useItem(L2Playable playable, ItemInstance item, boolean forceUse)
{
if (Config.HERO_CUSTOM_ITEMS)
{
if (!(playable instanceof L2PcInstance))
return;
 
L2PcInstance activeChar = (L2PcInstance) playable;
 
if (activeChar.isInOlympiadMode())
{
activeChar.sendMessage("This Item Cannot Be Used On Olympiad Games.");
}
 
if (activeChar.isHero())
{
activeChar.sendMessage("You Are Already A Hero!.");
}
else
{
activeChar.setHero(true);
updateDatabase(activeChar, Config.HERO_CUSTOM_DAY * 24L * 60L * 60L * 1000L);
activeChar.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
activeChar.broadcastUserInfo();
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
activeChar.getInventory().addItem("Wings", 6842, 1, activeChar, null);
}
activeChar = null;
}
}
 
public int[] getItemIds()
{
return ITEM_IDS;
}
 
private void updateDatabase(final L2PcInstance player, final long heroTime)
{
Connection con = null;
try
{
if (player == null)
return;
 
con = L2DatabaseFactory.getInstance().getConnection(false);
PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
 
stmt.setInt(1, player.getObjectId());
stmt.setString(2, player.getName());
stmt.setInt(3, 1);
stmt.setLong(4, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
stmt.execute();
stmt.close();
stmt = null;
}
catch (final Exception e)
{
e.printStackTrace();
 
_log.warning("Error: could not update database: " + e);
}
finally
{
try
{
if (con != null)
con.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
 
private static final int ITEM_IDS[] =
{
Config.HERO_CUSTOM_ITEM_ID
};
 
}
 
 
 
 
 
XML
 
    <item id="3481" type="EtcItem" name="Heroi">
        <set name="material" val="GOLD" />
        <set name="is_stackable" val="true" />
        <set name="is_depositable" val="false" />
        <set name="is_dropable" val="false" />
        <set name="handler" val="HeroCustomItem" />
    </item>
 
 
characters_custom_data.sql
 
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `characters_custom_data`
-- ----------------------------
DROP TABLE IF EXISTS `characters_custom_data`;
CREATE TABLE `characters_custom_data` (
  `obj_Id` decimal(11,0) NOT NULL DEFAULT '0',
  `char_name` varchar(35) NOT NULL DEFAULT '',
  `hero` decimal(1,0) NOT NULL DEFAULT '0',
  `hero_end_date` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`obj_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-- ----------------------------
-- Records of characters_custom_data
-- ----------------------------
 

 

 

 

someone could tell me what problem or solution to this? if possible I will thank a lot.

4 answers to this question

Recommended Posts

Guest
This topic is now closed to further replies.


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock