UGTK / Toolkit / API / Tickets Api Completed
Tickets System
Summary
Generates redeemable ticket codes and syncs them with a PHP server: create/upload codes in batch, download the ticket list into a database, redeem or delete a code, and show them in a leaderboard-style UI.
Content
Modules Dependencies
This module depends on the following UGTK modules:
- Php Connection System: all server operations inherit Mn_PhpOperationBase.
- App Info Stats System: tickets are scoped by Mn_AppInfo.AppIdentifier.
- Code Generator (Mn_Code for codes), Database System, Layout Auto Resize and Pooling System are also used.
Carried inside the prefabs. These modules are not referenced by the assembly definition - the components are simply already attached to the prefabs this module ships. Remove one of them from the project and the prefab keeps its layout and loses that behaviour, with nothing in the console to say so.
| Module | Component, and the prefab carrying it |
|---|---|
Api/EmailSender |
Mn_PhpMailSender (in TicketsGeneratorScreen) |
DataSystem/TableManagement |
Mn_DatabaseToExcelExporter (in TicketsLeaderboardScreen) |
UIModule/BlurSystem |
Mn_UIHaloShadow (in TicketsGeneratorScreen), Mn_UIHaloShadow (in TicketsLeaderboardScreen), Mn_UIHaloShadow (in TicketsRedeemCodeScreen) |
UIModule/LayoutAutoResize |
Mn_VerticalAutoResize (in TicketsLeaderboardScreen) |
UIModule/TextUpdaterSystem |
Mn_TextUpdater (in TicketElement), Mn_TextUpdater (in TicketsGeneratorScreen) |
UtilitySystems/ActivationSystem |
Mn_GameObjectActivation (in TicketRedeemer), Mn_TimeGameObjectActivation (in TicketRedeemer), Mn_TimeGameObjectActivation (in TicketsRedeemCodeScreen) |
UtilitySystems/CodesGenerator |
Mn_Code (in TicketSender), Mn_Code (in TicketsGeneratorScreen) |
UtilitySystems/PoolingSystem |
Mn_Pooler (in TicketsLeaderboardScreen) |
UtilitySystems/ReplaceSpecialWorld |
Mn_ReplaceSpecialWord (in TicketRedeemer), Mn_ReplaceSpecialWord (in TicketsGeneratorScreen), Mn_SpecialWorldSlot (in TicketRedeemer), and 2 more |
Setup
A ticket is a code that exists on your server and can be redeemed exactly once, so the server half comes first.
- Copy
PhpFiles/tickets/to your backend and connect the four endpoints to your database:ticket_create,ticket_list,ticket_redeem,ticket_delete. - Create a
SO_TicketsDatabaseasset - it is anSO_GenericDatabase<S_TicketInfo>, so it behaves like every other UGTK database and holds the tickets the device knows about. - Add the prefabs from
Prefabs/ServerOperations/for the operations you need:TicketSendercreates,TicketDownloaderlists,TicketRedeemerredeems,TicketDeleterremoves. Each is aMn_PhpOperationBase, so each takes its own URL. - For the screens, use
TicketsGeneratorScreen,TicketsLeaderboardScreenandTicketsRedeemCodeScreenfromPrefabs/UIs/;TicketElementis the row the leaderboard clones.
Before shipping, replace the apiKey on every ticket component. All four of them expose one,
and the prefabs in Prefabs/ServerOperations/ ship with a value already serialised into them - so a
project that drops those prefabs in and never opens the Security header is authenticating with a key
that is not its own. The field is a plain serialised string: it is readable in the prefab file and
in the built player, which makes it a shared secret between your game and your server, not a
protection against someone who has the build.
Redemption has to happen on the server, and it does. ticket_redeem.php is the only place that
decides whether a code is still valid - if that check were done on the device, two phones redeeming
the same code at the same moment would both win.
How To Use
- Use
Mn_TicketTokenSenderto generate and upload a batch of distinct codes (ticket_create.php); the next code is sent only after the server confirmsstatus == "ok". - Call
Mn_TicketsDownloaderto download all tickets for the current app identifier (ticket_list.php) into aSO_TicketsDatabase. - Call
Mn_TicketsLeaderboard.UpdateLeaderboard()to render the tickets asMn_TicketElementrows. - Redeem a code with
Mn_TicketTokenRedeemer(SetInputCode/SetPlayerNicknamethenRedeem(),ticket_redeem.php), or remove one withMn_TicketTokenDeleter.DeleteByCode(code)(ticket_delete.php).
Testing Scene
Open TicketScene in the module's Debug/ folder.
What to do, in order:
- Generate a batch of codes and press download to see them arrive.
- Redeem one, then redeem the same one again.
- Redeem a code that does not exist.
- Delete a code and try to redeem it.
Steps 2 and 3 are the two answers a player will actually hit, and both need a specific state on the server to reproduce honestly — which is why every component's inspector can simulate them directly. Build the UI against the simulated answers first.
Then do the test everybody skips: turn the network off and repeat. A request that never answers is the normal condition on mobile, and it is where a game most often ends up stuck on a spinner with no way back.
The recording is the generator screen taking its settings: a reward name, how many codes to make, and how long each one should be. It stops there on purpose - Generate code writes rows into the database behind the configured endpoint, and the endpoint the demo ships with is the author's. Point it at your own before you press it, or you will be filling somebody else's table with "Free coffee".
Technical Info
- Mn_TicketTokenSender: PHP operation that generates codes (
Mn_Code) and uploads them in batch sequentially. - Mn_TicketsDownloader: PHP operation that downloads all tickets into
SO_TicketsDatabase. - Mn_TicketTokenRedeemer: PHP operation that verifies and redeems a code, parsing the server
PhpResponse. - Mn_TicketTokenDeleter: PHP operation that deletes a ticket row by code.
- Mn_TicketsLeaderboard: builds the UI list of tickets.
- Mn_TicketElement: single ticket row (init from
S_TicketInfo, supports delete). - SO_TicketsDatabase:
SO_GenericDatabase<S_TicketInfo>storing downloaded tickets. - S_TicketInfo: struct with db id, app identifier, code, reward key, generated/redeemed timestamps and redeemer nickname.
© 2026 Marcello De Bonis. All rights reserved
Depends on 15
Used by 0
- No other module depends on it.
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 23 modules in total.
UGTKengine within an engine


