Jump to content

Generating Player-Specific Preferences


Naton

Recommended Posts

When enough accounts are using your script, you may not want every account to be behaving exactly the same. You may want to create specific preferences for each account.

 

The TRiBot Script SDK contains a class to assist with generating player specific preferences.

See the docs at https://runeautomation.com/docs/sdk/-tribot--scripting--s-d-k/org.tribot.script.sdk.antiban/-player-preferences/preference.html

The class is

org.tribot.script.sdk.antiban.PlayerPreferences

 

To generate a preference, call 

PlayerPreferences.preference(key, generatorFunction)

Ex.

PlayerPreferences.preference("org.tribot.Antiban.eatPercent", g -> g.uniform(30, 60))

 

This above line would generate a value evenly distributed from 30-60 for all accounts.

Calling this method with the same parameters always gives the same value for the same account, even if you re-run the script on another machine.

 

Note that some level of care must be taken to not duplicate the preference key - see the preference key parameter docs for a convention to follow.

 

Let's try a real example. Let's say we want 70% of our accounts to train mining first and get a coal bag for blast furnace, and we want 30% of our accounts to train smithing to 30 first.

We could do this with the following code:

int preference = PlayerPreferences.preference("scripts.blastfurnace.decisions.MineOrSmith", g -> g.uniform(1, 100))
if (preference > 30) {
	// mine
}
else {
	// smith
}

 

Note that the key being used doesn't really matter, it's used in combination with your in-game account name to generate a seed for the random number generator used by the generator function. This allows the preferences to be repeatable when running the script again on the same account. You just need to make sure not to use the same key for more then one preference.

 

You can do so much more then just have 70% of accounts doing one activity, but that is a simple real-world example. This is a very powerful and easy to use feature that allows you to create customized (and most importantly, repeatable even if you re-run the script, or really just the same preference key and generator function not necessarily the same script, on another machine but on the same account) playstyles for your bots.

View all my bots on the TRiBot store! (premium) (free)

Need assistance with any of my bots? Join the nScript support discord (link below).

nScripting.com    nScript Support Discord     Refund Policy

Automate your bot management through nRestocker and the TRiBot Bulk Launcher

Link to comment
Share on other sites

  • Nullable changed the title to Generating Player-Specific Preferences

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...