Ads - Banners and Rewarded Videos

How to show ads in the game with the supported ad providers: banners on the screen and videos that give a reward to the player. The ads are the ads feature (enabled in Features), and the sample ads and providers are installed disabled.

Providers

  • CrazyGames (crazyGames) - banners and videos, for games published on the CrazyGames platform.
  • GameMonetize (gameMonetize) - videos, it requires the game ID of your GameMonetize account in the client/ads/general/providers/gameMonetize/gameId config.

To use a provider, check Enabled on its row in Ads > Providers and set its client/ads/general/providers/[provider key]/enabled config to 1. The client loads the provider SDK from the sdkUrl config of the provider.

Banners

A banner is an Ads row with the banner type, the size (Width, Height) and the position (Top, Bottom, Left, Right), plus a Banners row with the Banner Data JSON that says when it is shown:

  • {"fullTime": true} - the banner is always visible (the sample fullTimeBanner).
  • {"uiReferenceIds": ["inventory-open", "equipment-open"]} - the banner is visible while the player has one of those UI boxes open (the sample ui-banner), use ANY for every box.
Admin Panel - Ads list with the sample banners and videos Admin Panel - Banner data of the UI banner

Rewarded videos

A video is an Ads row with the eventVideo type and a Videos row with:

  • Event Key - the client event that plays the video, for example reldens.activatedRoom_reldens-new-age-town (when the player enters the town).
  • Event Data - the reward, for example {"rewardItemKey":"coins","rewardItemQty":1}.
Admin Panel - Ads videos list

While the video plays the player can not move. When it ends the server gives the reward item once per play; if the video ended before the client/ads/general/providers/[provider key]/videoMinimumDuration milliseconds (3000 for CrazyGames), the reward is given when that time has passed. Each play is saved in Ads > Played: without Replay a player sees each video once, with Replay the video plays every time the event happens.

Code integration (advanced)

  • Server: AdsPlugin (lib/ads/server/plugin.js) loads the ads with AdsStartHandler into the client/ads/collection and server/ads/collection config, and AdsMessageActions saves the started and ended videos and gives the rewards.
  • Client: lib/ads/client/plugin.js loads the SDK of each active provider with SdkHandler; the providers classes are in lib/ads/client/providers/ and are registered in ProvidersList (googleAdSense is an empty placeholder).
  • See Ads Entity, Ads Banner Entity, Ads Event Video Entity, Ads Played Entity and Ads Providers Entity.
Go Up