jua1 Posted April 29, 2014 Share Posted April 29, 2014 (edited) script keeps getting stuck on a if(closestObject(9345) != null) the object is a bird snare and it is on the ground when it cycles through to the null check but it never gets passed. I've tried using closestNPC(), closestObjectForName(), ClosestNPCForName() all dont make it passed the null check. public void LaySnare() throws InterruptedException { Inventory Inven = client.getInventory(); final RS2Object GroundSnare = closestObject(9345); final Entity player = client.getMyPlayer(); if (player != null) if (HuntingGround.contains(player)) { if (Inven.contains(BirdSnareItem) == true) { Inven.interactWithName(BirdSnareItem, InteractSnare); sleep(10000); if(GroundSnare != null){ log("logging snare position"); snare = GroundSnare.getPosition(); if(!Inven.contains(BirdSnareItem)){ log(DetectState); StateHolder = 0;} } } } else { walkExact(HuntingGround); } } Edited April 29, 2014 by jua1 Link to comment Share on other sites More sharing options...
BurritoBug Posted April 29, 2014 Share Posted April 29, 2014 script keeps getting stuck on a if(closestObject(9345) != null) the object is a bird snare and it is on the ground when it cycles through to the null check but it never gets passed. I've tried using closestNPC(), closestObjectForName(), ClosestNPCForName() all dont make it passed the null check. do you want to pick it back up off the floor when it collapses? Link to comment Share on other sites More sharing options...
jua1 Posted April 29, 2014 Author Share Posted April 29, 2014 (edited) nah after the null check i log its position so that you can run this with other people hunting in the same area and not try to pick up their snares, but the problem is the getPosition() requires a null check and i've also tried exist(). Edited April 29, 2014 by jua1 Link to comment Share on other sites More sharing options...
Extreme Scripts Posted April 29, 2014 Share Posted April 29, 2014 RS2Object snare = closestObjectForName("Bird snare"); if(snare != null){ snare.interact("Dismantle"); } Link to comment Share on other sites More sharing options...
jua1 Posted April 29, 2014 Author Share Posted April 29, 2014 RS2Object snare = closestObjectForName("Bird snare"); if(snare != null){ snare.interact("Dismantle"); } tried this it didn't work. Link to comment Share on other sites More sharing options...
Nezz Posted April 29, 2014 Share Posted April 29, 2014 If it's on the ground, it could be a GroundItem so GroundItem birdsnare = closestGroundItemForName("Bird snare"); if(birdsnare != null) do stuff Link to comment Share on other sites More sharing options...
jua1 Posted April 29, 2014 Author Share Posted April 29, 2014 thats possible but when i place it on the ground i get no value for ground item. Worth trying though il try it right now. Yea its not a ground item Link to comment Share on other sites More sharing options...
Extreme Scripts Posted April 29, 2014 Share Posted April 29, 2014 (edited) thats possible but when i place it on the ground i get no value for ground item. Worth trying though il try it right now. Yea its not a ground item First things first I think you need to be more clear as to what you're trying to do with the trap, bird traps have 4 states: Layed (Waiting for Bird to smoke) id = 9345 Smoked (Failed to catch crimson) id = 9344 Caught (Caught the Crimson) id = 9373 Fell down (This is a GroundItem now) id: 10006 With the ID you provided in the OP you are trying to do something with the "Layed" trap which doesn't really make sense but hope this gives some clarity: I'll give you a snippet of what's in my Divinity Birds script which works perfectly: RS2Object setTrap = closestObjectForId(9345); if(setTrap != null){ if(setTrap.isVisible()){ setTrap.interact("Dismantle"); sleep(random(700,1200)); } else { client.moveCameraToEntity(setTrap); } } Edited April 29, 2014 by Divinity 1 Link to comment Share on other sites More sharing options...
jua1 Posted April 29, 2014 Author Share Posted April 29, 2014 this is only a snippet of the code that is where its getting stuck. If i dont getPosition of the snare my script works perfectly. I need to log their positions though so you can run the script next to other bots or else its going to try to pick up other ppls snares. Im telling you guys I am only having problem with the null check for closestObjectForName("Bird Snare") Link to comment Share on other sites More sharing options...
Extreme Scripts Posted April 30, 2014 Share Posted April 30, 2014 this is only a snippet of the code that is where its getting stuck. If i dont getPosition of the snare my script works perfectly. I need to log their positions though so you can run the script next to other bots or else its going to try to pick up other ppls snares. Im telling you guys I am only having problem with the null check for closestObjectForName("Bird Snare") Ahhhh in that case you need to make sure it's spelt correctly... it's "Bird snare" with a small "s" Link to comment Share on other sites More sharing options...
jua1 Posted April 30, 2014 Author Share Posted April 30, 2014 yea sorry i spelt it correctly in the script I think im going to do it a different way because this is not working it seems that the null check doesnt work for this object. Link to comment Share on other sites More sharing options...
Extreme Scripts Posted April 30, 2014 Share Posted April 30, 2014 yea sorry i spelt it correctly in the script I think im going to do it a different way because this is not working it seems that the null check doesnt work for this object. If you would like me to teamview you to sort the issue I would be more than happy. Just pm me your credentials if so ^_^ Link to comment Share on other sites More sharing options...
Swizzbeat Posted April 30, 2014 Share Posted April 30, 2014 Just so you can get better: NEVER EVER EVER EVER EVERRRRRR check for a boolean value by doing "==" or anything of the sort Final variables should be all caps separated by _ characters for spaces Variables/methods should be camelCased (unless their final) Not sure if just how you copy/pasted but your brackets are all over the place What is the point of making those variables final As for your question, try logging before that line what the ground snare is equal to. Link to comment Share on other sites More sharing options...
jua1 Posted April 30, 2014 Author Share Posted April 30, 2014 final Variables should be all caps... does that mean final are Const variables? Link to comment Share on other sites More sharing options...
jua1 Posted April 30, 2014 Author Share Posted April 30, 2014 so all those who have had trouble with this use getX() and getY() don't check for null just keep the same position for both snares. Link to comment Share on other sites More sharing options...