I've been running into a problem where I want to try and use a interface to open up shops. Except I want to use the interface to display multiple shops.. If that makes sense. I'll give you an example of what I'm trying to do if it doesn't.
- Player clicks on an object to open the interface with 10 shops listed
- Player clicks on a different object to open the same interface with 10 different shops listed
I think the issue is that I need a way to differ the interface I want at that time in ButtonHandler. To click a button in the interface it points to ButtonHandler.
How would I make it click the buttons within just the local interface.java file, without pointing to ButtonHandler first?
Here is the code for the shop java file:
Code:
package com.rs.game.player.content.interfaces.stores;
import com.rs.game.player.Player;
import com.rs.utils.ShopsHandler;
public class MeleeWeapons {
public static int InterfaceID = 72;
public static void sendInterface(Player player) {
player.getInterfaceManager().sendInterface(InterfaceID);
player.getPackets().sendIComponentText(InterfaceID, 55, "Pick a shop");
player.getPackets().sendIComponentText(InterfaceID, 31, "Daggers");
player.getPackets().sendIComponentText(InterfaceID, 32, "Swords");
player.getPackets().sendIComponentText(InterfaceID, 33, "Longswords");
player.getPackets().sendIComponentText(InterfaceID, 34, "Spears");
player.getPackets().sendIComponentText(InterfaceID, 35, "Hasta");
player.getPackets().sendIComponentText(InterfaceID, 36, "Two-Handed");
player.getPackets().sendIComponentText(InterfaceID, 37, "Claws");
player.getPackets().sendIComponentText(InterfaceID, 38, "Battleaxes");
player.getPackets().sendIComponentText(InterfaceID, 39, "Maces");
player.getPackets().sendIComponentText(InterfaceID, 40, "Warhammer");
}
public static void handleButtons(Player player, int componentId) {
int DaggerShop = 1;
int SwordShop = 81;
int LongswordShop = 82;
int SpearShop = 83;
int HastaShop = 84;
int TwoHShop = 108;
int ClawShop = 114;
int BattleaxeShop = 115;
int MaceShop = 116;
int WarhammerShop = 117;
if (componentId == 68) {
ShopsHandler.openShop(player, DaggerShop);
return;
}
if (componentId == 67) {
ShopsHandler.openShop(player, SwordShop);
return;
}
if (componentId == 66) {
ShopsHandler.openShop(player, LongswordShop);
return;
}
if (componentId == 65) {
ShopsHandler.openShop(player, SpearShop);
return;
}
if (componentId == 64) {
ShopsHandler.openShop(player, HastaShop);
return;
}
if (componentId == 73) {
ShopsHandler.openShop(player, TwoHShop);
return;
}
if (componentId == 72) {
ShopsHandler.openShop(player, ClawShop);
return;
}
if (componentId == 71) {
ShopsHandler.openShop(player, BattleaxeShop);
return;
}
if (componentId == 70) {
ShopsHandler.openShop(player, MaceShop);
return;
}
if (componentId == 69) {
ShopsHandler.openShop(player, WarhammerShop);
}
}
}
Here is what I have to put in ButtonHandler for it to even recognize that I have a button to be clicked:
Code:
if (interfaceId == 72) {
MeleeWeapons.handleButtons(player, componentId);
}
Thank you for reading in advance ^.^