Jump to content

Question

Posted

 Could any good soul adapt this mode to l2jfrozen?

package handlers.voicedcommandhandlers;

import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

/**
* @author Cobra
*/

public class autoloot implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
private static String[] _voicedCommands =
{
    "autolooton",
    "autolootoff"
};

public String[] getVoicedCommandList()
{
    return VOICED_COMMANDS;
}

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
    if (command.equalsIgnoreCase("autolooton"))
    {
        activeChar.setAutoLootEnabled(true);
        activeChar.sendMessage("Auto loot is now enabled.");
    }
    else if (command.equalsIgnoreCase("autolootoff"))
    {
        activeChar.setAutoLootEnabled(false);
        activeChar.sendMessage("Auto loot is now disabled.");
    }
    return true;
}
}

It is for l2jserver but it is missing the L2PCInstance file from setAutoLootEnabled

I even tried it but when I tested it it didn't run the code I created it was this

/** AutoLoot parameters*/
private boolean _autoLootEnabled = false;

public void setAutoLootEnabled(final boolean autoLootEnabled)
{
_autoLootEnabled = autoLootEnabled;

}

 

/**
* @param reference
* @return Returns the autoLootEnabled.
*/

public boolean isAutoLootEnabled(final L2Object reference)
{
return _autoLootEnabled && !(reference instanceof L2GrandBossInstance)
&& !(reference instanceof L2RaidBossInstance)
&& !(reference instanceof L2MinionInstance);

}

 

1 answer to this question

Recommended Posts

  • 0
Posted (edited)

If you sit down and study the code for several minutes you will understand how it work

and you won't need any help or copy paste the exact code.

 

This code:

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
    if (command.equalsIgnoreCase("autolooton"))
    {
        activeChar.setAutoLootEnabled(true);
        activeChar.sendMessage("Auto loot is now enabled.");
    }
    else if (command.equalsIgnoreCase("autolootoff"))
    {
        activeChar.setAutoLootEnabled(false);
        activeChar.sendMessage("Auto loot is now disabled.");
    }
    return true;
}

 

can turn into this:

@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
    activeChar.setIsAutoLoot(!activeChar.isAutoLoot());
    activeChar.sendMessage("Auto loot is now " + (isAutoLoot(null) ? "enabled." : "disabled"));
    return true;
}

You don't need the if statement since there are only 2 cases and the useVoicedCommand will only executed when 1 of these handler that are in String[] are called. 

 

And this code: 

private boolean _autoLootEnabled = false;

public void setAutoLootEnabled(final boolean autoLootEnabled)
{
_autoLootEnabled = autoLootEnabled;

}

 

/**
* @param reference
* @return Returns the autoLootEnabled.
*/

public boolean isAutoLootEnabled(final L2Object reference)
{
return _autoLootEnabled && !(reference instanceof L2GrandBossInstance)
&& !(reference instanceof L2RaidBossInstance)
&& !(reference instanceof L2MinionInstance);

}

Should be better:

private boolean _isAutoLoot;

public void setIsAutoLoot(final boolean val)
{
   _isAutoLoot = val;
}

public boolean isAutoLoot(final L2Character target)
{
   return Objects.nonNull(target) && target.isRaid() ? false : _isAutoLoot;
}

 

Edited by EdithFinch

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
Answer this question...

×   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

    • Thank you for the reply. I know that this issue is due to L2 being so old. I was just wondering if there was an external way to fix the UI scaling. Like a patch or some settings.
    • Bro the game is so old it doesn't have a native option to scale the UI like in modern MMOs
    • Dear players, From April 19 to April 27 inc., the Bonus Start event will be active. It’s designed to help new and low-level characters get started more easily.   All characters that meet one of the following conditions: — created less than 3 days ago (regardless of level), — currently level 20 or below, — created during the event period, will receive upon login: — 10 sets of buff scrolls (phys or mage, depending on class), — 10 packs of +50% Drop/Spoil runes (2 hours each), — 10 packs of +50% Exp runes (2 hours each). Characters between level 21 and 30 will receive upon login: — 6 sets of buff scrolls, — 6 packs of +50% Drop/Spoil runes (2h each), — 6 packs of +50% Exp runes (2h each).   Event items will be removed approx. 09.05.2025 Server rates will be increased to x2.25. Take this chance to start your journey with ease or bring an old hero back into the fight — it’s the perfect time to test your strength! Open Beta Test is started!  Helper cats are waiting in towns — talk to them to receive the necessary equipment and level up your character. Siege Schedule:  - April 13 at 16:00 (GMT+2) – Innadrile Castle - April 14 at 20:00 (GMT+2) – Bandit Stronghold - April 15 at 20:00 (GMT+2) – Devastated Castle 📌 During the OBT, players who report bugs will receive CoL:   - 1 CoL for each reported staticmeshes bug (e.g., walking through textures, stairs, etc.) - 2 CoL or more for server-related issues (depending on severity) You can report bugs on the forum. The Open Beta Test will run approximately until April 15 at 23:00 (GMT+2). Your activity and feedback will help us improve the game.   Download links: Download client | Download updater 
    • begin if (user.dead) then begin delay(555); Engine.GoHome(rtCastle); print('User dead, going to castle..') end; end.  
    • Hello everyone. Long time no see. I've been trying to play L2 on my 4k monitor, however the UI is extremely small.  I checked around the internet and couldn't find a guide on how to keep the resolution high and the UI size a bit bigger. I either get small UI + full resolution (correct resolution of monitor), or normal sized UI but resolution set to full HD (which doesn't really look good on a 4k screen). Adjusting scaling on display settings doesn't change the UI just the text on L2. Does anyone know a way to increase the UI size only and keeping the screens resolution same (4k) ? I'll share a screenshot as an example, and it 's not even full screen mode. https://freeimage.host/i/3cvPVnI  
  • Topics

×
×
  • Create New...