What Is CraftyGame?
Every Crafty game extends CraftyGame. The platform calls lifecycle hooks automatically as players join, leave, and matches start/end.
Lifecycle Hooks (Contract)
Override these in your game script:What To Put In Each Hook
_game_init(): register static setup (teams, economy items, config)_game_start(): initialize round runtime state, start timer, spawn logic_game_end(): finalize outcomes, cleanup, optional rewards persistence_player_joined(player): apply defaults, team assignment, per-player bootstrap_player_left(player): cleanup player-owned state or temporary entities
AI Implementation Rules
If you are generating code from this page:- Keep win/lose logic and scoring server-side.
- Use
craftyfor match-wide state, not per-player custom fields. - Use
CraftyPlayer.set_syncedfor values clients need to read. - Keep
_game_init()idempotent and lightweight.
Common crafty Calls Inside CraftyGame
In your CraftyGame class, use the Crafty singleton:

