This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..
Question
janiko
Hope someone can help
I wrote script to restore buffs here is the function.
the problem is that it restores only first buff from sql record
Example of Sql Record
-- ---------------------------- -- Table structure for `community_skillsave` -- ---------------------------- DROP TABLE IF EXISTS `community_skillsave`; CREATE TABLE `community_skillsave` ( `charId` int(10) DEFAULT NULL, `skills` text, `pet` text ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of community_skillsave -- ---------------------------- INSERT INTO `community_skillsave` VALUES ('268480452', '1240;1048;', null);Restore Java Script
private void RESTOR(L2PcInstance activeChar) { Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement stat = con.prepareStatement("SELECT * FROM community_skillsave WHERE charId=?;"); stat.setInt(1, activeChar.getObjectId()); ResultSet rset = stat.executeQuery(); rset.next(); String allskills = rset.getString(2); StringTokenizer stBuff = new StringTokenizer(allskills, ";"); while (stBuff.hasMoreTokens()) { int skilltoresatore = Integer.parseInt(stBuff.nextToken()); int skilllevel = SkillTable.getInstance().getMaxLevel(skilltoresatore); L2Skill skill = SkillTable.getInstance().getInfo(skilltoresatore, skilllevel); PreparedStatement st = con.prepareStatement("SELECT COUNT(*) FROM community_skillsave WHERE skills=?;"); st.setInt(1, skilltoresatore); ResultSet rs = st.executeQuery(); rs.next(); if (rs.getInt(1) != 0) { skill.getEffects(activeChar, activeChar); } else { activeChar.sendMessage("Buff: " + skill.getName() + " (" + skill.getId() + "), can't be restored!"); } rs.close(); st.close(); } rset.close(); stat.close(); } catch (SQLException e) { } finally { L2DatabaseFactory.close(con); } }thanks to everyone
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now