sudoinit6 Posted February 2, 2018 Share Posted February 2, 2018 (edited) I am trying to set up: if (ResponseCode.isDisabledError(18) || ResponseCode.isDisabledError(4)){ do stuff } And it works, but too well. It does stuff on any kind of failure. Is there a way to make it only do stuff with these errors and do other stuff with any other error? Edited February 2, 2018 by sudoinit6 Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 2, 2018 Share Posted February 2, 2018 if(ResponseCode.isDisabledError(ResponseCode.ACCOUNT_DISABLED)) { } else { } Not sure what 4 or 18 represent but, this method should only be used in conjunction with "ACCOUNT_DISABLED" (-1)? Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted February 2, 2018 Author Share Posted February 2, 2018 4 minutes ago, dreameo said: if(ResponseCode.isDisabledError(ResponseCode.ACCOUNT_DISABLED)) { } else { } Not sure what 4 or 18 represent but, this method should only be used in conjunction with "ACCOUNT_DISABLED" (-1)? 4 and 18 are locked or banned respectively. I will try your way and see if it works. Thanks. Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 2, 2018 Share Posted February 2, 2018 1 minute ago, sudoinit6 said: 4 and 18 are locked or banned respectively. I will try your way and see if it works. Thanks. Oh ok. I just looked at the API and that's all i found for codes lol. Quote Link to comment Share on other sites More sharing options...
Chris Posted February 2, 2018 Share Posted February 2, 2018 1 = Unexepected server responce please try using a different world. 2 = login to the game 3 = Invalid name/password 4 = banned username 5 = Account is already logged in try agian in 60 secs... 6 = Runescape has been updated! Please reload this page. 7 = This world is full. Please use a different world. 8 = Unable to connect. login server offline. 9 = Login limit exceeded. Too many connections from you address. 10 = Unable to connect. Bad session id. 11 = We suspect someone knows your password. Press 'change your password' on the front page. 12 = You need a members account to login to this world. Please subscribe, or use a different world. 13 = Could not complete login. Please try using a different world. 14 = The server is being updated. Please wait 1 minute and try again. 15 = Another server responce please try agian 16 = Too many incorrect longs from your address. Please wait 5 minutes before trying again. 17 = You are standing in a members-only area. To play on this world move to a free area first. 18 = Account locked as we suspect it has been stolen. Press 'recover a locked account' on front page. 19 = This world is running a closed beta. sorry invited players only. please use a different world. 20 = Invalid loginserver requested please try using a different world. 21 = You have only just left another world. your profile will be transferred in 4seconds. 22 = Malformed login packet. Please try agian. 23 = No reply from loginserver. Please wait 1minute and try again. 24 = Error loading your profile. please contact customer support. 25 = Unexepected loginserver response 26 = This computers address has been blocked as it was used to break our rules. 27 = Service unavailable. 2 Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 2, 2018 Share Posted February 2, 2018 16 minutes ago, Chris said: 1 = Unexepected server responce please try using a different world. 2 = login to the game 3 = Invalid name/password 4 = banned username 5 = Account is already logged in try agian in 60 secs... 6 = Runescape has been updated! Please reload this page. 7 = This world is full. Please use a different world. 8 = Unable to connect. login server offline. 9 = Login limit exceeded. Too many connections from you address. 10 = Unable to connect. Bad session id. 11 = We suspect someone knows your password. Press 'change your password' on the front page. 12 = You need a members account to login to this world. Please subscribe, or use a different world. 13 = Could not complete login. Please try using a different world. 14 = The server is being updated. Please wait 1 minute and try again. 15 = Another server responce please try agian 16 = Too many incorrect longs from your address. Please wait 5 minutes before trying again. 17 = You are standing in a members-only area. To play on this world move to a free area first. 18 = Account locked as we suspect it has been stolen. Press 'recover a locked account' on front page. 19 = This world is running a closed beta. sorry invited players only. please use a different world. 20 = Invalid loginserver requested please try using a different world. 21 = You have only just left another world. your profile will be transferred in 4seconds. 22 = Malformed login packet. Please try agian. 23 = No reply from loginserver. Please wait 1minute and try again. 24 = Error loading your profile. please contact customer support. 25 = Unexepected loginserver response 26 = This computers address has been blocked as it was used to break our rules. 27 = Service unavailable. Where you get dat from? Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted February 2, 2018 Author Share Posted February 2, 2018 It's in a post on this forum, search for Response Codes. It would be really cool if I could do different stuff depending on the code, but I haven't figured out how to make that work yet. Quote Link to comment Share on other sites More sharing options...
Chris Posted February 2, 2018 Share Posted February 2, 2018 2 minutes ago, sudoinit6 said: It's in a post on this forum, search for Response Codes. It would be really cool if I could do different stuff depending on the code, but I haven't figured out how to make that work yet. https://osbot.org/api/org/osbot/rs07/listener/LoginResponseCodeListener.html#onResponseCode-int- Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted February 2, 2018 Author Share Posted February 2, 2018 14 hours ago, Chris said: https://osbot.org/api/org/osbot/rs07/listener/LoginResponseCodeListener.html#onResponseCode-int- I am aware of that, but if you look in my first post on any response code it does stuff, regardless of which code is returned, what I would like to do is have it do different stuff for different codes. It could be that it is possible, I'm just not using it properly. I don't really know what I am doing. Quote Link to comment Share on other sites More sharing options...
Alek Posted February 2, 2018 Share Posted February 2, 2018 Response codes are only sent when you login, you will need to override autologin event. Quote Link to comment Share on other sites More sharing options...
Lemons Posted February 2, 2018 Share Posted February 2, 2018 Not sure if I'm misunderstanding or not, but you need to make a response code listener to use them. You seem to just be compared them against a static integer. Sorry if I misunderstood. getBot().addLoginListener(new LoginResponseCodeListener() { @Override public void onResponseCode(int responseCode) throws InterruptedException { if (ResponseCode.isDisabledError(responseCode)) { // Disabled or locked } else if (ResponseCode.isConnectionError(responseCode)) { // Connection error, if custom login handler sleep or w/e } } }); Also, response codes can be returned on DC, such as when locked/banned. 1 Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted February 2, 2018 Author Share Posted February 2, 2018 (edited) 58 minutes ago, Lemons said: Not sure if I'm misunderstanding or not, but you need to make a response code listener to use them. You seem to just be compared them against a static integer. Sorry if I misunderstood. getBot().addLoginListener(new LoginResponseCodeListener() { @Override public void onResponseCode(int responseCode) throws InterruptedException { if (ResponseCode.isDisabledError(responseCode)) { // Disabled or locked } else if (ResponseCode.isConnectionError(responseCode)) { // Connection error, if custom login handler sleep or w/e } } }); Also, response codes can be returned on DC, such as when locked/banned. I thank you for your help, I don't think you are misunderstanding, I wish I were better at explaining myself but I am learning. Bear with me because I am sure this will be amateur hour for you, I am almost embarrassed to explain how my stuff works but it is the best I can do with my current level of knowledge. Currently I run each bot on it's own Linux VM(I know more about linux and VMware than I do java). My scripts are task based and in the class that extends Script (where all the tasks are listed) I have the code I originally posted. The "do suff" stuff is this: If the response code is disabled: Write a file to /root/OSBot/Data/ I have a cron job that looks in that folder for that specific file every five minutes, if it exists delete the file and start creating a new account and launch osBot all over again. The only problem is it "does stuff" on any failure to connect. So if I get a random fail to connect for some reason I lose hours on that bot. Like I said, noob but it works. Are you saying if I put your code in my class that extends Script I could have it write one file on disabled or locked or write a different file on connection error? If so that would suit my need perfectly because I could have my cron job restart the whole thing on disable/lock or just kill java and launch the bot again on connection error. Edited February 2, 2018 by sudoinit6 Quote Link to comment Share on other sites More sharing options...
Lemons Posted February 2, 2018 Share Posted February 2, 2018 (edited) 19 minutes ago, sudoinit6 said: Yes, the "Disabled or locked" statement will triggered on account disable, so you could just touch the file you need in that statement. I think your issue before was misunderstanding how ResponseCode.isDisabledError(int) works. LoginResponseCodeListener should work with osbots login handler for this situation. Just make sure you add the listener in the scripts onStart and all should be good. Also, connection errors could be for a multitude of reasons, look at @Chris's post to handle specific values (just compare responseCode to the # of the error for those). Edited February 2, 2018 by Lemons Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted February 2, 2018 Author Share Posted February 2, 2018 8 minutes ago, Lemons said: Yes, the "Disabled or locked" statement will triggered on account disable, so you could just touch the file you need in that statement. I think your issue before was misunderstanding how ResponseCode.isDisabledError(int) works. LoginResponseCodeListener should work with osbots login handler for this situation. Just make sure you add the listener in the scripts onStart and all should be good. Also, connection errors could be for a multitude of reasons, look at @Chris's post to handle specific values (just compare responseCode to the # of the error for those). I thank you for your response and your effort to educate me. You are probably correct, I don't understand how ResponseCode.isDisabledError(int) works. But let's see if I can learn! Here is the entirety of the code I have been using: @Override public void onResponseCode(int responseCode) throws InterruptedException { if (ResponseCode.isDisabledError(18) || ResponseCode.isDisabledError(4) ) { log("Account locked"); try { log("trying to create text file."); PrintWriter writer = new PrintWriter( "/root/OSBot/Data/lockedAccounts.txt", "UTF-8"); writer.println("locked"); writer.close(); } catch (IOException e) { log("creating text file failed"); // TODO Auto-generated catch block e.printStackTrace(); System.exit(0); } System.exit(0); } In my mind what I THOUGHT would happen would be that this code would be executed only if the login response code matched one of the two in the or statement. But it executes on ANY failure to login if you could explain to me why that is I would be grateful. And if I am understanding correctly, if I remove the above (it is in my onLoop sectin) and put this in my onStart: getBot().addLoginListener(new LoginResponseCodeListener() { @Override public void onResponseCode(int responseCode) throws InterruptedException { if (ResponseCode.isDisabledError(responseCode)) { // Disabled or locked My clunky code that writes file a } else if (ResponseCode.isConnectionError(responseCode)) { // Connection error, if custom login handler sleep or w/e My clunky code that writes file b } } }); Then I don't care what the individual response codes are because if it's disabled I start fresh and if it's anything else I wait 5 min and try to launch the bot again, correct? Once again I really appreciate the help, I have been hanging around here for a year and a half and this community has always been top notch. Quote Link to comment Share on other sites More sharing options...
Lemons Posted February 2, 2018 Share Posted February 2, 2018 the issue here is this: if (ResponseCode.isDisabledError(18) || ResponseCode.isDisabledError(4) ) { is basically equivalent to this: if ((4 == 4 || 4 == 18) && (18 == 4 || 18 == 18)) { Because ResponseCode.isDisabledError is (most likely) just: public static boolean isDisabledError(int responseCode) { return responseCode == ResponseCode.DISABLED_ACCOUNT || responseCode == 18; } So your mistake is thinking ResponseCode.isDisabledError knows the response code. It does not, it only checks the given response code (and your always giving 4 and 18, so its always true on any response code). Simple misunderstanding, those have bit all of us in the ass at some point. As for individual response codes, just allows you to fine tune responses to different types of connection issues. If you use them or not, that is up to you. 1 Quote Link to comment Share on other sites More sharing options...