TheScrub Posted August 8, 2013 Share Posted August 8, 2013 (edited) just something i wrote This will be able to return the id of the item name inside your bank With this snippet you will need to check if the bank is open With this snippet you must keep the anotation Wrote more around the core so it will return an int public int bankItemIdByName(String Item_Name){ Item items[] = client.getBank().getItems(); int item_id = 0; for (Item single_item : items) { if (single_item.getName().equals(Item_Name)) { item_id = single_item.getId(); return item_id; } } return item_id; } /* * This will return the id of the item by name * This was written by "TheScrub" * John of * Adelaide South Australia */ /*Example use of the method provided above*/ client.getBank().withdraw1(bankItemIdByName("Salmon")); Edited August 12, 2013 by TheScrub 1 Link to comment Share on other sites More sharing options...
Mr Asshole Posted August 9, 2013 Share Posted August 9, 2013 Lol. I kind of laughed at the credits at the end. Link to comment Share on other sites More sharing options...
Jordan Posted August 9, 2013 Share Posted August 9, 2013 Might be helpful for me later on. Thanks for this. Link to comment Share on other sites More sharing options...
TheScrub Posted August 9, 2013 Author Share Posted August 9, 2013 Lol. I kind of laughed at the credits at the end. yer u better you sheeeeeet cunt! Link to comment Share on other sites More sharing options...
TheScrub Posted August 9, 2013 Author Share Posted August 9, 2013 Might be helpful for me later on. Thanks for this. Np mr Neal Caffrey picture guy! Link to comment Share on other sites More sharing options...
Bake me a cake Posted August 21, 2013 Share Posted August 21, 2013 String Item_Name your naming shouldn't be like that. Link to comment Share on other sites More sharing options...
TheScrub Posted August 22, 2013 Author Share Posted August 22, 2013 String Item_Name your naming shouldn't be like that. thats the parameter for people to understand ik what u mean should be item_name no caps i have String s in my parameter's i renamed it for people to understand Link to comment Share on other sites More sharing options...
Mr Asshole Posted August 22, 2013 Share Posted August 22, 2013 (edited) just something i wrote This will be able to return the id of the item name inside your bank With this snippet you will need to check if the bank is open With this snippet you must keep the anotation Wrote more around the core so it will return an int public int bankItemIdByName(String Item_Name){ Item items[] = client.getBank().getItems(); int item_id = 0; for (Item single_item : items) { if (single_item.getName().equals(Item_Name)) { item_id = single_item.getId(); return item_id; } } return item_id; } /* * This will return the id of the item by name * This was written by "TheScrub" * John of * Adelaide South Australia */ /*Example use of the method provided above*/ client.getBank().withdraw1(bankItemIdByName("Salmon")); Looks good but make use of naming conventions. It helps make understanding it easier for the person reading it. For example your method name is using correct naming conventions. Use mixed casing for parameter values with a prefix such as a or an. variables use mix casing as well and constants should utilize capitalizing each word with a underscore. for example: public int getBankItemByName(aItemName){ int itemID = 0; for (Item singleItem : client.getBank().getItems()) { if (single_item.getName().equals(aItemName)) { itemID = singleItem.getId(); return itemID; } } return -1; } Edited August 22, 2013 by Exarticus Link to comment Share on other sites More sharing options...
Cyro Posted August 22, 2013 Share Posted August 22, 2013 just something i wrote This will be able to return the id of the item name inside your bank With this snippet you will need to check if the bank is open With this snippet you must keep the anotation Wrote more around the core so it will return an int public int bankItemIdByName(String Item_Name){ Item items[] = client.getBank().getItems(); int item_id = 0; for (Item single_item : items) { if (single_item.getName().equals(Item_Name)) { item_id = single_item.getId(); return item_id; } } return item_id; } /* * This will return the id of the item by name * This was written by "TheScrub" * John of * Adelaide South Australia */ /*Example use of the method provided above*/ client.getBank().withdraw1(bankItemIdByName("Salmon")); Looks good but make use of naming conventions. It helps make understanding it easier for the person reading it. For example your method name is using correct naming conventions. Use mixed casing for parameter values with a prefix such as a or an. variables use mix casing as well and constants should utilize capitalizing each word with a underscore. for example: public int getBankItemByName(aItemName){ int itemID = 0; for (Item singleItem : client.getBank().getItems()) { if (single_item.getName().equals(aItemName)) { itemID = singleItem.getId(); return itemID; } } return null; } an int cant return null change that to -1 and use #equalsIgnoreCase(); instead of #equals(); Link to comment Share on other sites More sharing options...
Mr Asshole Posted August 22, 2013 Share Posted August 22, 2013 just something i wrote This will be able to return the id of the item name inside your bank With this snippet you will need to check if the bank is open With this snippet you must keep the anotation Wrote more around the core so it will return an int public int bankItemIdByName(String Item_Name){ Item items[] = client.getBank().getItems(); int item_id = 0; for (Item single_item : items) { if (single_item.getName().equals(Item_Name)) { item_id = single_item.getId(); return item_id; } } return item_id; } /* * This will return the id of the item by name * This was written by "TheScrub" * John of * Adelaide South Australia */ /*Example use of the method provided above*/ client.getBank().withdraw1(bankItemIdByName("Salmon")); Looks good but make use of naming conventions. It helps make understanding it easier for the person reading it. For example your method name is using correct naming conventions. Use mixed casing for parameter values with a prefix such as a or an. variables use mix casing as well and constants should utilize capitalizing each word with a underscore. for example: public int getBankItemByName(aItemName){ int itemID = 0; for (Item singleItem : client.getBank().getItems()) { if (single_item.getName().equals(aItemName)) { itemID = singleItem.getId(); return itemID; } } return null; } an int cant return null change that to -1 and use #equalsIgnoreCase(); instead of #equals(); Opps my bad. Thanks for catching that :P Link to comment Share on other sites More sharing options...
Blue Herbs Posted August 22, 2013 Share Posted August 22, 2013 Very helpful, thank you Learning to script is a lot easier with snippets :p Link to comment Share on other sites More sharing options...
lolmanden Posted August 22, 2013 Share Posted August 22, 2013 Thank you for the snippet! Link to comment Share on other sites More sharing options...