For Server Owners

Reward Your Players with the Metin2 Vote API: Setup Guide

Reward Your Players with the Metin2 Vote API: Setup Guide

Giving a small in-game reward to players who vote keeps your community happy and pushes your server up the weekly ranking. The Metin2PvpServarlar.com vote API automatically tells your server whether a player has really voted. This guide walks you through the Metin2 vote API setup step by step, with sample PHP code and security rules.

How does the system work?

  1. The player clicks the vote link containing their own account number, on your website or in game.
  2. On our site, they pass the robot verification (Cloudflare Turnstile) and cast their vote.
  3. When the player asks for their reward, your server checks this account number with the verification URL.
  4. If the response is 1, you give the reward; if it's 0, you remind the player to vote first.

A player can vote for the same server once every 24 hours. For votes cast through the vote link, this limit applies to both the IP address and the game account.

Where do you find the links?

On the Control Panel › My Servers page, click the API button next to your server. There you'll see two addresses and a short PHP example.

The vote link is the address the player clicks:

https://www.metin2pvpservarlar.com/oy-ver/{server-name}/{server_id}/{ID}

The verification URL is the address only your server calls:

https://www.metin2pvpservarlar.com/api/oy/{server_id}/{api_key}/{ID}

The ID at the end of both addresses is the player's game account number and must be a number greater than zero. Copy the vote link from the panel as is and only replace the ID at the end. The verification URL returns plain text: 1 if the player voted for your server through the vote link within the last 24 hours, 0 if not.

Step-by-step setup

  • Generate the link per player: Don't make players type their account number by hand. In the user panel on your website or in the in-game vote button, add the logged-in account's number to the link automatically. That way the reward goes to the right account.
  • Add a "Claim my reward" button: The player presses it after voting; the code running on your server sends the verification request at that moment.
  • Log the reward: The verification URL returns 1 for 24 hours after the vote. Save the time you gave the reward to your own database together with the account number, and don't give the same account a second reward before 24 hours have passed. Otherwise a player can press the button repeatedly with a single vote and collect rewards.
  • Deliver the reward: Use whatever method your server files support, such as adding item shop balance or sending the player an item.

Sample PHP code

You can add the code below to a server-side PHP file on your website:

// Never put your API key in the game client, in JavaScript code
// or in any publicly accessible file.
const SERVER_ID = '{server_id}'; // Your server ID from the panel
const API_KEY   = '{api_key}';   // Your API key from the panel

function hasVoted(int $accountId): bool
{
    if ($accountId < 1) {
        return false;
    }

    $url = 'https://www.metin2pvpservarlar.com/api/oy/'
        . SERVER_ID . '/' . API_KEY . '/' . $accountId;

    $curl = curl_init($url);
    curl_setopt_array($curl, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CONNECTTIMEOUT => 5,
        CURLOPT_TIMEOUT        => 10,
    ]);
    $response  = curl_exec($curl);
    $errorCode = curl_errno($curl);
    $httpCode  = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    // Connection error, timeout or invalid request: no reward.
    if ($response === false || $errorCode !== 0 || $httpCode !== 200) {
        return false;
    }

    return trim($response) === '1';
}

// $accountId comes from the logged-in player's session.
if (hasVoted($accountId)) {
    // If this account hasn't been rewarded in the last 24 hours,
    // give the reward and save the reward time to the database.
} else {
    // Remind the player to vote first.
}

The code only gives a reward when the response is exactly 1. If the key or number is wrong, the response may be a short error message; on a timeout, nothing comes back at all. All of these cases count as "no vote".

Security and rules

  • Keep the key secret: If you run the check in code on the player's computer, the player can fake the response and get the reward for free, and your key ends up in everyone's hands. If you think your key has leaked, write to us through the contact page.
  • Keep requests to a minimum: Only run the check when a player asks for a reward. Querying every account at regular intervals creates unnecessary load.
  • Follow the rules: Giving in-game rewards for votes is allowed. Buying votes, paying money for votes or collecting votes with bots, VPNs and fake accounts is forbidden; fraudulent votes can be deleted and the server can be removed from the list.
  • Pick a balanced reward: Give small but regular rewards instead of big ones that break the game's economy. Players who vote every day help your server climb the best servers ranking.

Common problems

  • It always returns 0: The player may not have used the vote link with their account number. Votes cast by logging in to our site and voting from the server page count toward the ranking but don't show up in the verification URL. Also check that the number in the vote link matches the one in the verification request.
  • A player can't vote: Since the vote link's limit also applies per IP address, players sharing the same internet connection can only vote for your server once in 24 hours through this link. Explain this to your players in advance.
  • The response is slow: Show the player a "try again in a few minutes" message; don't fire the request over and over in a loop.

We explain where to share your vote link in our server promotion guide. To show your players how to claim their reward, you can share our voting guide.

Frequently asked questions

How do I set up the vote API if I don't use PHP?

The logic is the same in every language: send a GET request to the verification URL and give the reward if the response is exactly 1. If your site is built in another programming language, apply the same steps there.

Can a player get a reward twice on the same day?

They shouldn't. Since the verification URL returns 1 for 24 hours after the vote, it's your code's job to log the reward time and prevent repeats.

Which number should I use as the ID?

The player's game account number. It must be a number greater than zero, and the same number must be used in both the vote link and the verification request.

Does the vote reset affect the reward system?

No. Votes reset for the ranking every Friday at 20:59 Turkish time (UTC+3); the 24-hour voting window runs independently. A player who voted right before the reset can vote again as soon as their window is up.

0 Likes

More posts

Comments 0

No comments yet.