Compatibility Checker
The QBCore Compatibility Checker is a comprehensive tool that analyzes your resources and server setup to identify compatibility issues before and after migrations. It helps prevent problems by detecting outdated code patterns, deprecated functions, and configuration conflicts.
Overview
The compatibility checker performs static code analysis on your QBCore resources to identify:
- Deprecated functions and outdated API calls
- Breaking changes that need attention
- Configuration conflicts between resources
- Event system incompatibilities
- Database schema mismatches
- Version dependency conflicts
π‘ Pro Tip
Run the compatibility checker before any major update to identify issues early and plan your migration strategy accordingly.
Installation
Download Compatibility Checker
# Clone the compatibility checker tool
git clone https://github.com/qbcore-framework/qb-compatibility-checker.git
cd qb-compatibility-checker
# Install dependencies
npm install
# or
pip install -r requirements.txt # If using Python versionConfiguration
# Copy example configuration
cp config.example.json config.json
# Edit configuration
nano config.json{
"server_path": "/path/to/your/fivem/server",
"resources_path": "resources/[qb]",
"qbcore_version": "2.0.0",
"target_version": "2.1.0",
"checks": {
"deprecated_functions": true,
"event_compatibility": true,
"config_conflicts": true,
"database_schema": true,
"dependency_versions": true
},
"exclude_resources": [
"resource-to-ignore"
],
"output_format": "json"
}Usage
Quick Compatibility Check
# Run basic compatibility check
./check-compatibility.sh
# Check specific resource
./check-compatibility.sh --resource qb-inventory
# Check for specific version migration
./check-compatibility.sh --from v1.0 --to v2.0
# Generate detailed report
./check-compatibility.sh --detailed --output report.jsonAdvanced Usage
# Check only deprecated functions
./check-compatibility.sh --check deprecated-functions
# Check configuration conflicts
./check-compatibility.sh --check config-conflicts
# Check database compatibility
./check-compatibility.sh --check database-schema
# Batch check multiple servers
./check-compatibility.sh --batch servers.listCompatibility Checks
1. Deprecated Functions Check
Identifies outdated function calls that need updating:
# Example output
Deprecated Functions Found:
==========================
Resource: qb-inventory
βββ File: server/main.lua:45
β βββ QBCore.Functions.GetRPName(source)
β β Replace with: Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname
β
βββ File: client/main.lua:123
β βββ TriggerEvent('QBCore:PlayerLoaded')
β β Replace with: RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
Resource: qb-customs
βββ File: server/server.lua:67
β βββ Player.PlayerData.money['cash']
β β Replace with: Player.Functions.GetMoney('cash')Custom Deprecated Function Patterns
Create custom patterns to check for:
{
"custom_patterns": [
{
"pattern": "QBConfig\\.",
"replacement": "Config.",
"severity": "high",
"description": "QBConfig namespace changed to Config in v2.0"
},
{
"pattern": "\\.PlayerData\\.money\\['(\\w+)'\\]",
"replacement": ".Functions.GetMoney('$1')",
"severity": "critical",
"description": "Direct money access deprecated, use GetMoney function"
}
]
}2. Event System Compatibility
Checks for event name changes and registration patterns:
# Event Compatibility Report
Event System Issues:
===================
Resource: qb-ambulancejob
βββ Deprecated Event: 'QBCore:PlayerLoaded'
β βββ Found in: client/main.lua:15
β βββ Replace with: 'QBCore:Client:OnPlayerLoaded'
β
βββ Missing Event Handler: 'QBCore:Client:OnPlayerUnload'
β βββ Should handle player logout in: client/main.lua
β
βββ Event Parameter Mismatch: 'hospital:client:Revive'
βββ Expected 2 parameters, found 1 in: server/main.lua:234Event Migration Mapping
{
"event_mappings": {
"QBCore:PlayerLoaded": "QBCore:Client:OnPlayerLoaded",
"QBCore:PlayerLogout": "QBCore:Client:OnPlayerUnload",
"QBCore:PlayerMoneyChanged": "QBCore:Client:OnMoneyChange",
"QBCore:ClientJobUpdate": "QBCore:Client:OnJobUpdate"
}
}3. Configuration Conflicts
Detects configuration inconsistencies and conflicts:
# Configuration Conflicts
Config Issues Found:
===================
Global Conflicts:
βββ qb-inventory & qb-shops both define 'UseTarget = false'
β βββ May cause targeting conflicts
β
βββ qb-garages & qb-apartments both use spawn location vector4(123, 456, 78, 90)
β βββ Overlapping spawn points detected
β
Resource-specific Issues:
βββ qb-fuel: Missing required config option 'PumpModels'
βββ qb-banking: Deprecated config option 'UseOldBanking' should be removed
βββ qb-phone: Config version mismatch - using v1.5 format in v2.0 resourceConfiguration Schema Validation
{
"config_schemas": {
"qb-inventory": {
"required_fields": ["MaxInventoryWeight", "MaxDropDistance"],
"deprecated_fields": ["UseOldInventory", "LegacyMode"],
"version_requirements": {
"min_version": "2.0.0",
"config_version": "2.1"
}
}
}
}4. Database Schema Compatibility
Validates database structure against QBCore requirements:
# Database Schema Check
Database Compatibility:
======================
Missing Tables:
βββ player_outfits (Required for qb-clothing v2.0+)
βββ player_phone_messages (Required for qb-phone v2.0+)
Missing Columns:
βββ players.phone_number (Required for v2.0)
βββ players.metadata (Required for v2.0)
βββ player_vehicles.metadata (Required for enhanced vehicle system)
Index Recommendations:
βββ CREATE INDEX idx_phone_number ON players (phone_number);
βββ CREATE INDEX idx_citizenid ON player_vehicles (citizenid);
Data Format Issues:
βββ 15 players with invalid JSON in 'money' column
βββ 3 players with NULL metadata (should be '{}')Schema Validation Rules
-- schema-validation.sql
-- Define expected database structure
-- Required tables for QBCore v2.0+
CREATE TABLE IF NOT EXISTS schema_requirements (
table_name VARCHAR(64),
column_name VARCHAR(64),
data_type VARCHAR(32),
is_nullable BOOLEAN,
default_value TEXT,
version_required VARCHAR(10)
);
INSERT INTO schema_requirements VALUES
('players', 'phone_number', 'VARCHAR(20)', true, NULL, '2.0.0'),
('players', 'metadata', 'LONGTEXT', true, '{}', '2.0.0'),
('player_outfits', 'id', 'INT', false, NULL, '2.0.0');5. Dependency Version Analysis
Checks resource dependencies and version compatibility:
# Dependency Analysis
Dependency Issues:
=================
Version Conflicts:
βββ qb-inventory requires qb-core ^2.0.0, found 1.9.5
βββ qb-phone requires qb-inventory ^2.1.0, found 2.0.3
βββ custom-banking requires qb-banking 1.x, but v2.0 installed
Missing Dependencies:
βββ qb-customs requires ox_lib (not installed)
βββ qb-racing requires qb-phone v2.0+ (v1.5 found)
Resource Compatibility Matrix:
βββββββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ
β Resource β Current β Required β Compatible β
βββββββββββββββββββΌββββββββββββββΌββββββββββββββΌββββββββββββββ€
β qb-core β 2.0.0 β - β β β
β qb-inventory β 2.1.0 β qb-core^2.0 β β β
β qb-phone β 1.9.0 β qb-core^2.0 β β β
β custom-banking β 1.0.0 β qb-core^1.0 β β β
βββββββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ΄ββββββββββββββAutomated Fix Suggestions
Auto-Fix Common Issues
The compatibility checker can automatically fix some common issues:
# Apply automatic fixes (creates backup first)
./check-compatibility.sh --auto-fix --backup
# Preview fixes without applying
./check-compatibility.sh --auto-fix --dry-run
# Fix specific types of issues
./check-compatibility.sh --auto-fix deprecated-functionsAuto-Fix Rules
{
"auto_fixes": [
{
"name": "Update Config Namespace",
"find": "QBConfig\\.",
"replace": "Config.",
"files": ["**/config*.lua"],
"backup": true
},
{
"name": "Update Money Access",
"find": "Player\\.PlayerData\\.money\\['(\\w+)'\\]",
"replace": "Player.Functions.GetMoney('$1')",
"files": ["**/*.lua"],
"manual_review": true
},
{
"name": "Update Event Names",
"mappings": {
"QBCore:PlayerLoaded": "QBCore:Client:OnPlayerLoaded",
"QBCore:PlayerLogout": "QBCore:Client:OnPlayerUnload"
},
"files": ["**/*.lua"]
}
]
}Custom Compatibility Rules
Create Custom Rules
Define project-specific compatibility rules:
{
"custom_rules": [
{
"id": "custom_money_system",
"name": "Custom Money System Check",
"description": "Check for custom money system compatibility",
"pattern": "customMoney\\.|CustomBanking\\.",
"severity": "warning",
"message": "Custom money system detected - verify compatibility with QBCore v2.0",
"files": ["**/*.lua"]
},
{
"id": "third_party_inventory",
"name": "Third-party Inventory Check",
"description": "Detect third-party inventory systems",
"files": ["**/inventory/**/*.lua"],
"exclude_patterns": ["qb-inventory"],
"severity": "info",
"message": "Third-party inventory system detected - ensure compatibility"
}
]
}Rule Testing
# Test custom rules
./check-compatibility.sh --test-rules custom_rules.json
# Validate rule syntax
./check-compatibility.sh --validate-rules
# Debug rule matching
./check-compatibility.sh --debug-rules custom_money_systemIntegration with CI/CD
GitHub Actions Integration
# .github/workflows/compatibility-check.yml
name: QBCore Compatibility Check
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
compatibility-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Compatibility Checker
run: |
git clone https://github.com/qbcore-framework/qb-compatibility-checker.git
cd qb-compatibility-checker
npm install
- name: Run Compatibility Check
run: |
cd qb-compatibility-checker
./check-compatibility.sh --server-path ../ --output ../compatibility-report.json
- name: Upload Results
uses: actions/upload-artifact@v2
with:
name: compatibility-report
path: compatibility-report.json
- name: Comment PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const report = JSON.parse(fs.readFileSync('compatibility-report.json', 'utf8'));
let comment = '## π Compatibility Check Results\n\n';
if (report.issues.length === 0) {
comment += 'β
No compatibility issues found!';
} else {
comment += `β οΈ Found ${report.issues.length} compatibility issues:\n\n`;
report.issues.forEach(issue => {
comment += `- **${issue.severity}**: ${issue.message}\n`;
});
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});Pre-commit Hook
#!/bin/bash
# .git/hooks/pre-commit
echo "Running QBCore compatibility check..."
# Run compatibility check on staged files
if ! ./tools/check-compatibility.sh --staged-only --quiet; then
echo "β Compatibility issues found. Please fix before committing."
echo "Run './tools/check-compatibility.sh --staged-only' for details."
exit 1
fi
echo "β
Compatibility check passed."Reporting and Analysis
Generate Detailed Reports
# Generate comprehensive report
./check-compatibility.sh --report-format html --output compatibility-report.html
# Generate JSON report for processing
./check-compatibility.sh --report-format json --output report.json
# Generate executive summary
./check-compatibility.sh --summary --email admin@yourserver.comReport Formats
HTML Report Example
<!DOCTYPE html>
<html>
<head>
<title>QBCore Compatibility Report</title>
</head>
<body>
<h1>Compatibility Analysis Summary</h1>
<div class="summary">
<h2>Overall Score: 78/100</h2>
<p>Status: <span class="warning">Needs Attention</span></p>
</div>
<div class="issues">
<h2>Critical Issues (2)</h2>
<ul>
<li>qb-inventory: Deprecated money access pattern</li>
<li>qb-phone: Missing required database table</li>
</ul>
</div>
</body>
</html>JSON Report Structure
{
"timestamp": "2024-01-15T10:30:00Z",
"server_info": {
"qbcore_version": "2.0.0",
"total_resources": 45,
"checked_resources": 42
},
"summary": {
"compatibility_score": 78,
"total_issues": 15,
"critical_issues": 2,
"warnings": 8,
"info": 5
},
"issues": [
{
"severity": "critical",
"category": "deprecated_functions",
"resource": "qb-inventory",
"file": "server/main.lua",
"line": 45,
"message": "Direct money access deprecated",
"suggestion": "Use Player.Functions.GetMoney('cash')",
"auto_fixable": true
}
],
"recommendations": [
"Update qb-phone to version 2.0+",
"Run database migration script",
"Review custom resources for compatibility"
]
}Troubleshooting
Common Issues
Issue: βPermission denied when accessing resourcesβ
# Fix file permissions
chmod +x check-compatibility.sh
chmod -R 755 /path/to/fivem/resourcesIssue: βDatabase connection failedβ
# Test database connection
mysql -h localhost -u username -p database_name -e "SELECT 1;"
# Update database credentials in config.jsonIssue: βFalse positive deprecated function warningsβ
{
"whitelist": [
{
"pattern": "Player.PlayerData.money",
"reason": "Custom implementation maintains compatibility",
"resources": ["custom-banking"]
}
]
}Performance Optimization
For large servers with many resources:
# Use parallel processing
./check-compatibility.sh --parallel 4
# Skip large files
./check-compatibility.sh --skip-large-files
# Cache results
./check-compatibility.sh --cache-results
# Incremental checking
./check-compatibility.sh --incremental --since last-checkβ οΈ Important Notes
- β’ Compatibility checking is advisory - manual testing is still required
- β’ Auto-fixes create backups, but verify changes before going live
- β’ Some compatibility issues may only appear at runtime
- β’ Custom resources may have unique compatibility requirements