Prerequisites
- A FiveM server
- SunLicense API credentials
- Your product ID and license key
Step 1: Set up the basic structure
Create a new file calledlicense_check.lua in your resource’s server folder:
Step 2: Implement the validator class
Step 3: Initialize the license check
Create an initialization file (init.lua):
Step 4: Configure your resource
Update yourfxmanifest.lua:
Best practices
- License key security
- Store your license key in
server.cfg - Never expose the key in client-side code
- Rotate keys regularly if possible
- Store your license key in
- Error handling
- Implement proper logging
- Handle network timeouts
- Provide clear error messages
- Validation timing
- Validate on resource start
- Implement periodic validation if needed
- Use reasonable retry intervals