Jump to content

Recommended Posts

Posted (edited)

there is a big bug when you try to add reputation points, sometimes you add 1000 rep points and is multiplying the ammount ...

 

http://www.maxcheaters.com/topic/165828-hi5-services-npc/?p=2241888

 

It's buggy cuz it gets your actual reputation number [ aka player.getClan().getReputationScore() ] ++ the points that you want add.

 

My interlude version is bugless if you want.

Edited by SweeTs
Posted

yes I have tryed with: player.getClan().addReputationScore(reputationPointsCount);  but give error, I got the last beta high five version, do you know how to convert it for h5?

Posted (edited)

yes I have tryed with: player.getClan().addReputationScore(reputationPointsCount);  but give error, I got the last beta high five version, do you know how to convert it for h5?

 

Just search over Eclipse for "addReputationScore" / "setReputationScore" / "ReputationScore" and you will see what is the correct method.

 

As I see it's correct method, so there shouldn't be any error. Anyway, post the error/screen here or create new topic in request help, as you wish.

Edited by SweeTs
Posted

public synchronized void addReputationScore(int value, boolean save)
Just...

player.getClan().addReputationScore(reputationPointsCount, true);
  • 1 month later...
Posted

Hey mate, awesome work you did there! I found a small bug though. When I use the function "Clan level up" the clan levels up, but it isn't saved in the DB so after every server restart, the clan level is being reset to 0... Not getting any errors though :/ Would be awesome if you could look into it :D I will check it out a bit more myself but I am a rookie so I kinda doubt I will find a solution :/

Posted

Hey mate, awesome work you did there! I found a small bug though. When I use the function "Clan level up" the clan levels up, but it isn't saved in the DB so after every server restart, the clan level is being reset to 0... Not getting any errors though :/ Would be awesome if you could look into it :D I will check it out a bit more myself but I am a rookie so I kinda doubt I will find a solution :/

 

http://www.maxcheaters.com/topic/167407-services-npc/?p=2294525

Posted

i Add it agan and again.. and is the same, code is correctly. lock.

 

/*

 * Copyright © 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.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Logger;
 
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
 
/**
 * @author Colet
 */
public class Services extends Quest
{
    public static final Logger _log = Logger.getLogger(Services.class.getName());
   
    // NPC Id
    int servicesNpc = 9013;
   
    // Noble Items
    int nobleItemId = 57;
    long nobleItemCount = 1;
   
    // PK Reduce Items
    int pkReduceItemId = 57;
    long pkReduceItemCount = 1000;
   
    // Change Name Items
    int changeNameItemId = 57;
    long 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
    57, // Level 8 to 9
    57, // Level 9 to 10
    57 // Level 10 to 11
    };
    
    long[] clanLevelItemsCount =
    {
    6, // Level 5 to 6
    7, // Level 6 to 7
    8, // Level 7 to 8
    9, // Level 8 to 9
    10, // Level 9 to 10
    11 // Level 10 to 11
    };
    
    // Clan Reputation Points Items
    int clanReputationPointsItemId = 57;
    long clanReputationPointsItemCount = 5;
    
    // Change Gender Items
    int changeGenderItemId = 57;
    long 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");
    }
   
    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";
        }
        
        return "Services.htm";
    }
   
    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);
                    player.setTarget(player);
                    player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                    player.broadcastUserInfo();
                    return "NoblesseServices-Success.htm";
                }
                else
                {
                    return "NoblesseServices-NoItems.htm";
                }
            }
            else
            {
                return "NoblesseServices-AlredyNoble.htm";
            }
        }
        else if (event.equals("levelUpClan"))
        {
        if (!player.isClanLeader())
        {
        return "ClanLevelUp-NoLeader.htm";
        }
        else
        {
        if (player.getClan().getLevel() == 11)
        {
        return "ClanLevelUp-MaxLevel.htm";
        }
        else
        {
        if (((player.getClan().getLevel() <= 1) || (player.getClan().getLevel() == 2) || (player.getClan().getLevel() == 3) || (player.getClan().getLevel() == 4)))
        {
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
            player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                        player.setTarget(player);
                        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                        return "ClanLevelUp.htm";
        }
        else if (player.getClan().getLevel() == 5)
        {
        if (st.getQuestItemsCount(clanLevelItemsId[0]) >= clanLevelItemsCount[0])
        {
            st.takeItems(clanLevelItemsId[0], clanLevelItemsCount[0]);
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
                player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                            player.setTarget(player);
                            player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                            return "ClanLevelUp.htm";
        }
        else
        {
        return "ClanLevelUp-NoItems.htm";
        }
        }
        else if (player.getClan().getLevel() == 6)
        {
        if (st.getQuestItemsCount(clanLevelItemsId[1]) >= clanLevelItemsCount[1])
        {
            st.takeItems(clanLevelItemsId[1], clanLevelItemsCount[1]);
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
                player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                            player.setTarget(player);
                            player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                            return "ClanLevelUp.htm";
        }
        else
        {
        return "ClanLevelUp-NoItems.htm";
        }
        }
        else if (player.getClan().getLevel() == 7)
        {
        if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2])
        {
            st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]);
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
                player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                            player.setTarget(player);
                            player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                            return "ClanLevelUp.htm";
        }
        else
        {
        return "ClanLevelUp-NoItems.htm";
        }
        }
        else if (player.getClan().getLevel() == 8)
        {
        if (st.getQuestItemsCount(clanLevelItemsId[3]) >= clanLevelItemsCount[3])
        {
            st.takeItems(clanLevelItemsId[3], clanLevelItemsCount[3]);
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
                player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                            player.setTarget(player);
                            player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                            return "ClanLevelUp.htm";
        }
        else
        {
        return "ClanLevelUp-NoItems.htm";
        }
        }
        else if (player.getClan().getLevel() == 9)
        {
        if (st.getQuestItemsCount(clanLevelItemsId[4]) >= clanLevelItemsCount[4])
        {
            st.takeItems(clanLevelItemsId[4], clanLevelItemsCount[4]);
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
                player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                            player.setTarget(player);
                            player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                            return "ClanLevelUp.htm";
        }
        else
        {
        return "ClanLevelUp-NoItems.htm";
        }
        }
        else if (player.getClan().getLevel() == 10)
        {
        if (st.getQuestItemsCount(clanLevelItemsId[5]) >= clanLevelItemsCount[5])
        {
            st.takeItems(clanLevelItemsId[5], clanLevelItemsCount[5]);
            player.getClan().setLevel(player.getClan().getLevel() + 1);
            player.getClan().broadcastClanStatus();
                player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
                            player.setTarget(player);
                            player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                            return "ClanLevelUp.htm";
        }
        else
        {
        return "ClanLevelUp-NoItems.htm";
        }
        }
       
                    try (Connection con = L2DatabaseFactory.getInstance().getConnection();
                    PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_level=? WHERE clan_id=?"))
                    {
                    statement.setInt(1, player.getClan().getLevel());
                    statement.setInt(2, player.getClan().getClanId());
                    statement.execute();
                    statement.close();
                    }
                    catch (Exception e)
                    {
                    _log.info("Error updating clan level for player " + player.getName() + ". Error: " + e);
                    }
                    
        player.getClan().broadcastClanStatus();
        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";
        }
        else
        {
        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";
                    }
                    else
                    {
                        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.getInstance().doesCharNameExist(newName))
                        {
                            player.sendMessage("The name " + newName + " already exists.");
                            return "ChangeName.htm";
                        }
                        else
                        {
                            if (logNameChanges)
                            {
                                String fileName = "log/Services/Name Change - " + player.getName() + ".txt";
                                new File(fileName);
                                FileWriter fileText = new FileWriter(fileName);
                                BufferedWriter fileContent = new BufferedWriter(fileText);
                                fileContent.write("Character name change info:\r\n\r\nCharacter original name: " + player.getName() + "\r\nCharacter new name: " + newName);
                                fileContent.close();
                            }
                           
                            st.takeItems(changeNameItemId, changeNameItemCount);
                            player.setName(newName);
                            player.store();
                            player.sendMessage("Your new character name is " + newName);
                            player.broadcastUserInfo();
                            return "ChangeName-Success.htm";
                        }
                    }
                }
                else
                {
                    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";
                    }
                    else
                    {
                        if (st.getQuestItemsCount(pkReduceItemId) >= pkReduceItemCount)
                        {
                            st.takeItems(pkReduceItemId, pkReduceItemCount * pkReduceCount);
                            player.setPkKills(player.getPkKills() - pkReduceCount);
                            player.sendMessage("You have successfuly cleaned " + pkReduceCount + " PKs.");
                            player.broadcastUserInfo();
                            return "PkServices-Success.htm";
                        }
                        else
                        {
                            return "PkServices-NoItems.htm";
                        }
                    }
                }
                else
                {
                    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";
        }
        else
        {
        try
        {
        String newClanName = event.substring(15);
       
        if (st.getQuestItemsCount(changeClanNameItemId) >= changeClanNameItemCount)
        {
        if (newClanName == null)
        {
        return "ChangeClanName.htm";
        }
                   else
                   {
                       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 (null != ClanTable.getInstance().getClanByName(newClanName))
                       {
                           player.sendMessage("The name " + newClanName + " already exists.");
                           return "ChangeClanName.htm";
                       }
                       else
                       {
                           if (logClanNameChanges)
                           {
                               String fileName = "log/Services/Clan Name Change - " + player.getClan().getName() + ".txt";
                               new File(fileName);
                               FileWriter fileText = new FileWriter(fileName);
                               BufferedWriter fileContent = new BufferedWriter(fileText);
                               fileContent.write("Clan name change info:\r\n\r\nClan original name: " + player.getClan().getName() + "\r\nClan new name: " + newClanName + "\r\nClan Leader: " + player.getName());
                               fileContent.close();
                           }
                           
                           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";
                       }
                   }
        }
        else
        {
        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";
               }
               else
               {
                   if (st.getQuestItemsCount(clanReputationPointsItemId) >= clanReputationPointsItemCount)
                   {
                       st.takeItems(clanReputationPointsItemId, clanReputationPointsItemCount * reputationPointsCount);
                       player.getClan().addReputationScore(player.getClan().getReputationScore() + reputationPointsCount, true);
                       player.getClan().broadcastClanStatus();
                       return "ClanReputationPoints-Success.htm";
                   }
                   else
                   {
                       return "ClanReputationPoints-NoItems.htm";
                   }
               }
                }
            }
            catch (Exception e)
            {
                player.sendMessage("Incorrect value. Please try again.");
                return "ClanReputationPoints.htm";
            }
        }
        
        return htmlText;
}
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • A New Chapter Begins We're Rebuilding – Join Our Staff Team After many years of activity, growth, and challenges, it’s finally time for our community to restructure and move forward. We’re ready to turn a new page and evolve into something greater — but we can’t do it without the help of passionate and committed people. That’s why we’re now opening up staff applications for those who want to actively shape the future of our community. If you have the motivation, time, and patience to contribute to something meaningful, this is your chance to step in and make a real impact. What We're Looking For We’re building a fresh and dedicated team of individuals who are ready to support and grow this project. Open roles include: Moderators – to keep the forum clean, safe, and organized Gaming Moderators – to help manage gaming boards (e.g., Lineage, GTA FiveM) Content Creators – to post updates, guides, and articles Community Managers – to engage users and drive activity Technical Staff – for development, backend, and server work We’re not focusing only on Lineage anymore. Our vision is expanding to new areas — including GTA FiveM and other multiplayer games you might have expertise in. If you have a good idea, a server plan, or something new to suggest — we’re open to it. Now’s the time to bring it forward. Requirements We’re looking for individuals who have: A history of activity on the forum (preferred) Available time to contribute consistently A sense of teamwork and responsibility A genuine interest in gaming and community building If you're interested, just send a private message to me or Celestine. (or just reply here) Tell us a few things about yourself and how you’d like to contribute. Let’s bring this community back to life. Let’s rebuild something great — together.   M M G A 
    • Lineage2Network - Interlude Reimagined   Embark on a revitalized journey through the classic Interlude era with Lineage2.Network. Our server is meticulously crafted by veteran players to deliver a seamless and engaging experience, blending the nostalgia of the Chaotic Chronicle with modern enhancements.     Server details   Chronicle: Interlude + Classic Rates: EXP x30 | Adena x10 | Drop x10 | Spoil x10     Server features   Daily Missions - complete special tasks for daily rewards Attendance Rewards - get rewards for online time Custom Events - TVT, DM, CTF NPC buffer duration - 2 hours   Mana Potions - restores 1000 MP, 10s cooldown Ring of Core additional stats: +1 STR Earring of Orfen additional stats: +1 INT Shadow Earring of Zaken - 7 days Shadow Ring of Queen Ant - 7 days   Max buff count - 24 (20 + 4 with Divine Inspiration) Noblesse, Heroic Valor, Flames of Invincibility and Celestial Shield don't take buff slot Reworked Cancel, Mage and Warrior Banes – removed buffs reappear after 30s Block Buffs - block all incoming buffs except from self/party Sweeper Festival added to Spoiler class   Subclass – retail or purchasable Noblesse – retail or purchasable up to Barakiel; collect 8 fragments for full staff 1st & 2nd class free, 3rd needs 700 Halisha Marks or is purchasable New Olympiad System: new stadiums with NPC buffer,  1 week period.     Key dates     Beta Launch: April 14, 2025 Official Launch: May 9, 2025     Check out full server details in our website And visit our discord   Join us and be part of community where classic gameplay meets innovative updates. Whether you're a solo adventurer or part of a formidable clan, Lineage2.Network offers a dynamic and balanced environment for all.  
    • Good day. Our game currency store is looking for suppliers of adena and items on a project such as L2REBORN x10. We also sell Epic jewelry and various items on this project L2REBORN x10. There are items and adena on L2REBORN x1. For all questions, write to us in discord - goddardshop
  • Topics

×
×
  • Create New...