Docs/Recipes/Currency & shop
Recipe: Currency & shop
Earn coins on elimination, spend them at a shop button to buy items. Persistent across sessions. Three rules + one variable.
Last updated 2026-06-06
Ingredients
- Variable
coins— int, scopeplayer, persist on, default 0. - Config
shield_price— int, default 100. - UEFN devices: 1 Elimination Manager, 1 Button Device, 1 Item Granter (shield potion), 1 HUD Message device.
Build it
Variable + config
coins(int, player, persist on) so progress sticks between sessions.shield_pricein Config so designers tune economy in UEFN without redeploying.Earn rule
WHEN On Elimination → DO Give Currency coins +10, Show HUD "+10 coins".Successful purchase
WHEN On Button Pressed IF Compare variable coins ≥ shield_price → DO Decrement Variable coins by shield_price, Grant Item shield_potion, Show HUD "Purchased!"Failed purchase
WHEN On Button Pressed IF Compare variable coins < shield_price → DO Show HUD "Not enough coins". Symmetric pair: either you can afford it or you get the “nope” feedback. No silent failure.
💡 Tip
Always pair an action rule with a feedback rule. Players shouldn't have to guess whether their press registered.
Generated Verse
# Persistent state
te_player_stats := class<final><persistable>:
Version:int = 0
Coins:int = 0
# Successful purchase rule (Rule 3)
ShopButton.InteractedWithEvent.Subscribe(OnShopPress)
OnShopPress(Agent:agent):void=
if (GetCoins[Agent] >= ShieldPrice):
SetCoins(Agent, GetCoins[Agent] - ShieldPrice)
ItemGranter.GrantItem(Agent)
HUDMessage.Show(Agent, MsgPurchased)
else if (GetCoins[Agent] < ShieldPrice):
HUDMessage.Show(Agent, MsgNotEnough)
Variations
- Tiered shop — multiple buttons each with their own price + item granter. Each gets a pair of rules.
- Daily reset — add a
last_purchase_dayvariable; allow once per day. - Bulk discount — gate by a
buy_countthreshold for a loyalty price.
Gotchas
⚠️ Watch out
Persist ON for currency. If a player disconnects mid-game and coins aren't persistent, they lose everything earned.
⚠️ Watch out
Check before decrement. Don't decrement first then re-check — if you do, a network hiccup can leave the player negative.
See also