Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
Shady1

how to - beginner question

8 posts in this topic

hi,

how would i detect a player underneath me, in my exact spot? thank you very much.

Share this post


Link to post
Share on other sites

If you right click on your player you should be able to see if someone is under you from the choose options.

Share this post


Link to post
Share on other sites
1 minute ago, Sphiinx said:

    public static int getPlayersInArea(int radius) {
        RSArea radiusArea = new RSArea(Player.getPosition(), radius);
        return Players.getAll(Filters.Players.inArea(radiusArea)).length - 1;
    }

 

so i already know how to use this, but will this work if there is someone underneath me?  if i only want it to check the tile underneath me, would the radius be zero or 1?

Share this post


Link to post
Share on other sites
3 minutes ago, Deluxes said:

If you right click on your player you should be able to see if someone is under you from the choose options.

i guess that's one way to do it

Share this post


Link to post
Share on other sites
Just now, Shady1 said:

so i already know how to use this, but will this work if there is someone underneath me?  if i only want it to check the tile underneath me, would the radius be zero or 1?

Modify that, set a radius of 1. Then filter for the names discluding yours.

Share this post


Link to post
Share on other sites
Just now, Sphiinx said:

Modify that, set a radius of 1. Then filter for the names discluding yours.

ok radius of 1 for underneath me confirmed, ty

Edited by Shady1

Share this post


Link to post
Share on other sites
5 hours ago, Shady1 said:

ok radius of 1 for underneath me confirmed, ty

No point using an area with size 1. Just use that tile directly:

private int playersUnderneath() {	
	return Players.getAll(Filters.Players.tileEquals(Player.getPosition())).length - 1;
}

Or, as an alternative, if you don't care how many players are underneath, you can use Players.exists: 

// at least one player is underneath you
private boolean hasPlayerUnderneath() { 
	return Players.exists(Filters.Players.tileEquals(Player.getPosition()), 2);
}



 

Edited by Beg
1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.