Pay rewards without a plugin

One PHP file runs next to your game. It asks VoteScript who earned what and pays it.

What you need

  • PHP 7.2 or newer on the command line
  • A login to your game database, or RCON
  • An API key

Start it once

Put the file on a machine that reaches your database or console, and run it. The first start writes the settings file.

Fill in the settings

Choose the mode. The page of your game has a filled-in example, if we know one.

Tip: Try a statement on a copy of your database first.
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]
points = "UPDATE accounts SET vote_points = vote_points + :amount WHERE name = :player"
check = "SELECT 1 FROM accounts WHERE name = :player"
votescript.ini
[votescript]
url = "https://votescript.voterank.net"
key = "YOUR_KEY"
mode = "rcon"

[rcon]
host = "127.0.0.1"
port = 25575
password = ""
retry_if = "No player was found"

[commands]
default = "give {player} {key} {amount}"
votescript.ini
[votescript]
url = "https://votescript.voterank.net"
key = "YOUR_KEY"
mode = "tshock"

[tshock]
url = "http://127.0.0.1:7878"
token = ""
retry_if = "Invalid player"

[commands]
default = '/give {key} "{player}" {amount}'

Match the keys

The word before the statement is the reward key. In the example it is points, so the reward in your dashboard must have the key points.

Start it and vote

Run it again and send a test vote from your dashboard. Keep it running, or run it with --once from cron.

You should now see: A line for each payment, and the points in your game.

If it does not work

A reward waits and waits
The check line finds no account, or the statement changed no row. Usually the account is online, or the name is different.
It stops with a message about rows
Your statement would change more than one row. Make it more exact, so it matches one account.
Fill in the key
Create a key under Game server and paste it into the file.
SQL Server
Use a dsn that starts with sqlsrv: or dblib:, and install that PHP driver.

Next

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.