Jump to content
  • 0

Making A New Clan Manager (Can't Add Skills; Acis)


Miracles

Question

Hi guys, i'm reworking some old's clan managers; I got a problem making the scripts give full clan skills; 

 

If u clan is lvl 0-1-2-3-4-5-6-7 make it 8; give u 10.000k Rep (This work FINE) ; But can't make it give skills too.

 

Any help guys?

int[] clanSkills =
       {
               370,
               371,
               372,
               373,
               374,
               375,
               376,
               377,
               378,
               379,
               380,
               381,
               382,
               383,
               384,
               385,
               386,
               387,
               388,
               389,
               390,
               391
       };
if (((player.getClan().getLevel() <= 1) || (player.getClan().getLevel() == 2) || (player.getClan().getLevel() == 3) || (player.getClan().getLevel() == 4) || (player.getClan().getLevel() == 5) || (player.getClan().getLevel() == 6) || (player.getClan().getLevel() == 7)))
                {
                    if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2])
                    {
                        st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]);
                        player.getClan().changeLevel(8);
                        player.getClan().addReputationScore(100000);
                        player.getClan().addNewSkill(clanSkill);
                        player.getClan().broadcastClanStatus();
                        player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                        player.sendMessage("Your reputation score is now " + player.getClan().getReputationScore() + ".");
                        player.sendMessage("Your clan has learned all clan skills.");
                        player.setTarget(player);
                        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                        
                        return "ClanLevelUp.htm";
                    }
                    return "ClanLevelUp-NoItems.htm";
                }
                
                player.getClan().broadcastClanStatus();
                return "ClanLevelUp.htm";
        	}
Link to comment
Share on other sites

Recommended Posts

  • 0

U can explain me, wath this errors wanna say?

 

stillerror.png

 

Services.java

/*
 * Copyright (C) 2004-2013 L2J DataPack
 *
 * This file is part of L2J DataPack.
 *
 * L2J DataPack 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.
 *
 * L2J DataPack 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 custom.Services;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Logger;

import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.CharNameTable;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
 
/**
 * @author Colet
 * Interlude rework SweeTs
 */
public class Services extends Quest
{
    public static final Logger _log = Logger.getLogger(Services.class.getName());
   
    // NPC Id
    int servicesNpc = 50010;
   
    // Noble Items
    int nobleItemId = 57;
    int nobleItemCount = 100;
   
    // PK Reduce Items
    int pkReduceItemId = 57;
    int pkReduceItemCount = 1;
   
    // Change Name Items
    int changeNameItemId = 57;
    int changeNameItemCount = 1000000;
    boolean logNameChanges = true;
   
    // Change Clan Name Items
    int changeClanNameItemId = 57;
    long changeClanNameItemCount = 50000;
    boolean logClanNameChanges = true;
    int clanMinLevel = 5;
    
    // Clan Level Items
    int[] clanLevelItemsId =
    {
    	57, // Level 5 to 6
    	57, // Level 6 to 7
    	57, // Level 7 to 8
    };
    
    int[] clanLevelItemsCount =
    {
    	6, // Level 5 to 6
    	7, // Level 6 to 7
    	8, // Level 7 to 8
    };
    
    // Clan Reputation Points Items
    int clanReputationPointsItemId = 57;
    int clanReputationPointsItemCount = 1;
    
    // Change Gender Items
    int changeGenderItemId = 57;
    int changeGenderItemCount = 50;
	
    public Services(int questId, String name, String descr)
    {
        super(questId, name, descr);
       
        addStartNpc(servicesNpc);
        addFirstTalkId(servicesNpc);
        addTalkId(servicesNpc);
    }
   
    public static void main(String[] args)
    {
        new Services(-1, Services.class.getSimpleName(), "custom");
    }
   
    @Override
    public String onFirstTalk(L2Npc npc, L2PcInstance player)
    {
        if (player.getQuestState(getName()) == null)
        {
            newQuestState(player);
        }
        else if (player.isInCombat())
        	return "Services-Blocked.htm";
        
        else if (player.getPvpFlag() == 1)
        	return "Services-Blocked.htm";
        
        else if (player.getKarma() != 0)
        	return "Services-Blocked.htm";
        
        else if (OlympiadManager.getInstance().isRegistered(player))
        	return "Services-Blocked.htm";
        
        else if (player.isDead() || player.isFakeDeath())
        	return "Services-Blocked.htm";
        
        return "Services.htm";
    }
   
    @Override
    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    {
        String htmlText = event;
        QuestState st = player.getQuestState(getName());
       
        if (event.equals("setNoble"))
        {
            if (!player.isNoble())
            {
                if (st.getQuestItemsCount(nobleItemId) >= nobleItemCount)
                {
                    st.takeItems(nobleItemId, nobleItemCount);
                    player.setNoble(true, true);
                    player.setTarget(player);
                    player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                    player.broadcastUserInfo();
                    return "NoblesseServices-Success.htm";
                }
				return "NoblesseServices-NoItems.htm";
            }
			return "NoblesseServices-AlredyNoble.htm";
        }
        else if (event.equals("levelUpClan"))
        {
            if (player.getClan() == null)
                return "ClanLevelUp-NoClan.htm";
            else if (!player.isClanLeader())
                return "ClanLevelUp-NoLeader.htm";
            else if (player.getClan().getLevel() == 8)
                return "ClanLevelUp-MaxLevel.htm";
            else if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2])
                return "ClanLevelUp-NoItems.htm";
            else
            {
                    st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]);
                    player.getClan().changeLevel(8);
                    player.getClan().addReputationScore(100000);
                    for (L2Skill cs : SkillTable.getClanSkills())
						player.getClan().addNewSkill(cs);
                    player.getClan().broadcastClanStatus();
                    player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                    player.sendMessage("Your reputation score is now " + player.getClan().getReputationScore() + ".");
                    player.sendMessage("Your clan has learned all clan skills.");
                    player.broadcastPacket(new MagicSkillUse(player, player, 5103, 1, 1000, 0));
                    
                    return "ClanLevelUp.htm";    
            }
        }
        else if (event.equals("changeGender"))
        {
        	if (st.getQuestItemsCount(changeGenderItemId) >= changeGenderItemCount)
        	{
            	st.takeItems(changeGenderItemId, changeGenderItemCount);
            	player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
                player.setTarget(player);
                player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
            	player.broadcastUserInfo();
            	
            	return "ChangeGender-Success.htm";
        	}
			return "ChangeGender-NoItems.htm";
        }
        else if (event.startsWith("changeName"))
        {
            try
            {
                String newName = event.substring(11);
               
                if (st.getQuestItemsCount(changeNameItemId) >= changeNameItemCount)
                {                                                      
                    if (newName == null)
                    {                                                      
                        return "ChangeName.htm";
                    }
					if (!newName.matches("^[a-zA-Z0-9]+$"))
					{
					    player.sendMessage("Incorrect name. Please try again.");
					    return "ChangeName.htm";
					}
					else if (newName.equals(player.getName()))
					{
					    player.sendMessage("Please, choose a different name.");
					    return "ChangeName.htm";
					}
					else if (CharNameTable.doesCharNameExist(newName))
					{
					    player.sendMessage("The name " + newName + " already exists.");
					    return "ChangeName.htm";
					}
					else
					{
					    st.takeItems(changeNameItemId, changeNameItemCount);
					    player.setName(newName);
					    player.store();
					    player.sendMessage("Your new character name is " + newName);
					    player.broadcastUserInfo();
					    player.getClan().broadcastClanStatus();
					    
					    return "ChangeName-Success.htm";
					}
                }
				return "ChangeName-NoItems.htm";
            }
            catch (Exception e)
            {
                player.sendMessage("Please, insert a correct name.");
                return "ChangeName.htm";
            }
        }
        else if (event.startsWith("reducePks"))
        {
            try
            {
                String pkReduceString = event.substring(10);
                int pkReduceCount = Integer.parseInt(pkReduceString);
                
                if (player.getPkKills() != 0)
                {
                    if (pkReduceCount == 0)
                    {
                        player.sendMessage("Please, put a higher value.");
                        return "PkServices.htm";
                    }
					if (st.getQuestItemsCount(pkReduceItemId) >= pkReduceCount)
					{
					    st.takeItems(pkReduceItemId, pkReduceItemCount * pkReduceCount);
					    player.setPkKills(player.getPkKills() - pkReduceCount);
					    player.sendMessage("You have successfuly cleaned " + pkReduceCount + " PKs.");
					    player.broadcastUserInfo();
					    
					    return "PkServices-Success.htm";
					}
					return "PkServices-NoItems.htm";
                }
				return "PkServices-NoPks.htm";
            }
            catch (Exception e)
            {
                player.sendMessage("Incorrect value. Please try again.");
                return "PkServices.htm";
            }
        }
        else if (event.startsWith("changeClanName"))
        {
        	if (player.getClan() == null)
        	{
        		return "ChangeClanName-NoClan.htm";
        	}
			try
			{
				String newClanName = event.substring(15);
				
				if (st.getQuestItemsCount(changeClanNameItemId) >= changeClanNameItemCount)
				{
					if (newClanName == null)
					{
						return "ChangeClanName.htm";
					}
					if (!player.isClanLeader())
					{
						player.sendMessage("Only the clan leader can change the clan name.");
						return "ChangeClanName.htm";
					}
					else if (player.getClan().getLevel() < clanMinLevel)
					{
						player.sendMessage("Your clan must be at least level " + clanMinLevel + " to change the name.");
						return "ChangeClanName.htm";
					}
					else if (!newClanName.matches("^[a-zA-Z0-9]+$"))
					{
					    player.sendMessage("Incorrect name. Please try again.");
					    return "ChangeClanName.htm";
					}
					else if (newClanName.equals(player.getClan().getName()))
					{
					    player.sendMessage("Please, choose a different name.");
					    return "ChangeClanName.htm";
					}
					else if (ClanTable.getInstance().getClanByName(newClanName) != null)
					{
					    player.sendMessage("The name " + newClanName + " already exists.");
					    return "ChangeClanName.htm";
					}
					else
					{
					    st.takeItems(changeNameItemId, changeNameItemCount);
					    player.getClan().setName(newClanName);
					    
					    try (Connection con = L2DatabaseFactory.getInstance().getConnection())
					    {
					    	PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_name=? WHERE clan_id=?");
					    	statement.setString(1, newClanName);
					    	statement.setInt(2, player.getClan().getClanId());
					    	statement.execute();
					    	statement.close();
					    }
					    catch (Exception e)
					    {
					    	_log.info("Error updating clan name for player " + player.getName() + ". Error: " + e);
					    }
					    
					    player.sendMessage("Your new clan name is " + newClanName);
					    player.getClan().broadcastClanStatus();
					    
					    return "ChangeClanName-Success.htm";
					}
				}
				return "ChangeClanName-NoItems.htm";
			}
			catch (Exception e)
			{
			    player.sendMessage("Please, insert a correct name.");
			    return "ChangeClanName.htm";
			}
        }
        else if (event.startsWith("setReputationPoints"))
        {
            try
            {
                String reputationPointsString = event.substring(20);
                int reputationPointsCount = Integer.parseInt(reputationPointsString);
                
                if (player.getClan() == null)
                {
                	return "ClanReputationPoints-NoClan.htm";
                }
                else if (!player.isClanLeader())
                {
                	return "ClanReputationPoints-NoLeader.htm";
                }
                else
                {
	                if (reputationPointsCount == 0)
	                {
	                    player.sendMessage("Please, put a higher value.");
	                    return "ClanReputationPoints.htm";
	                }
					if (st.getQuestItemsCount(clanReputationPointsItemId) >= clanReputationPointsItemCount)
					{
						st.takeItems(clanReputationPointsItemId, clanReputationPointsItemCount * reputationPointsCount);
					    player.getClan().addReputationScore(reputationPointsCount);
					    player.getClan().broadcastClanStatus();
					    return "ClanReputationPoints-Success.htm";
					}
					return "ClanReputationPoints-NoItems.htm";
                }
            }
            catch (Exception e)
            {
                player.sendMessage("Incorrect value. Please try again.");
                return "ClanReputationPoints.htm";
            }
        }
        
        return htmlText;
	}
}
Link to comment
Share on other sites

  • 0

Core is already add; 

Index: java/net/sf/l2j/gameserver/datatables/SkillTable.java

+    private static final L2Skill[] _clanSkills = new L2Skill[22];
+    private static final int[] _clanSkillsId =
+    {
+        370,371,372,373,374,375,376,377,378,379,
+        380,381,382,383,384,385,386,387,388,389,
+        390,391
+    };
+    
     private static final L2Skill[] _nobleSkills = new L2Skill[8];
@@ -99,6 +107,9 @@
         for (int i = 0; i < _heroSkillsId.length; i++)
             _heroSkills[i] = getInfo(_heroSkillsId[i], 1);
         
+        for (int i = 0; i < _clanSkillsId.length; i++)
+            _clanSkills[i] = getInfo(_clanSkillsId[i], 1);
+        
         for (int i = 0; i < _nobleSkills.length; i++)

     }

@@ -175,6 +186,11 @@
+    public static L2Skill[] getClanSkills()
+    {
+        return _clanSkills;
+    }

I need the script, save the skills on Clan_Skills table right?

So i need import it, tell me is this ?

import net.sf.l2j.gameserver.datatables.ClanSkillsTable;

Please do not think I'm trolling u ; I sincerely want to learn how it works

Edited by Miracles
Link to comment
Share on other sites

  • 0

I home you added it properly. Also you have to compile again and switch l2jserver.jar

 

You know that, right?

Link to comment
Share on other sites

  • 0

SkillTable.java

/*
 * 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 net.sf.l2j.gameserver.datatables;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.skills.DocumentSkill;

public class SkillTable
{
	private static final Logger _log = Logger.getLogger(SkillTable.class.getName());
	
	private static final Map<Integer, L2Skill> _skills = new HashMap<>();
	private static final Map<Integer, Integer> _skillMaxLevel = new HashMap<>();
	
	private static final L2Skill[] _heroSkills = new L2Skill[5];
	private static final int[] _heroSkillsId =
	{
		395,
		396,
		1374,
		1375,
		1376
	};
	
	private static final L2Skill[] _nobleSkills = new L2Skill[8];
	private static final int[] _nobleSkillsId =
	{
		325,
		326,
		327,
		1323,
		1324,
		1325,
		1326,
		1327
	};
	
	    private static final L2Skill[] _clanSkills = new L2Skill[22];
	    private static final int[] _clanSkillsId =
	    {
	        370,371,372,373,374,375,376,377,378,379,
	        380,381,382,383,384,385,386,387,388,389,
	        390,391
	    };
	    
	
	public static SkillTable getInstance()
	{
		return SingletonHolder._instance;
	}
	
	protected SkillTable()
	{
		load();
	}
	
	private void load()
	{
		final File dir = new File("./data/xml/skills");
		
		for (File file : dir.listFiles())
		{
			DocumentSkill doc = new DocumentSkill(file);
			doc.parse();
			
			for (L2Skill skill : doc.getSkills())
				_skills.put(getSkillHashCode(skill), skill);
		}
		
		_log.info("SkillTable: Loaded " + _skills.size() + " skills.");
		
		// Stores max level of skills in a map for future uses.
		for (final L2Skill skill : _skills.values())
		{
			// Only non-enchanted skills
			final int skillLvl = skill.getLevel();
			if (skillLvl < 99)
			{
				final int skillId = skill.getId();
				final int maxLvl = getMaxLevel(skillId);
				
				if (skillLvl > maxLvl)
					_skillMaxLevel.put(skillId, skillLvl);
			}
		}
		
		// Loading FrequentSkill enumeration values
		for (FrequentSkill sk : FrequentSkill.values())
			sk._skill = getInfo(sk._id, sk._level);
		
		for (int i = 0; i < _heroSkillsId.length; i++)
			_heroSkills[i] = getInfo(_heroSkillsId[i], 1);
		
		for (int i = 0; i < _clanSkillsId.length; i++)
		_clanSkills[i] = getInfo(_clanSkillsId[i], 1);
		
		for (int i = 0; i < _nobleSkills.length; i++)
			_nobleSkills[i] = getInfo(_nobleSkillsId[i], 1);
	}
	
	public void reload()
	{
		_skills.clear();
		_skillMaxLevel.clear();
		
		load();
	}
	
	/**
	 * Provides the skill hash
	 * @param skill The L2Skill to be hashed
	 * @return SkillTable.getSkillHashCode(skill.getId(), skill.getLevel())
	 */
	public static int getSkillHashCode(L2Skill skill)
	{
		return getSkillHashCode(skill.getId(), skill.getLevel());
	}
	
	/**
	 * Centralized method for easier change of the hashing sys
	 * @param skillId The Skill Id
	 * @param skillLevel The Skill Level
	 * @return The Skill hash number
	 */
	public static int getSkillHashCode(int skillId, int skillLevel)
	{
		return skillId * 256 + skillLevel;
	}
	
	public L2Skill getInfo(int skillId, int level)
	{
		return _skills.get(getSkillHashCode(skillId, level));
	}
	
	public int getMaxLevel(int skillId)
	{
		final Integer maxLevel = _skillMaxLevel.get(skillId);
		return (maxLevel != null) ? maxLevel : 0;
	}
	
	/**
	 * @param addNoble if true, will add also Advanced headquarters.
	 * @return an array with siege skills.
	 */
	public L2Skill[] getSiegeSkills(boolean addNoble)
	{
		L2Skill[] temp = new L2Skill[2 + (addNoble ? 1 : 0)];
		int i = 0;
		
		temp[i++] = _skills.get(SkillTable.getSkillHashCode(246, 1));
		temp[i++] = _skills.get(SkillTable.getSkillHashCode(247, 1));
		
		if (addNoble)
			temp[i++] = _skills.get(SkillTable.getSkillHashCode(326, 1));
		
		return temp;
	}
	
	    public static L2Skill[] getClanSkills()
	    {
	        return _clanSkills;
	   }
	
	public static L2Skill[] getHeroSkills()
	{
		return _heroSkills;
	}
	
	public static boolean isHeroSkill(int skillid)
	{
		for (int id : _heroSkillsId)
			if (id == skillid)
				return true;
		
		return false;
	}
	
	public static L2Skill[] getNobleSkills()
	{
		return _nobleSkills;
	}
	
	/**
	 * Enum to hold some important references to frequently used (hardcoded) skills in core
	 * @author DrHouse
	 */
	public static enum FrequentSkill
	{
		LUCKY(194, 1),
		SEAL_OF_RULER(246, 1),
		BUILD_HEADQUARTERS(247, 1),
		STRIDER_SIEGE_ASSAULT(325, 1),
		DWARVEN_CRAFT(1321, 1),
		COMMON_CRAFT(1322, 1),
		LARGE_FIREWORK(2025, 1),
		SPECIAL_TREE_RECOVERY_BONUS(2139, 1),
		
		ANTHARAS_JUMP(4106, 1),
		ANTHARAS_TAIL(4107, 1),
		ANTHARAS_FEAR(4108, 1),
		ANTHARAS_DEBUFF(4109, 1),
		ANTHARAS_MOUTH(4110, 1),
		ANTHARAS_BREATH(4111, 1),
		ANTHARAS_NORMAL_ATTACK(4112, 1),
		ANTHARAS_NORMAL_ATTACK_EX(4113, 1),
		ANTHARAS_SHORT_FEAR(5092, 1),
		ANTHARAS_METEOR(5093, 1),
		
		RAID_CURSE(4215, 1),
		WYVERN_BREATH(4289, 1),
		ARENA_CP_RECOVERY(4380, 1),
		RAID_CURSE2(4515, 1),
		VARKA_KETRA_PETRIFICATION(4578, 1),
		FAKE_PETRIFICATION(4616, 1),
		THE_VICTOR_OF_WAR(5074, 1),
		THE_VANQUISHED_OF_WAR(5075, 1),
		BLESSING_OF_PROTECTION(5182, 1),
		FIREWORK(5965, 1);
		
		protected final int _id;
		protected final int _level;
		protected L2Skill _skill = null;
		
		private FrequentSkill(int id, int level)
		{
			_id = id;
			_level = level;
		}
		
		public L2Skill getSkill()
		{
			return _skill;
		}
	}
	
	private static class SingletonHolder
	{
		protected static final SkillTable _instance = new SkillTable();
	}
}

Compile:

 

build.png

Link to comment
Share on other sites

  • 0

But, did you replace the jar?

 

And as I said, fix imports. You miss L2Skill.

Edited by SweeTs
Link to comment
Share on other sites

  • 0

But, did you replace the jar?

 

And as I said, fix imports. You miss L2Skill.

 

Yep i replace it after run build;

 

Check the imports, i add L2Skill but still give me errors;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Logger;

import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.CharNameTable;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.datatables.ClanSkillsTable;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;

Error

 

1449101342_error.png

Link to comment
Share on other sites

  • 0

You should activate Eclipse warning section (or use an IDE such as Eclipse, and btw, why does it simply compile at all ?), it's not up to SweeTs to be your personal warning section.

Edited by Tryskell
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...