wafihsn Posted May 14, 2016 Share Posted May 14, 2016 Hey there , im new on runescape os and im making my own script . i am having issu with 2 things , i need to check if my player is in "attack mode" then wait until he is finish .second problem is i can intract with entitys , i want my player to collect bones but nothing happens ,ill paste my code and plz tell me what i did wrong.. if(getInventory().isFull()) getInventory().interact("Bury", "Bones"); else{ Entity bones = getObjects().closest("Bones"); NPC chiken = getNpcs().closest("Chicken"); NPC cow = getNpcs().closest("Cow"); NPC cowcalf = getNpcs().closest("Cow Calf"); if (chiken != null) //attack chicken if (!myPlayer().isAnimating()) chiken.interact("Attack"); if (cow != null) //attack cow if (!myPlayer().isAnimating()) cow.interact("Attack"); if (cowcalf != null) //attack cow calf if (!myPlayer().isAnimating()) cowcalf.interact("Attack"); if (bones != null) //take Bones if (!myPlayer().isAnimating()) bones.interact("Take"); } Quote Link to comment Share on other sites More sharing options...
Explv Posted May 14, 2016 Share Posted May 14, 2016 (edited) Hey there , im new on runescape os and im making my own script . i am having issu with 2 things , i need to check if my player is in "attack mode" then wait until he is finish . second problem is i can intract with entitys , i want my player to collect bones but nothing happens , ill paste my code and plz tell me what i did wrong.. if(getInventory().isFull()) getInventory().interact("Bury", "Bones"); else{ Entity bones = getObjects().closest("Bones"); NPC chiken = getNpcs().closest("Chicken"); NPC cow = getNpcs().closest("Cow"); NPC cowcalf = getNpcs().closest("Cow Calf"); if (chiken != null) //attack chicken if (!myPlayer().isAnimating()) chiken.interact("Attack"); if (cow != null) //attack cow if (!myPlayer().isAnimating()) cow.interact("Attack"); if (cowcalf != null) //attack cow calf if (!myPlayer().isAnimating()) cowcalf.interact("Attack"); if (bones != null) //take Bones if (!myPlayer().isAnimating()) bones.interact("Take"); } Items on the ground are GroundItems not RS2Objects. So to get the bones you need to do: GroundItem bones = getGroundItems().closest("Bones"); To check if your player is attacking something you can do: if(myPlayer().getInteracting() != null) Or this may work too: getCombat().isFighting() Also FYI you don't need a separate variable for each target NPC. You can get the closest out of all of them with one statement: NPC enemy = S.getNpcs().closest("Chicken", "Cow", "Cow calf"); But you may also want to check that those npcs are not under attack themselves, and that they are not dead. Perhaps something like: NPC enemy = getNpcs().closest(new NameFilter<>("Chicken", "Cow", "Cow calf"), npc -> !npc.isUnderAttack() && npc.getHealthPercent() > 0); Edited May 14, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
wafihsn Posted May 14, 2016 Author Share Posted May 14, 2016 Items on the ground are GroundItems not Objects. So to get the bones you need to do: GroundItem bones = getGroundItems().closest("Bones"); To check if your player is attacking something you can do: if(myPlayer().getInteracting() != null) Or this may work too: getCombat().isFighting() Also FYI you don't need a separate variable for each target NPC. You can get the closest out of all of them with one statement: NPC enemy = S.getNpcs().closest("Chicken", "Cow", "Cow calf"); But you may also want to check that those npcs are not under attack themselves, and that they are not dead. Perhaps something like: NPC enemy = getNpcs().closest(new NameFilter<>("Chicken", "Cow", "Cow calf"), npc -> !npc.isUnderAttack() && npc.getHealthPercent() > 0); thanx man .. im on the right way now Quote Link to comment Share on other sites More sharing options...
Strange_Fk Posted May 14, 2016 Share Posted May 14, 2016 Items on the ground are GroundItems not Objects. So to get the bones you need to do: GroundItem bones = getGroundItems().closest("Bones"); To check if your player is attacking something you can do: if(myPlayer().getInteracting() != null) Or this may work too: getCombat().isFighting() Also FYI you don't need a separate variable for each target NPC. You can get the closest out of all of them with one statement: NPC enemy = S.getNpcs().closest("Chicken", "Cow", "Cow calf"); But you may also want to check that those npcs are not under attack themselves, and that they are not dead. Perhaps something like: NPC enemy = getNpcs().closest(new NameFilter<>("Chicken", "Cow", "Cow calf"), npc -> !npc.isUnderAttack() && npc.getHealthPercent() > 0); Explv is a boss, always see him helping people with scripting and putting out some quality scripts 2 Quote Link to comment Share on other sites More sharing options...
Tom Posted May 14, 2016 Share Posted May 14, 2016 Items on the ground are GroundItems not Objects. So to get the bones you need to do: GroundItem bones = getGroundItems().closest("Bones"); Scripter Drama Issue #717 Technically speaking, GroundItem is an object Quote Link to comment Share on other sites More sharing options...
Explv Posted May 14, 2016 Share Posted May 14, 2016 (edited) Scripter Drama Issue #717 Technically speaking, GroundItem is an object I meant RS2Objects* Don't make me hurt you Edited May 14, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
Tom Posted May 14, 2016 Share Posted May 14, 2016 RS2Objects* Don't make me hurt you nop just object Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted May 14, 2016 Share Posted May 14, 2016 @Explv back at it again! Quote Link to comment Share on other sites More sharing options...