RDM Posted October 25, 2014 Share Posted October 25, 2014 Trying to make a script that buys from an npc and not sure how to get the clause right. I know how to steal from a stall(below), how would i change it to get it into trading and buying from an npc? private State getState() { Entity stall = object.closest("Tea Stall") if (!inventory.isEmpty()) return State.DROP; if (stall != null) return State.STEAL; return State.WAIT; } Also how would i make it ao when the script as finished opening feather packs that it wont drop the gold stack? What I have so far... private State getState() { Entity npc = object.closest("NPC NAME") Not even sure if this is right lol. private enum State { TRADE, OPEN }; Thank you Link to comment Share on other sites More sharing options...
The Hero of Time Posted October 25, 2014 Share Posted October 25, 2014 Just saying, its a statement, where / insert / database things are called clauses, if is a statement Link to comment Share on other sites More sharing options...
Alek Posted October 25, 2014 Share Posted October 25, 2014 Logic is a fundamental part of programming, it really can't be taught. Just add more checks and if statements before actually returning steal or drop. Pseudo code example: boolean shouldTrade = false; if(!shouldTrade){ if(!inventory.isFull(){ return State.Steal; } else { return State.Drop } } else { return State.Trade; } Link to comment Share on other sites More sharing options...
Czar Posted October 25, 2014 Share Posted October 25, 2014 (edited) if (p.getInterfaces().get(300).isValid() && p.getInterfaces().get(300).isVisible()) { // store is open if (p.getStore().contains(1337)) { if (p.getStore().buy("czar", 1)) { return 1000; } } } else { Entity shopkeeper = p.npcs.closest("Shopkeeper"); if (shopkeeper != null) { if (shopkeeper.interact("Trade")) { return 1000; } } } That's for buying something from shop, As for the 'dropping gold', check if inventory is full, not if inventory isn't empty !getInventory().isEmpty() -->>> getInventory().isFull() PM me if you need more help Edited October 25, 2014 by Czar Link to comment Share on other sites More sharing options...