Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Tutorial How, and why, to use the PlayerSense API

Joined
Dec 10, 2014
Messages
3,255
How, and why, to use the PlayerSense API


What is PlayerSense? (Documentation link)
PlayerSense is used to prevent accounts from having the same pattern, even when they are running the same bot. By giving each account a different behaviour when it comes to certain things (such as using hotkeys for interfaces, hotkeys for the actionbar, when to enable run and much, much more) we strive to combat against some of the pattern detecting code that Jagex uses to identify bots.​

How does it work?
PlayerSense holds all of it's information in a Map, using PlayerSense.put(key, value) to put information into the Map, and PlayerSense.get(key, value) to get information from it. There are two kinds of keys you can use, PlayerSense.Key (Documentation link) or String. When you get the value from PlayerSense, if it's using a PlayerSense.Key, it will get a value from the Generator. I recommend you use these predefined keys as often as possible.​

How do I use it?
Depending on the different keys there are different ways to use PlayerSense. Here I have a short snippet of how I've used PlayerSense to determine whether to use the hotkey (space) or click on the interface.
Code:
public static boolean select(boolean click){
    if(click || !PlayerSense.getAsBoolean(PlayerSense.Key.USE_MISC_HOTKEYS))
        return getCraftButton().click();
    else
        return Keyboard.typeKey(KeyEvent.VK_SPACE);
}

Why should I use it?
By using PlayerSense you're adding another layer of security to your script, reducing the chances of being detected by Jagex's bot-detection systems.
When should I use it?
Whenever it makes sense to, if you have the option of making the bot either use a hotkey or click on the interface, use PlayerSense.getAsBoolean(PlayerSense.Key.USE_MISC_HOTKEYS) to determine which method to use. If there are certain mannerisms you want to reproduce, such as how some people consistently select the first item in their inventory and some just pick a random one, generate a value and put it into PlayerSense, then use that value to choose which one to do. Much of the API already uses PlayerSense, such as ActionBar activating, Chat Dialog option selection, the Camera API, and RegionPath generation.​
 
Last edited:
Joined
Jan 31, 2015
Messages
116
Nice tutorial once again slashie ^^

You should also mention that some RuneMate Api calls have this already implemented. Ex. the Camera.passivelyTurnTo();
 
Joined
Dec 10, 2014
Messages
3,255
Nice tutorial once again slashie ^^

You should also mention that some RuneMate Api calls have this already implemented. Ex. the Camera.passivelyTurnTo();
Thanks :D

I've added some mentions of where the API already uses PlayerSense, thanks for the suggestion :)
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
Thanks :D

I've added some mentions of where the API already uses PlayerSense, thanks for the suggestion :)
It's also used for RegionPath generation. In addition, it's more complicated than a map on the back end but for your explanation it was probably the simplest way to explain it (in reality it stores all values fed to it and creates a value based on that information). It's designed to give consistent values based on it's dataset, and since the dataset various for each individual player (and changes over time) it helps to break larger multi-account patterns.You should go into a bit more detail on how to add your own values to it because that's really powerful too.

In addition, the following screenshots contain updated javadocs so that may be of use in understanding there function.
http://i.gyazo.com/147a5005f34e70c9ec91fc0959e4829a.png
http://i.gyazo.com/00bd2e57dad66a89540eefa7b098ad72.png
 
Last edited:
Joined
Dec 10, 2014
Messages
3,255
It's also used for RegionPath generation. In addition, it's more complicated than a map on the back end but for your explanation it was probably the simplest way to explain it (in reality it stores all values fed to it and creates a value based on that information). It's designed to give consistent values based on it's dataset, and since the dataset various for each individual player (and changes over time) it helps to break larger multi-account patterns.You should go into a bit more detail on how to add your own values to it because that's really powerful too.

In addition, the following screenshots contain updated javadocs so that may be of use in understanding their function.
http://i.gyazo.com/147a5005f34e70c9ec91fc0959e4829a.png
http://i.gyazo.com/00bd2e57dad66a89540eefa7b098ad72.png
So if we were to put multiple values for the same String key into PlayerSense, it would store them all and randomly get one when using get instead of overwriting the old value?

In this case would it be best to feed it randomized values if the key isn't present?
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
So if we were to put multiple values for the same String key into PlayerSense, it would store them all and randomly get one when using get instead of overwriting the old value?

In this case would it be best to feed it randomized values if the key isn't present?
Not quite, it's not a random selection of them. It's a value based on them. If you're feeding it data manually, don't feed it more than one value unless you're really confident in what you're doing.
 
Joined
Dec 10, 2014
Messages
3,255
Not quite, it's not a random selection of them. It's a value based on them. If you're feeding it data manually, don't feed it more than one value unless you're really confident in what you're doing.
So don't feed it callables or anything like that either?
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
@Cloud Are the returned values based on data collected from playing legit in the client?
Currently a select few of them are however moving forward many more will be.
So don't feed it callables or anything like that either?
Nope, the only things you should feed are perhaps a unique value that you would use to determine when to turn the camera to focus on something and such.
 
Joined
Nov 3, 2013
Messages
609
Currently a select few of them are however moving forward many more will be.

Nope, the only things you should feed are perhaps a unique value that you would use to determine when to turn the camera to focus on something and such.
Later this week, I think I'm going to try to make a trainable script. Would you be interested in the results? I'm hoping to find a reliable way of correlating clicks and presses to objects, tiles and interfaces. I've noticed how different scripters write scripts differently because they play differently, hopefully this should help prevent jagex flagging players who are suddenly playing with a totally different style.
 
Joined
Jan 8, 2015
Messages
1,427
Later this week, I think I'm going to try to make a trainable script. Would you be interested in the results? I'm hoping to find a reliable way of correlating clicks and presses to objects, tiles and interfaces. I've noticed how different scripters write scripts differently because they play differently, hopefully this should help prevent jagex flagging players who are suddenly playing with a totally different style.

That sounds very interesting, please tag me when you post :)
 
Joined
Jun 21, 2014
Messages
350
Do you know how I could generate a new key for storing values? My IDE isn't giving me any suggestions on the use of PlayerSense, I enter PlayerSense. and all it suggests is .Key and nothing else, whatever I'm entering isn't appearing to be valid in my IDE.
 
Joined
Nov 3, 2013
Messages
609
Do you know how I could generate a new key for storing values? My IDE isn't giving me any suggestions on the use of PlayerSense, I enter PlayerSense. and all it suggests is .Key and nothing else, whatever I'm entering isn't appearing to be valid in my IDE.
Try "PlayerSense.Key key = new PlayerSense.Key();" Though I think standard practice is to have the constructor private for enums.
 
Joined
Dec 10, 2014
Messages
3,255
Do you know how I could generate a new key for storing values? My IDE isn't giving me any suggestions on the use of PlayerSense, I enter PlayerSense. and all it suggests is .Key and nothing else, whatever I'm entering isn't appearing to be valid in my IDE.
Just use a String as the key, it accepts both a String or a PlayerSense.Key. PlayerSense.Keys are predefined values in an enum, I'm pretty sure you can't create your own.
 
Joined
Nov 3, 2013
Messages
609
Not quite, it's not a random selection of them. It's a value based on them. If you're feeding it data manually, don't feed it more than one value unless you're really confident in what you're doing.
@Cloud
Will this learn from the data I enter?
I'm trying to add a preference between bankers and bank booths. If at first I simply generate random values for it (boolean) and put a bunch of them into it, at some point I would start only using the PlayerSense value, would the getAsBoolean return the most common one (true or false), or something completely different?

Is this data remembered between script runs?

Can you give an example of a good use of custom keys for this?
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
@Cloud
Will this learn from the data I enter?
I'm trying to add a preference between bankers and bank booths. If at first I simply generate random values for it (boolean) and put a bunch of them into it, at some point I would start only using the PlayerSense value, would the getAsBoolean return the most common one (true or false), or something completely different?

Is this data remembered between script runs?

Can you give an example of a good use of custom keys for this?
It would return true/false in a similar manner to the distribution in which you fed them. It's remembered not only across script runs but across scripts, however in the current release it's lost between sessions.
 
Top