Search the Community
Showing results for tags 'api'.
-
GitHub https://github.com/Tomhoogstra/OSTracker If you found this repository useful, please consider giving it a star! About In late 2019, OSTracker 1.0 was released which was a client-server implementation that strived to collect user data for scripters with ease. There were a few problems with this type of implementation, and most of them were performance related and mostly poor ways of communication between the client and the database. Today I am happy to release OSTracker 2.0, which transitions from this Client-Server approach to a RESTful API which allows for much easier and less intensive data submission and tracking. OSTracker 2.0 API is built on Laravel, a PHP framework that specialises in the development of web applications. Tracked Data (per user) Experience gained for all skills Items Received, Lost, or Spent (e.g. arrows and runes) Time ran Error logs (if setup) Upcoming Data retrieval end points that will allow you to filter certain users, scripts, skills, items, and more. Client-side installation Integration with your OSBot script is relatively simple. Simply copy the contents of the 'client' directory in this repo into your scripts code base. In your scripts onStart, you should initialise OSTracker like so. private Tracker tracker; @Override public void onStart(){ try { tracker = new Tracker(getBot(), getName(), "BASE_API_URL", "YOUR_TOKEN") .setUpdateInterval(30) // Defaults to an hour .start(); tracker.getSessionTracker().setVersion(getVersion()); } catch (Exception e) { if (tracker != null) { tracker.stop(); } e.printStackTrace(); } } And end the tracker in your scripts onExit like so @Override public void onExit(){ if(tracker != null){ tracker.stop(); } } Your token will be created when deploying the Laravel API to your server, or it will be provided to you if you are choosing to integrate with somebody else's API. From here, OSTracker will automatically handle experience, loot, and script runtime tracking, and by default will submit this data to the API once per hour. Data will also be submitted when the script is stopped. API installation Don't fancy setting all this up? I can host your data for you for $3 USD per month. Post-installation instructions / API endpoints
-
Bob Ross would be so proud! Example code: import java.awt.Color; import java.awt.Graphics2D; import java.util.List; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import com.liverare.api.PaintAPI; @ScriptManifest(author = "", info = "", logo = "", name = "Test", version = 0) public class Test extends Script { PaintAPI paint; Area safeSpace; List<NPC> guards; @Override public void onStart() throws InterruptedException { paint = new PaintAPI(); paint.exchangeContext(bot); safeSpace = myPlayer().getArea(5); } @Override public int onLoop() throws InterruptedException { guards = npcs.filter(Test::isGuard); return 100; } private static boolean isGuard(NPC npc) { return npc.getName().equals("Guard"); } @Override public void onPaint(Graphics2D g) { g.setColor(Color.BLACK); g.setBackground(Color.PINK); // dont worry bout checks fam, i do dat paint.drawMinimapArea(g, safeSpace); paint.drawEntities(g, guards, Test::guardToString, true, false, false, false, false, false, true); } private static String guardToString(NPC npc) { return "Health: " + npc.getHealthPercent() + ", xyz: " + npc.getPosition().toString(); } } Functions: public void drawLink(Graphics2D g, Entity entity1, Entity entity2) public void drawMinimapArea(Graphics2D g, org.osbot.rs07.api.map.Area area) public <T extends Position> void drawString(Graphics2D g, Function<T, String> toString, T position) public void drawString(Graphics2D g, String aString, Position position) public void drawString(Graphics2D g, String aString, Entity entity) public void drawEntity(Graphics2D g, Entity entity, String aString, boolean labelTile, boolean click, boolean cube, boolean minimap, boolean tile, boolean box, boolean wireframe) public void drawEntity(Graphics2D g, Entity entity, Function<T, String> getDescription, boolean labelTile, boolean click, boolean cube, boolean minimap, boolean tile, boolean box, boolean wireframe) public <T extends Entity> void drawEntities(Graphics2D g, Collection<T> entities, Function<T, String> getDescription, boolean labelTile, boolean click, boolean cube, boolean minimap, boolean tile, boolean tileCube, boolean wireframe) private void drawBox(Graphics2D g, Entity entity) private void drawBox(Graphics2D g, Position bottomTile, Position topTile) private void drawWireframe(Graphics2D g, Entity entity) private void drawClickBounds(Graphics2D g, Entity entity) private void drawCube(Graphics2D g, Entity entity) public void drawMinimapPoint(Graphics2D g, Vector3D v) public void drawMinimapLink(Graphics2D g, Vector3D a, Vector3D b) public void drawTile(Graphics2D g, Entity entity) public void drawTile(Graphics2D g, Position position) public static void drawPoint(Graphics2D g, Point point, int size) public static void drawPoint(Graphics2D g, int x, int y, int size) public static void drawShape(Graphics2D g, Shape shape) public static void drawString(Graphics2D g, String aString, int x, int y) public static void drawString(Graphics2D g, String aString, Point point) public static void drawString(Graphics2D g, String aString, Rectangle rectangle) Source:
- 25 replies
-
- 11
-
Let's work to make Wilderness bots great again! Example code: import java.util.List; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import com.liverare.api.WildernessAPI; @ScriptManifest(author = "", info = "", logo = "", name = "Test", version = 0) public class Test extends Script { WildernessAPI wilderness; @Override public void onStart() throws InterruptedException { wilderness = new WildernessAPI(); wilderness.exchangeContext(bot); } @Override public int onLoop() throws InterruptedException { Player workerBot = players.closest("W0rk3r B0t 5001"); handleRealThreats(); handlePotentialThreats(); saveWorkerBot(workerBot); return 100; } private void handleRealThreats() { List<Player> realThreats = wilderness.findRealThreats(); if (realThreats != null && !realThreats.isEmpty()) { // oh shit they can attack us // better check what they're wearing and what they're doing } } private void handlePotentialThreats() { List<Player> potentialThreats = wilderness.findPotentialThreats(); if (potentialThreats != null && !potentialThreats.isEmpty()) { // oh dear, we may be in trouble // we'd better not go deeper into the Wilderness, they may be // waiting for us to do exactly that! } } private void saveWorkerBot(Player workerBot) { List<Player> realThreatsToWorkerBot = wilderness.findRealThreats(workerBot); if (realThreatsToWorkerBot != null && !realThreatsToWorkerBot.isEmpty()) { // worker bot may be in trouble // perhaps we should attack baddie? lure them away? etc. } } } Methods: public int getSafeWildernessLevel(Player player) public int getSafeWildernessLevel(Player playerA, Player playerB) public List<Player> findPotentialThreats() public List<Player> findPotentialThreats(Player victim) public List<Player> findRealThreats() public List<Player> findRealThreats(Player victim) public static boolean canPlayerAFighterPlayerB(Player playerA, Player playerB) public static int calculateYCoordinate(Vector3D vector3d, boolean upperBound) public static int calculateYCoordinate(int wildernessLevel, boolean upperBound) public static int calculateWildernessLevel(Vector3D vector3d) public static int calculateWildernessLevel(int yCoordinate) Source:
- 7 replies
-
- 7
-
- wilderness api
- wilderness
-
(and 1 more)
Tagged with:
-
So you want to files, huh? M'kay. Example code: import java.io.IOException; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "", info = "", logo = "", name = "Chicken Killer", version = 0) public class ChickenKiller extends Script { OSBotFileAPI osbotFile; String profile; @Override public void onStart() throws InterruptedException { initialiseCustomAPIs(); iWantToOpenAFile(); iWantToSaveStuffToAFile("Hello world!"); } private void initialiseCustomAPIs() { osbotFile = new OSBotFileAPI(); osbotFile.exchangeContext(bot); osbotFile.initializeModule(); } private void iWantToOpenAFile() { try { profile = osbotFile.open(); logger.debug(profile); } catch (RuntimeException | IOException e) { logger.error(e); } } private void iWantToSaveStuffToAFile(String stuff) { try { osbotFile.save("Hello world!"); } catch (RuntimeException | IOException e) { logger.error(e); } } @Override public int onLoop() throws InterruptedException { return 250; } } Testing: Folder is automatically created if it doesn't exist: I manually created a text file for testing and added it into the script data folder: I re-ran the script so that I could now select something: And then the script did a little save testing with the same file: Functions: public boolean folderExists() protected synchronized String readFromFile(File file) throws FileNotFoundException, IOException public synchronized String readFromFile(String filename) throws FileNotFoundException, IOException protected synchronized void writeToFile(File file, String fileContent) throws IOException public synchronized void writeToFile(String filename, String fileContent) throws IOException public synchronized String open(FileFilter fileFilter) throws RuntimeException, FileNotFoundException, IOException public synchronized String open() throws RuntimeException, FileNotFoundException, IOException public synchronized void save(FileFilter fileFilter, String fileContent) throws IOException public synchronized void save(String fileContent) throws IOException public synchronized boolean deleteFile(String filename) Source:
-
Mirror client version 2.4.144 Console output / terminal output Nothing Crash report if a crash occurred No crash, just bot like behaviour Script that you ran my own Hooks that failed none JVM/Browser bit version (32 / 64) Code used: for (Item item : api.store.getItems()) { for (Rune rune : runesToBuy) { if (item.getId() == rune.getRuneId()) { int amount = api.store.getAmount(item.getId()); if (amount > 0) { api.store.buy(item.getName(), amount); } } } } Behaviour: Mouse will move to empty spot, or won't move at all. It will buy a few runes from the first type. than it stops working.. Location: Shop from Ali Morrisane's in Al kharid EDIT: GIF: https://i.imgur.com/gCccjeo.gif EDIT 2: I'm currently using widgets, and it works great too. But I would still very much like the store api to get fixed. (Or am I doing something wrong here?)
-
I blinked, then.. Version 2 Example code: public class Test extends Script { AmountAPI amount; RS2Widget vambracesButton; RS2Widget chapsButton; RS2Widget bodyButton; RS2Widget superCombatButton; @Override public void onStart() throws InterruptedException { amount = new AmountAPI(); amount.exchangeContext(bot); amount.initializeModule(); } @Override public int onLoop() throws InterruptedException { if (amount.isValid()) { vambracesButton = amount.getButton("Green d'hide vamb"); chapsButton = amount.getButton("Green d'hide chaps"); bodyButton = amount.getButton("Green d'hide body"); superCombatButton = amount.getButton("Super combat potion(4)"); } else { // open the interface... } return 250; } } Functions: public Map<ItemDefinition, RS2Widget> getItemButtons() public RS2Widget getButton(int... itemIds) public RS2Widget getButton(int itemId) public RS2Widget getButton(String... itemNames) public RS2Widget getButton(String itemName) public RS2Widget getButton(Predicate<ItemDefinition> itemDefinitionFilter) public RS2Widget getButton(ItemDefinition itemDefinition) public boolean isVisible() public boolean isValid() private Map<ItemDefinition, RS2Widget> findItemButtons() private boolean isRootOf(RS2Widget widget) private RS2Widget findAmountWidget() private static ItemDefinition getItem(RS2Widget parent) private static int getItemId(RS2Widget parent) private static RS2Widget getItemIdWidget(RS2Widget parent) private static boolean isItemIdValid(RS2Widget child) private static boolean isWidgetMakeAction(RS2Widget child) Source: V1 Source
- 4 replies
-
- 4
-
- amount widget
- amount widget api
-
(and 3 more)
Tagged with:
-
Find people wearing stuff. Note: doesn't work with ammo and rings. Example code: import java.util.List; import org.osbot.rs07.api.def.ItemDefinition; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import com.liverare.api.AppearanceAPI; @ScriptManifest(author = "", info = "", logo = "", name = "Test", version = 0) public class Test extends Script { AppearanceAPI appearance; @Override public void onStart() throws InterruptedException { appearance = new AppearanceAPI(); appearance.exchangeContext(bot); } @Override public int onLoop() throws InterruptedException { pesterRichPeopleForFreeStuff(); return 100; } private void pesterRichPeopleForFreeStuff() { List<Player> richPeople = appearance.findPlayersWielding(Test::isExpensiveItem); if (richPeople != null && !richPeople.isEmpty()) { // rich people spotted! // prepare for pestering // in 3... } } private static boolean isExpensiveItem(ItemDefinition itemDefinition) { String itemName = itemDefinition.getName(); return itemName.equals("Twisted bow") || itemName.equals("3rd age longsword") || itemName.equals("3rd age pickaxe") || itemName.equals("3rd age axe") || itemName.equals("3rd age cloak") || itemName.equals("Elysian spirit shield") || itemName.equals("3rd age bow"); } } Methods: public List<Player> findPlayersWielding(List<Player> players, Predicate<ItemDefinition> itemDefinitionFilter) public List<Player> findPlayersWielding(Predicate<ItemDefinition> itemDefinitionFilter) public Player findPlayerWielding(List<Player> players, Predicate<ItemDefinition> itemDefinitionFilter) public Player findPlayerWielding(Predicate<ItemDefinition> itemDefinitionFilter) public static boolean isDefined(Player player, Predicate<ItemDefinition> itemDefinitionFilter) private static boolean isDefined(int[] appearance, Predicate<ItemDefinition> itemDefinitionFilter) Source:
- 3 replies
-
- 8
-
- appearance api
- appearance
-
(and 1 more)
Tagged with:
-
I haven't looked much at the OSBot API itself but is there a way to pull all SDN script names and sdnid's? I'm creating an automated bot farm and I think it'll be usefull for to have those names and ID's in a table in my DB. Is this possible? If so where should I look? Also wasn't sure if I should post this in script development section or software development since my aims overlap.