Hi!, I'd like to know how to register a custom ByPassHandler.
I want to be able to call my bypass from <a action="bypass -h custombypass.CustomClass:customMethod">
Thanks!
I already send ALOT of examples, that is last time. Look on code
Bypasses for call this script will look like that. Call
<button width=100 height=18 action="bypass -h scripts_services.MyCustomService:myCustomBypassToHtml" back="L2UI_CH3.bigbutton2_down" fore="L2UI_CH3.bigbutton2" value="MyCustomService">
After we show scripts/services/my_custom_service_page.htm (look at code)
at page my_custom_service_page.htm we have bypass to my_custom_functions
<button width=100 height=18 action="bypass -h scripts_services.MyCustomService:my_custom_functions" back="L2UI_CH3.bigbutton2_down" fore="L2UI_CH3.bigbutton2" value="Make me BlaBlaBla">
Where MyCustomService is class name
myCustomBypassToHtml - method for calling my_custom_service_page.htm
my_custom_functions - method call actions that will change to the player
Also you can call directrly code without showing myCustomBypassToHtml, that is example for replacement at HTML
msg.replace("%item_id%", String.valueOf(Config.MY_CUSTOM_SERVICE_ITEM));
msg.replace("%item_count%", String.valueOf(Config.MY_CUSTOM_SERVICE_PRICE));
This code you can send from any npc or bbs or else, also look how the bypass should look in Community Board at gudes if you call your own service from it
Java:
package services;
import l2.gameserver.Config;
import l2.gameserver.model.Player;
import l2.gameserver.network.l2.components.SystemMsg;
import l2.gameserver.network.l2.s2c.NpcHtmlMessage;
import l2.gameserver.scripts.Functions;
import l2.gameserver.templates.item.ItemTemplate;
import l2.gameserver.utils.ItemFunctions;
public class MyCustomService extends Functions
{
public void myCustomBypassToHtml()
{
Player player = getSelf();
if(player == null)
return;
if(!Config.MY_CUSTOM_SERVICE) // If that is disabled we send service_disabled.htm
{
player.sendPacket(new NpcHtmlMessage(5).setFile("scripts/services/service_disabled.htm"));
return;
}
NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("scripts/services/my_custom_service_page.htm");
msg.replace("%item_id%", String.valueOf(Config.MY_CUSTOM_SERVICE_ITEM));
msg.replace("%item_count%", String.valueOf(Config.MY_CUSTOM_SERVICE_PRICE));
player.sendPacket(msg);
}
public void my_custom_functions()
{
Player player = getSelf();
if(player == null || !CheckPlayerConditions(player)) // Check null and basic condition
return;
if(!Config.MY_CUSTOM_SERVICE) // If that is disabled we send service_disabled.htm
{
player.sendPacket(new NpcHtmlMessage(5).setFile("scripts/services/service_disabled.htm"));
return;
}
if(!player.isInPeaceZone() || !player.getReflection().isDefault()) // If need check at zone peace or not
{
player.sendPacket(new NpcHtmlMessage(5).setFile("scripts/services/service_peace_zone.htm"));
return;
}
if(ItemFunctions.getItemCount(player, Config.MY_CUSTOM_SERVICE_ITEM) < Config.MY_CUSTOM_SERVICE_PRICE) // Check and take items
{
if(Config.MY_CUSTOM_SERVICE_ITEM == ItemTemplate.ITEM_ID_ADENA)
player.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
else
player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
return;
}
ItemFunctions.removeItem(player, Config.MY_CUSTOM_SERVICE_ITEM, Config.MY_CUSTOM_SERVICE_PRICE, true);
// HERE IS make any own code and change status or any else
player.sendMessage(new CustomMessage("my_custom_functions send Bla bla bla", player));
player.setHairColor(0);
player.setHairStyle(0);
player.setFace(0);
player.setBlaBlaBla(100500);
}
}