Organizing a gamemode
Keep the entry point small. It should initialize infrastructure, register feature modules, and call vimp.markReady() only when required startup work is complete.
text
src/server/
├─ main.ts
├─ infrastructure/
├─ players/
├─ vehicles/
├─ inventory/
└─ events/Recommended boundaries
- Event adapters validate untrusted payloads and call application services.
- Application services own rules and operate on explicit player/entity IDs.
- Persistence adapters keep database details out of gameplay handlers.
- Feature modules own and destroy their temporary entities, colshapes, timers, and voice channels.
- Shared event declarations define transport payloads without importing runtime values.
Avoid one global file containing every event. Also avoid putting authoritative logic in client scripts merely because GTA state is convenient there. Let the client report an intent or observation, then verify the action on the server.
Pin dependencies and lockfiles. Test database migrations and native addons on a separate server because server scripts share the host process and crash domain.