October 13, 201510 yr Does someone have this to check if your bot is in a clan and if not it will join a clan.
October 13, 201510 yr open clan chat tabif widget (589,0) is visible and text contains "Not in chat" then click join chat and enter chat nameelse we're in a chat
October 13, 201510 yr I made a little class that will hopefully deal with this ( not properly tested ) import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import java.util.Random; public class ClanChatter{ private Script script; public ClanChatter(Script script){ this.script = script; } public boolean notInClanChat(){ RS2Widget notInChat = script.getWidgets().getWidgetContainingText("Not in chat"); return (notInChat != null && notInChat.isVisible()); } public void openClanChatTab(){ script.getTabs().open(Tab.CLANCHAT); } public boolean isClanChatTabOpen(){ return Tab.CLANCHAT.isOpen(script.getBot()); } public boolean isInClanChat(){ RS2Widget talkingIn = script.getWidgets().getWidgetContainingText("Talking in:"); return (talkingIn != null && talkingIn.isVisible() && !talkingIn.getMessage().contains("Not in chat")); } public void joinClanChat(String name){ //RS2Widget enterName = getWidgets().getWidgetContainingText("Enter the player name whose channel you wish to join:"); RS2Widget enterName = script.getWidgets().get(162, 32); RS2Widget joinChat = script.getWidgets().getWidgetContainingText("Join Chat"); if (enterName != null && enterName.isVisible()){ script.getKeyboard().typeString(name); sleep(4000, 5000); } else if (joinChat != null && joinChat.isVisible()) clickOnWidget(joinChat); } public void leaveClanChat(){ RS2Widget leaveWidget = script.getWidgets().getWidgetContainingText("Leave Chat"); if (leaveWidget != null && leaveWidget.isVisible()) clickOnWidget(leaveWidget); } public boolean isInClan(String name){ RS2Widget talkingIn = script.getWidgets().getWidgetContainingText("Talking in:"); return talkingIn.getMessage().contains(name); } public boolean isOwner(String name){ RS2Widget owner = script.getWidgets().getWidgetContainingText("Owner:"); return owner.getMessage().contains(name); } public void talkInClanChat(String output){ script.getKeyboard().typeString(String.format("/%s", output)); sleep(1500, 2000); } private void clickOnWidget(RS2Widget widget){ widget.hover(); script.getMouse().click(false); sleep(1500, 2000); } private void sleep(int min, int max){ try{ script.sleep(new Random().nextInt(max-min) + min); } catch(Exception e){ script.log(e); } } } Edited October 13, 201510 yr by Explv
Create an account or sign in to comment