Complete Lua Example
Full example of integrating license verification in a FiveM resource with proper error handling.
-- server.lua
-- Replace '123456' with your actual 6-digit file code from dashboard
local FILE_CODE = "123456" -- Your file code from https://vf1.host/dashboard
Citizen.CreateThread(function()
Citizen.Wait(2000) -- Wait for server to fully start
PerformHttpRequest("https://vf1.host/api/verify/" .. FILE_CODE, function (err, text, head)
if err ~= 200 then
print("^1[License] Error connecting to license server")
return
end
if string.match(text, "Sorry,") then
print("^1[License] Invalid license: " .. text)
print("^1[License] Stopping resource...")
Citizen.Wait(2000)
StopResource(GetCurrentResourceName())
else
print("^2[License] License verified successfully!")
print("^2[License] Resource is now active!")
-- Your script code here
end
end, 'GET', '')
end)
Client-Side Verification
Example of verifying license on client-side (less secure, but useful for UI checks).
-- client.lua
local FILE_CODE = "123456"
Citizen.CreateThread(function()
PerformHttpRequest("https://vf1.host/api/verify/" .. FILE_CODE, function (err, text, head)
if text == "Valid" then
-- License is valid, show UI or enable features
TriggerEvent('license:verified')
else
-- License invalid, show error message
TriggerEvent('license:invalid', text)
end
end, 'GET', '')
end)
-- Listen for license verification
RegisterNetEvent('license:verified')
AddEventHandler('license:verified', function()
print("License verified on client!")
-- Enable client features
end)
Resource Startup Check
Best practice: Check license when resource starts and stop if invalid.
-- server.lua
local FILE_CODE = "123456"
local licenseVerified = false
-- Check license on resource start
Citizen.CreateThread(function()
PerformHttpRequest("https://vf1.host/api/verify/" .. FILE_CODE, function (err, text, head)
if text == "Valid" then
licenseVerified = true
print("^2[License] Verified - Resource active")
else
print("^1[License] Invalid - Stopping resource")
Citizen.Wait(2000)
StopResource(GetCurrentResourceName())
end
end, 'GET', '')
end)
-- Protect your events
RegisterNetEvent('your:event')
AddEventHandler('your:event', function()
if not licenseVerified then
return -- Don't process if license not verified
end
-- Your event code here
end)