Troubleshooting
Common issues and solutions for QBCore framework.
This guide covers common issues encountered when working with QBCore framework and their solutions.
Installation Issues
Database Connection Problems
Error: "Access denied for user"
Symptoms:
Solutions:
- Check Database Credentials:
- Verify Connection String:
- Check MySQL Service:
Error: "Database 'qbcore_server' doesn't exist"
Solution:
Resource Loading Issues
Error: "Resource [qb-core] couldn't be started"
Symptoms:
Solutions:
- Check Resource Path:
- Verify fxmanifest.lua:
- Check Dependencies:
Error: "Script timeout"
Symptoms:
Solutions:
- Check for Infinite Loops:
- Database Connection Issues:
Player Data Issues
Player Data Not Loading
Error: "Player data is nil"
Symptoms:
- Player spawns but has no data
- Commands don't work
- Money/job shows as nil
Solutions:
- Check Player Loading Events:
- Verify Database Schema:
- Check for Database Corruption:
Error: "Player already exists"
Symptoms:
- Cannot create new character
- Gets stuck on character creation
Solutions:
- Check for Duplicate Licenses:
- Clear Character Data:
Money/Job Issues
Error: "Money is not updating"
Solutions:
- Check Money Format:
- Check Money Functions:
Error: "Job permissions not working"
Solutions:
- Verify Job Data:
- Check Job Configuration:
Resource-Specific Issues
Inventory Issues
Error: "Items not showing in inventory"
Solutions:
- Check Item Registration:
- Verify Item Images:
- Check Inventory Database:
Error: "Cannot use items"
Solutions:
- Register Item Usage:
- Check Item Metadata:
Vehicle Issues
Error: "Vehicles not spawning"
Solutions:
- Check Vehicle Hash:
- Check Vehicle Database:
- Vehicle Keys Issues:
Phone/UI Issues
Error: "Phone not opening"
Solutions:
- Check Resource Dependencies:
- Check Phone Item:
- UI/NUI Issues:
Performance Issues
High Resource Usage
Server Performance Problems
Symptoms:
- High CPU usage
- Lag/stuttering
- Thread hitches
Solutions:
- Identify Resource Usage:
- Optimize Database Queries:
- Reduce Timer Frequency:
Memory Leaks
Increasing Memory Usage
Solutions:
- Check for Event Listeners:
- Clear References:
Debug Techniques
Logging and Debugging
Enable Debug Mode
Database Debugging
Console Commands for Debugging
Common Error Messages
Script Errors
Error | Cause | Solution |
---|---|---|
attempt to index a nil value | Variable not initialized | Check if variable exists before using |
attempt to call a nil value | Function doesn't exist | Verify function name and exports |
bad argument #1 to 'pairs' | Trying to iterate nil value | Check if table exists before iteration |
string expected, got nil | Passing nil to string function | Validate input parameters |
Database Errors
Error | Cause | Solution |
---|---|---|
Table doesn't exist | Missing database table | Import SQL files |
Column doesn't exist | Database schema mismatch | Update database schema |
Duplicate entry | Trying to insert duplicate key | Use UPDATE or INSERT IGNORE |
Data too long | Value exceeds column length | Increase column size |
Prevention Best Practices
Code Quality
- Always Check for Nil:
- Use Error Handling:
- Validate Inputs:
Testing
- Test with Multiple Players
- Test Resource Restart
- Test Database Disconnection
- Test Invalid Inputs
- Monitor Resource Usage
Monitoring
- Regular Database Backups
- Monitor Server Performance
- Check Error Logs
- Update Dependencies
Regular maintenance and monitoring can prevent most issues before they become problems.
Always test changes on a development server before applying to production.