Vote rewards for RuneScape (RSPS)

Your players vote on every RSPS toplist from one page. One jar answers ::claimvote, pays online players by itself and can receive Votifier votes. Or your old votes table keeps working as it is.

Create your vote page

Sign up, name your server and choose RuneScape (RSPS). Setup fills in the usual settings: players enter “Your in-game name” and claim with ::claimvote.

You should now see: Your vote page at its own address.

Add your toplists

Paste the link of your server on each list. For this game, VoteRank, RSPS-List, Rulocus and others are ready.

You should now see: Each list on your vote page.

Choose the reward

The item ID, such as 995 for coins. Donator days, titles, teleports and more are in the list.

You should now see: The reward under “What you earn” on your page.

Create an API key

Open Game server in the dashboard and create a key. It is shown once. You need it in the next step.

Connect the game

Choose one of these ways. Each has its own files and settings below.

Try it

Open a vote site in your dashboard, use Send a test vote with your own name, then type ::claimvote in the game.

You should now see: The reward in your game, and “Your game has used a key”.

Add our jar to your server

Tested against a live VoteScript

Step 1

Add votescript.jar to your server’s libraries. It needs Java 8 and nothing else.

Step 2

Start it when your server starts, with the four short methods below and what your game does for each kind of reward. The names in the code are examples: use those of your own server.

your server
// what your game does for each kind of reward
VoteActions<Player> actions = new VoteActions<>();
actions.on("item", (p, i) -> p.getInventory().add(i.number(0, 1, 65535), i.amount));
actions.on("vip/donator", (p, i) -> p.addDonatorDays(i.amount));
actions.on("title", (p, i) -> p.setTitle(i.words(), i.forever() ? -1 : i.amount));
actions.on("xp", (p, i) -> p.getSkills().addXp(Skill.byName(i.arg(0)), i.amount));
actions.on("storage/votePoints", (p, i) -> p.addAttribute("votePoints", i.amount));
actions.on("teleport/vote_island", (p, i) -> !p.inCombat(), (p, i) -> p.moveTo(3222, 3222, 0));
actions.on("run/daily_box", (p, i) -> DailyBox.open(p, i.amount));   // your own

// when the server starts
static final Queue<Runnable> TASKS = new ConcurrentLinkedQueue<>();
static VoteServer votes;

votes = VoteServer.start(new File("data/votes"), new VoteServer.Game() {
    public void run(Runnable task) { TASKS.add(task); }
    public Collection<String> online() {
        List<String> names = new ArrayList<>();
        for (Player p : World.getPlayers()) if (p != null) names.add(p.getUsername());
        return names;
    }
    public boolean give(String name, VoteScript.Claim claim) {
        Player p = World.getPlayer(name);
        if (p == null || p.getInventory().freeSlots() < claim.items.size()) return false; // kept for later
        return actions.give(p, claim);
    }
    public void message(String name, String text) {
        Player p = World.getPlayer(name);
        if (p != null) p.sendMessage(text);
    }
}, actions);

// in your game tick
for (Runnable t; (t = TASKS.poll()) != null; ) t.run();

// in your command handler, with the whole text the player typed
if (votes != null && votes.command(player.getUsername(), text)) return;

Step 3

Pass commands to it. Players can type ::claimvote, or ::auth CODE.

Step 4

Start the server once. Put your API key in data/votes/votescript.properties and restart. Online players are now paid by themselves.

data/votes/votescript.properties (part)
url=https://votescript.voterank.net
key=YOUR_KEY
automatic=true
every=10

Step 5

For lists that send Votifier votes, set votifier=true and open the port. Give the list the token, or the key in data/votes/rsa/public.key.

data/votes/votescript.properties (part)
url=https://votescript.voterank.net
key=YOUR_KEY
automatic=true
every=10

votifier=true
host=0.0.0.0
port=8192
v1=true

Write the command yourself

Tested against a live VoteScript

Step 1

To write everything yourself, use VoteRewards and call claim or claimCode. Network, retries and crashes are handled.

your server
VoteRewards rewards = new VoteRewards(
    new VoteScript("https://votescript.voterank.net", "YOUR_KEY"),
    task -> World.submit(task),               // your game thread
    new File("data/votes.properties"));

rewards.claim(player.getUsername(), new VoteRewards.Handler() {
    public boolean give(VoteScript.Claim claim) {
        if (!player.isOnline()) return false;   // kept for next time
        for (VoteScript.Item i : claim.items)
            player.addItem(Integer.parseInt(i.key), i.amount);
        return true;
    }
    public void message(String text) { player.sendMessage(text); }
});

Keep your old ::claimvote

Run on a test database

For servers whose command already reads a votes table with username, voted_on and claimed. Your jar and your command stay as they are; the delivery program adds one row per vote. In the dashboard, give one reward with the key vote and amount 1 per vote. Rename the columns if yours differ. The table must be InnoDB (ALTER TABLE votes ENGINE=InnoDB), or a crash could add a row twice. Turn off the old vote page first, so nobody can vote in both.

This pays into the database your game already uses. The program runs on your own machine, and VoteScript never gets your database login.

Step 1

No game code: the delivery program pays every confirmed vote by itself. Download it and run it once.

Step 2

Set up votescript.ini like this. Replace the key, the database name and the login.

Give your reward the key vote in the dashboard, so it finds this statement.

votescript.ini
[votescript]
url = "https://votescript.voterank.net"
key = "YOUR_KEY"
mode = "sql"

[database]
dsn = "mysql:host=127.0.0.1;dbname=YOUR_DATABASE;charset=utf8mb4"
user = ""
password = ""

[sql]
vote = "INSERT INTO votes (username, vote_key, site_id, voted_on, claimed) VALUES (:player, UUID(), 0, NOW(), 0)"
check = ""
each = "vote"

Step 3

Start it again and send a test vote from your dashboard.

Toplists for RuneScape (RSPS)

VoteRank is recommended for every game. Lists marked “test first” have a format we only found in other people’s code.

If it does not work

The command says there is nothing to claim
Check that the name on the vote page is the same as in the game, and that the vote shows as counted in the callback log.
Votes are not checked right now
Your game could not reach VoteScript, or the key is wrong. Look at “Last used” next to the key under Game server.
Rewards stay waiting
The statement changed no row. Usually the account is online, the name is different, or the check line does not find it. The program tries again by itself.
A reward says it waits
Your game said it cannot give it yet, or the player was in a fight. Open Rewards in the dashboard to see what your game can do, and allow it in the settings of the script or plugin.
Nothing arrives from a toplist
Compare the callback URL on the list with the one in VoteScript, letter by letter, with https. The common problems guide has every case.

Do it yourself

The API, webhooks and clients work with any game.

Give your players one place to vote

Your page is live as soon as you create your server. You can connect the rest step by step.