Skip to main content

Prerequisites

  • A FiveM server
  • SunLicense API credentials
  • Your product ID and license key

Step 1: Set up the basic structure

Create a new file called license_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 your fxmanifest.lua:

Best practices

  1. License key security
    • Store your license key in server.cfg
    • Never expose the key in client-side code
    • Rotate keys regularly if possible
  2. Error handling
    • Implement proper logging
    • Handle network timeouts
    • Provide clear error messages
  3. Validation timing
    • Validate on resource start
    • Implement periodic validation if needed
    • Use reasonable retry intervals

Common issues and solutions

Network connectivity problems

Invalid license format

Failed validation response