Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Client saving settings between accounts?


    detrs

    Recommended Posts

    I've only been coding for a week or two now, so I'm really new to all of it in general and lacking in terminology, so sorry. I've been having a few problems with accounts saving / carrying over settings and pretty much everything in general like booleans and any variables. I tried to put some of it in an onStart and it partially fixed it. I have Imp Catcher and Witch's Potion completed and I was trying to get it to save each step I was on, which worked, but when I go to swap accounts it uses the last account. Until I close the client and sometimes just stop and start the script again will fix it. Is there a good way to handle dealing with this?

     

    This is just a little snippet of what I was trying to do with just the saving part / loading part in particular. I had it in the main class that accountName = Players.getLocal()

    public static final int QUEST_ID_IMP_CATCHER = 1;
    public static final int QUEST_ID_WITCHS_POTION = 2;

    public static void saveQuestStage(String accountName, int questId, int questStage) {
    String fileName = accountName + "_Quest" + questId + ".dat";
    try (ObjectOutputStream oos = new ObjectOutputStream(Files.newOutputStream(Paths.get(fileName)))) {
    oos.writeInt(questStage);
    System.out.println("Saved quest stage: " + questStage + " for " + accountName + " - Quest " + questId);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    public static void loadQuestStage(String accountName, int questId, int questStage) {
    String fileName = accountName + "_Quest" + questId + ".dat";
    try (ObjectInputStream ois = new ObjectInputStream(Files.newInputStream(Paths.get(fileName)))) {
    int loadedQuestStage = ois.readInt();
    Macros.questStage = loadedQuestStage;
    System.out.println("Loaded quest stage: " + loadedQuestStage + " for " + accountName + " - Quest " + questId);
    } catch (IOException e) {
    e.printStackTrace();
    Macros.questStage = 0;
    }
    }
    Link to comment
    Share on other sites

    On 2/15/2024 at 3:40 AM, detrs said:

    I've only been coding for a week or two now, so I'm really new to all of it in general and lacking in terminology, so sorry. I've been having a few problems with accounts saving / carrying over settings and pretty much everything in general like booleans and any variables. I tried to put some of it in an onStart and it partially fixed it. I have Imp Catcher and Witch's Potion completed and I was trying to get it to save each step I was on, which worked, but when I go to swap accounts it uses the last account. Until I close the client and sometimes just stop and start the script again will fix it. Is there a good way to handle dealing with this?

     

    This is just a little snippet of what I was trying to do with just the saving part / loading part in particular. I had it in the main class that accountName = Players.getLocal()

    public static final int QUEST_ID_IMP_CATCHER = 1;
    public static final int QUEST_ID_WITCHS_POTION = 2;

    public static void saveQuestStage(String accountName, int questId, int questStage) {
    String fileName = accountName + "_Quest" + questId + ".dat";
    try (ObjectOutputStream oos = new ObjectOutputStream(Files.newOutputStream(Paths.get(fileName)))) {
    oos.writeInt(questStage);
    System.out.println("Saved quest stage: " + questStage + " for " + accountName + " - Quest " + questId);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    public static void loadQuestStage(String accountName, int questId, int questStage) {
    String fileName = accountName + "_Quest" + questId + ".dat";
    try (ObjectInputStream ois = new ObjectInputStream(Files.newInputStream(Paths.get(fileName)))) {
    int loadedQuestStage = ois.readInt();
    Macros.questStage = loadedQuestStage;
    System.out.println("Loaded quest stage: " + loadedQuestStage + " for " + accountName + " - Quest " + questId);
    } catch (IOException e) {
    e.printStackTrace();
    Macros.questStage = 0;
    }
    }

    I think I get what you are trying to achieve, and it's not a bad approach but there are ways you can check to see if you are done with a quest or what stage of the quest you are on.

    For example, if you want to check if a quest is completed or not then check what step the quest is on (there is usually a variable that holds the stage of each quest, in most cases this starts at 0 and say if you give an NPC an item for the quest it usually jumps to 1)

            if(!Quests.isFinished(FreeQuest.WITCHS_POTION)){ // this checks if the quest is finished or not
                int questState = PlayerSettings.getConfig(FreeQuest.WITCHS_POTION.getConfigID()); // this is if the quest state is stored in VarPlayer/Config variables
                int questStateVarBit = PlayerSettings.getBitValue(FreeQuest.WITCHS_POTION.getConfigID()); // this is if the quest state is stored in VarBit variables
                if(questState == 0){
                    log("We need to start the quest!");
                }else if(questState == 1){
                    log("We need to do the first step of this quest!");
                }else if(questState == 2){
                    log("We need to do the second step of this quest!");
                }
            }

     The amount it increases isn't always 1 sometimes its 10, it could be whatever jagex sets for it so you kind of have to search for it.

    Also, sometimes the quest is saved in Config variable and sometimes in Varbit variable. You'll only need to call 1 of these, I just put the two in the example for reference.

    Link to comment
    Share on other sites

    16 hours ago, fallacy87 said:

    I think I get what you are trying to achieve, and it's not a bad approach but there are ways you can check to see if you are done with a quest or what stage of the quest you are on.

    For example, if you want to check if a quest is completed or not then check what step the quest is on (there is usually a variable that holds the stage of each quest, in most cases this starts at 0 and say if you give an NPC an item for the quest it usually jumps to 1)

            if(!Quests.isFinished(FreeQuest.WITCHS_POTION)){ // this checks if the quest is finished or not
                int questState = PlayerSettings.getConfig(FreeQuest.WITCHS_POTION.getConfigID()); // this is if the quest state is stored in VarPlayer/Config variables
                int questStateVarBit = PlayerSettings.getBitValue(FreeQuest.WITCHS_POTION.getConfigID()); // this is if the quest state is stored in VarBit variables
                if(questState == 0){
                    log("We need to start the quest!");
                }else if(questState == 1){
                    log("We need to do the first step of this quest!");
                }else if(questState == 2){
                    log("We need to do the second step of this quest!");
                }
            }

     The amount it increases isn't always 1 sometimes its 10, it could be whatever jagex sets for it so you kind of have to search for it.

    Also, sometimes the quest is saved in Config variable and sometimes in Varbit variable. You'll only need to call 1 of these, I just put the two in the example for reference.

     

     

    public static Enum_Imp_Catcher handleImpCatcherQuestState() {
    if (Macros.questStage == 0) {
    return Enum_Imp_Catcher.Dont_Have_Imp_Items;
    } else if (Macros.questStage == 1) {
    return Enum_Imp_Catcher.Imp_Bank;
    } else if (Macros.questStage == 2) {
    return Enum_Imp_Catcher.Walk_To_Imp_QuestGiver;
    } else if (Macros.questStage == 3) {
    return Enum_Imp_Catcher.Talk_To_Imp_QuestGiver;
    }
    return null;
    }

     

    This is my state machine for imp catcher,. It's obviously not the most complicated quest, but what i'm doing currently is doing a case, and when that case is done it ups the questStage boolean by one with questStage++. So it'll start off at 0, then walk to the grand exhange, set it to 1, bank and buy items and set to 2, walk to the questgiver and set to 3, and then talk to and finish the quest. Which works nice......if it's a one and done straight through. but if it gets to the questgiver....and the script stops for whatever reason. It will then walk allllll the way back to the GE and start over. I would need to retailor my state machine to incorporate configs, but that should be a better way to  "save / check" progress? Or just use it in addition to what I have?

    Link to comment
    Share on other sites

    4 hours ago, detrs said:

     

     

    public static Enum_Imp_Catcher handleImpCatcherQuestState() {
    if (Macros.questStage == 0) {
    return Enum_Imp_Catcher.Dont_Have_Imp_Items;
    } else if (Macros.questStage == 1) {
    return Enum_Imp_Catcher.Imp_Bank;
    } else if (Macros.questStage == 2) {
    return Enum_Imp_Catcher.Walk_To_Imp_QuestGiver;
    } else if (Macros.questStage == 3) {
    return Enum_Imp_Catcher.Talk_To_Imp_QuestGiver;
    }
    return null;
    }

     

    This is my state machine for imp catcher,. It's obviously not the most complicated quest, but what i'm doing currently is doing a case, and when that case is done it ups the questStage boolean by one with questStage++. So it'll start off at 0, then walk to the grand exhange, set it to 1, bank and buy items and set to 2, walk to the questgiver and set to 3, and then talk to and finish the quest. Which works nice......if it's a one and done straight through. but if it gets to the questgiver....and the script stops for whatever reason. It will then walk allllll the way back to the GE and start over. I would need to retailor my state machine to incorporate configs, but that should be a better way to  "save / check" progress? Or just use it in addition to what I have?

    I think checking the in game variables is best. Think if you had someone run a dragonslayer quest but already had completed the map piece. Relying only on data that you saved would result in that user going to the GE and buying the items for the door and setting up combat for the maze and then possibly using the items at the door trying to open it. Here it would be best to detect the map piece in some way and jump the questState to 12 to go and give the map to Ned.

    That being said, I think you just need to have some sort of "Indicator" that can pinpoint exactly what questStage you are on, using in game variables as much as possible then go off other stuff like if you have an item in your inventory that you had to collect etc... But this also has issues with it, say you are on questState 0 for imp catcher and you require it having all the beads and a Necklace of passage(5) in your inventory before going to the wizard. You buy the items and questState now equals 1 and it teleports to the tower, however, the necklace of passage(5) becomes necklace of passage(4) and the questState is reverted back to 0 because it doesn't detect all the items in your inventory, resulting in going back to the GE to buy another necklace (maybe something like this is going on with your current code?).

     

    Link to comment
    Share on other sites

    12 hours ago, fallacy87 said:

    I think checking the in game variables is best. Think if you had someone run a dragonslayer quest but already had completed the map piece. Relying only on data that you saved would result in that user going to the GE and buying the items for the door and setting up combat for the maze and then possibly using the items at the door trying to open it. Here it would be best to detect the map piece in some way and jump the questState to 12 to go and give the map to Ned.

    That being said, I think you just need to have some sort of "Indicator" that can pinpoint exactly what questStage you are on, using in game variables as much as possible then go off other stuff like if you have an item in your inventory that you had to collect etc... But this also has issues with it, say you are on questState 0 for imp catcher and you require it having all the beads and a Necklace of passage(5) in your inventory before going to the wizard. You buy the items and questState now equals 1 and it teleports to the tower, however, the necklace of passage(5) becomes necklace of passage(4) and the questState is reverted back to 0 because it doesn't detect all the items in your inventory, resulting in going back to the GE to buy another necklace (maybe something like this is going on with your current code?).

     

    That's funny because that's exactly what I had in the first iteration. My logic stated pretty much all of that and I found it to be just too much, and it was like if you dont have all these items, and you have either necklacklace 5,4,3,2, or 1, and you havent blah blah. It just got to be too much. Using the quest stages fixed that, but ran into the problem of not being able to pick up where it left off. I've been messing around with what you said, and I see how I could make it do a little of both of what I was trying to do with configs. Definitely was very helpful!

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.