Skip to content

Plrun HTML5 SDK Reference

The Plrun SDK provides a simple, unified interface to monetize your HTML5 games and access platform features like leaderboards and cloud saves.


Getting Started

To use the SDK, you must include the script tag in the <head> of your game's index.html file. It must be loaded before your game logic.

<!-- Import the Plrun SDK -->
<script src="https://sdk.plrun.com/v1/plrun.js"></script>

Initialization

Before calling any other methods, you must initialize the SDK with your unique Game ID (found in your Developer Dashboard).

Plrun.init({
    gameId: 'YOUR_GAME_ID',
    onInit: function() {
        // SDK is ready. Start your game engine here.
        game.start();
    }
});

Interstitial Ads

Interstitial ads are full-screen ads that cover the interface of the game. They are best placed at natural transition points, such as between levels or after a game over screen.

Note: Always pause your game and mute audio before calling the ad function.

// Pause game loop and mute sound
game.pause();
audio.mute();

Plrun.showInterstitialAd().then(() => {
    // Ad finished or was skipped. Resume game.
    game.resume();
    audio.unmute();
}).catch((error) => {
    // Ad failed to load. Resume game anyway.
    console.error(error);
    game.resume();
});

Rewarded Video Ads

Rewarded ads allow users to watch a video in exchange for an in-game reward (e.g., extra lives, coins, skins). You should only grant the reward if the promise resolves with true.

Plrun.showRewardedAd().then((success) => {
    if (success) {
        // The user watched the ad entirely. Grant reward.
        player.addCoins(100);
        console.log("Reward granted!");
    } else {
        // The user closed the ad early. Do nothing.
        console.log("Ad skipped. No reward.");
    }
});

Leaderboards

Submit scores to the global Plrun leaderboards. The platform will automatically handle UI overlays to show rankings if you enable it in the dashboard.

Parameters:

Parameter Type Description
boardId String The ID of the leaderboard created in your dashboard.
score Number The numeric score achieved by the player.
Plrun.submitScore({
    boardId: 'global_high_score',
    score: 5020
}).then(() => {
    console.log("Score submitted successfully!");
});

Need help? Contact Developer Support

Version: 1.0.4