Skip to content

Capabilities and Credits

The Scorbit SDK allows your game to declare its capabilities and manage credits. Capabilities tell the Scorbit platform what your machine supports, enabling features like remote game start and mobile payments.

Capabilities

Capabilities are declared after creating the game state. They inform the Scorbit platform which features the machine supports, so the mobile app can present the appropriate options to players.

Available Capabilities

Capability Description
StartGame The machine supports starting a game remotely from the Scorbit app
CreditDrop The machine supports adding credits via mobile payment

Declaring Capabilities

Call setCapabilities after creating the game state. Capabilities can be combined using the bitwise OR operator.

// Declare that this machine supports remote game start and credit drop
sb_set_capabilities(gs, SB_CAPABILITY_START_GAME | SB_CAPABILITY_CREDIT_DROP);
// Declare that this machine supports remote game start and credit drop
gs.setCapabilities(scorbit::Capability::StartGame | scorbit::Capability::CreditDrop);
# Declare that this machine supports remote game start and credit drop
gs.set_capabilities(scorbit.Capability.StartGame | scorbit.Capability.CreditDrop)

You can also declare a single capability:

// Only support remote game start, no credit drop
sb_set_capabilities(gs, SB_CAPABILITY_START_GAME);
gs.setCapabilities(scorbit::Capability::StartGame);
gs.set_capabilities(scorbit.Capability.StartGame)

When to Set Capabilities

Set capabilities once after creating the game state, before entering the main game loop. This allows the Scorbit platform to know what the machine supports as soon as it connects.

Credits

The credits API allows your game to report credit transactions and status to the Scorbit platform. This is used in conjunction with the Event System — specifically the CreditsAddRequested and CreditsStatusRequested events.

Confirming a Credit Drop

When you receive a CreditsAddRequested event and successfully add credits to the machine, confirm the transaction by calling setCreditsDropped:

// credits: number of credits added
// transaction: the transaction ID from the CreditsAddRequested event
// success: whether the credits were successfully added
sb_set_credits_dropped(gs, credits, transaction, true);
gs.setCreditsDropped(credits, transaction, true);
gs.set_credits_dropped(credits, transaction, True)

If the credit drop failed (e.g., the machine is unable to accept credits), pass false for the success parameter:

sb_set_credits_dropped(gs, credits, transaction, false);
gs.setCreditsDropped(credits, transaction, false);
gs.set_credits_dropped(credits, transaction, False)

Reporting Credit Status

When you receive a CreditsStatusRequested event, report the current credit state of the machine:

// free_play: whether the machine is in free play mode
// credits: current number of credits
// max_credits: maximum credits the machine can hold
// pricing: pricing string (e.g., "1 credit per game") or NULL
sb_set_credits_status(gs, free_play, credits, max_credits, pricing);
gs.setCreditsStatus(freePlay, credits, maxCredits, pricing);
gs.set_credits_status(free_play, credits, max_credits, pricing)

Credits Parameters

setCreditsDropped

Parameter Type Description
credits integer Number of credits that were added
transaction string Transaction ID from the CreditsAddRequested event
success boolean Whether the credits were successfully added to the machine

setCreditsStatus

Parameter Type Description
freePlay boolean Whether the machine is in free play mode
credits integer Current number of credits on the machine
maxCredits integer Maximum number of credits the machine can hold
pricing string Pricing description (e.g., "$1.00 per play") or NULL/empty

Typical Flow

  1. At startup, declare capabilities: setCapabilities(StartGame | CreditDrop)
  2. Receive CreditsAddRequested event with credit count and transaction ID
  3. Add credits to the machine
  4. Confirm with setCreditsDropped(credits, transaction, true)
  5. When CreditsStatusRequested is received, report with setCreditsStatus(...)

For complete examples including event handling, refer to the Events page and the Scorbit SDK examples.