Всем добра! Сборка ласт PW, подскажите кому не сложно с меня +
1) нужно реализовать ACP, знаю оно есть через ctrl, MP/CP прекрасно работают, но там когда умирает персонаж банка НР юзается быстро без останки
Кто может в этом разобрался или как исправить посоветуйте пожалуйста....
Выдернул скрипт из другой сборки pwsoft, там прекрасно работает! У меня выдает эти ошибки
Как исправить эти ошибки ниже?
2) Есть ли в PW фишка ??? выскакивает приглашение на эвенты или на РБ видел на l2code реализован.
3) Снимается CP когда убивает моб, не критично но есть ли решение ??
----------
1. ERROR in \AutoCombatPotions.java (at line 107)
handler.useItem(player, potions);
^^^^^^^
The method useItem(L2PlayableInstance, L2ItemInstance, boolean) in the type IIte
mHandler is not applicable for the arguments (L2PcInstance, L2ItemInstance)
----------
2. ERROR in \AutoCombatPotions.java (at line 121)
handler.useItem(player, potions);
^^^^^^^
The method useItem(L2PlayableInstance, L2ItemInstance, boolean) in the type IIte
mHandler is not applicable for the arguments (L2PcInstance, L2ItemInstance)
----------
3. ERROR in \AutoCombatPotions.java (at line 135)
handler.useItem(player, potions);
^^^^^^^
The method useItem(L2PlayableInstance, L2ItemInstance, boolean) in the type IIte
mHandler is not applicable for the arguments (L2PcInstance, L2ItemInstance)
----------
3 problems (3 errors)
The method useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance
, net.sf.l2j.gameserver.model.L2ItemInstance, boolean) in the type scripts.items
.IItemHandler is not applicable for the arguments (net.sf.l2j.gameserver.model.a
ctor.instance.L2PcInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
The method useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance
, net.sf.l2j.gameserver.model.L2ItemInstance, boolean) in the type scripts.items
.IItemHandler is not applicable for the arguments (net.sf.l2j.gameserver.model.a
ctor.instance.L2PcInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
The method useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance
, net.sf.l2j.gameserver.model.L2ItemInstance, boolean) in the type scripts.items
.IItemHandler is not applicable for the arguments (net.sf.l2j.gameserver.model.a
ctor.instance.L2PcInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
Failed executing script: C:\12345\server\gameserver\data\scripts\calypso\AutoCom
batPotions.java. See AutoCombatPotions.java.error.log for details.
##############################
Вот сам скрипт
package calypso;
import java.util.HashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.PcInventory;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import scripts.commands.IVoicedCommandHandler;
import scripts.commands.VoicedCommandHandler;
import scripts.items.IItemHandler;
import scripts.items.ItemHandler;
/**
*
* @author Calypso
*
*/
public class AutoCombatPotions implements IVoicedCommandHandler {
private final static Logger _log = Logger.getLogger(AutoCombatPotions.class.getName());
// разрешить юз банок
private static boolean ALLOW_CP = true, ALLOW_HP = true, ALLOW_MP = true;
// проценты для юза
private static int PERCENT_CP = 90, PERCENT_HP = 90, PERCENT_MP = 90;
// банки, ищутся в сумке чара, юзается первая попавшаяся
private static final int[] CP_POTIONS = { 5592 }, HP_POTIONS = { 1539 }, MP_POTIONS = { 728 };
// как часто запускать поток для юза всех банок (это значение будет максимальной погрешностью)
private static long RUN_DELAY = 500;
// реюз каждого типа банок (нет смысла устанавливать менее RUN_DELAY)
private static long CP_DELAY = 500, HP_DELAY = 15000, MP_DELAY = 1000;
// только для премиумов
private static boolean ONLY_PREMIUM = false;
private static HashMap<Integer, ScheduledFuture<?>> runnedAcps = new HashMap<Integer, ScheduledFuture<?>>();
private static HashMap<String, Long> reuses = new HashMap<String, Long>();
@Override
public String[] getVoicedCommandList() {
return new String[] { "acpon", "acpoff", "acpof" };
}
@Override
public boolean useVoicedCommand(String command, L2PcInstance player, String target) {
if (player == null)
return false;
if (command.toLowerCase().equals("acpon")) {
if (ONLY_PREMIUM && !player.isPremium()) {
player.sendMessage("Only for Premium-players!");
return false;
}
if (runnedAcps.containsKey(player.getObjectId())) {
player.sendMessage("ACP already started!");
return false;
}
runnedAcps.put(player.getObjectId(), ThreadPoolManager.getInstance()
.scheduleAiAtFixedRate(new PotionUseTask(player), RUN_DELAY, RUN_DELAY));
player.sendMessage("ACP success started!");
} else if (command.toLowerCase().equals("acpoff") || command.toLowerCase().equals("acpof")) {
if (runnedAcps.containsKey(player.getObjectId())) {
cancelTask(player.getObjectId());
player.sendMessage("ACP is stoped!");
return false;
} else
player.sendMessage("ACP already stoped!");
}
return false;
}
private class PotionUseTask implements Runnable {
private L2PcInstance player;
private int safeObjId;
public PotionUseTask(L2PcInstance player) {
this.player = player;
safeObjId = player.getObjectId();
}
@Override
public void run() {
try {
if (player == null) {
_log.info("ACP: player is null!!! WTF? ObjID " + safeObjId);
cancelTask(safeObjId);
return;
}
if (player.isOnline() != 1) {
cancelTask(safeObjId);
return;
}
PcInventory inv = player.getInventory();
IItemHandler handler = null;
L2ItemInstance potions = null;
if (ALLOW_CP && checkReuse(safeObjId, "CP")) {
potions = getPotionFromInv(inv, "CP");
if (potions != null) {
if ((player.getCurrentCp() / player.getMaxCp()) * 100 < PERCENT_CP) {
handler = ItemHandler.getInstance().getItemHandler(potions.getItemId());
if (handler != null)
{
handler.useItem(player, potions);
setReuse(safeObjId, "CP");
}
}
}
}
if (ALLOW_HP && checkReuse(safeObjId, "HP")) {
potions = getPotionFromInv(inv, "HP");
if (potions != null) {
if ((player.getCurrentHp() / player.getMaxHp()) * 100 < PERCENT_HP) {
handler = ItemHandler.getInstance().getItemHandler(potions.getItemId());
if (handler != null)
{
handler.useItem(player, potions);
setReuse(safeObjId, "HP");
}
}
}
}
if (ALLOW_MP && checkReuse(safeObjId, "MP")) {
potions = getPotionFromInv(inv, "MP");
if (potions != null) {
if ((player.getCurrentMp() / player.getMaxMp()) * 100 < PERCENT_MP) {
handler = ItemHandler.getInstance().getItemHandler(potions.getItemId());
if (handler != null)
{
handler.useItem(player, potions);
setReuse(safeObjId, "MP");
}
}
}
}
} catch (Exception e) {
runnedAcps.get(safeObjId).cancel(false);
}
}
}
private boolean checkReuse(int objId, String type)
{
String pair = String.valueOf(objId) + ":" + type;
if(!reuses.containsKey(pair))
return true;
long lastUse = reuses.get(pair);
if(System.currentTimeMillis() - lastUse >= getReuseForPotion(type))
return true;
return false;
}
private void setReuse(int objId, String type)
{
String pair = String.valueOf(objId) + ":" + type;
reuses.put(pair, System.currentTimeMillis());
}
private long getReuseForPotion(String type)
{
type = type.toLowerCase();
if(type.equals("cp"))
return CP_DELAY;
if(type.equals("hp"))
return HP_DELAY;
if(type.equals("mp"))
return MP_DELAY;
return 0;
}
private L2ItemInstance getPotionFromInv(PcInventory inv, String type) {
L2ItemInstance result = null;
int[] search = null;
if (type.toLowerCase().equals("cp"))
search = CP_POTIONS;
if (type.toLowerCase().equals("hp"))
search = HP_POTIONS;
if (type.toLowerCase().equals("mp"))
search = MP_POTIONS;
if (search == null)
_log.warning(
"ACP: getPotionFromInv() == null, invalid potion type or unsetted id of potions! Type: " + type);
for (int id : search) {
result = inv.getItemByItemId(id);
if (result != null)
break;
}
return result;
}
private void cancelTask(int objId) {
runnedAcps.remove(objId).cancel(false);
}
public static void main(String... arguments) {
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new AutoCombatPotions());
_log.info("### ACP service by Calypso loaded!");
}
}