How It Works
System Architecture
The GOD - Nail Trap System operates through a client-server architecture that ensures synchronized nail placement and damage detection across all players.
Core Mechanics
1. Nail Deployment
Single Nail (screw_nail)
When a player uses a single nail item:
On Foot:
Player performs a planting animation
Progress bar displays: "Planting Nails On Ground...."
Nail is placed directly at player's current position
Item is consumed from inventory
In Vehicle:
Player performs a throwing animation
Progress bar displays: "Throwing Nails On Ground...."
Nail is spawned forward from player's position based on heading
Perfect for pursuits: Illegal players can throw nails out the window while driving to disable pursuing police vehicles
Nails land behind the throwing vehicle, ready to puncture tires of following vehicles
Item is consumed from inventory
Nail Package (nailspackage)
When a player uses a nail package:
Interactive mode activates with on-screen instructions
Player can press
E(INPUT_CONTEXT) to place nails repeatedlyMaximum of 20 nails can be placed per package
Each placement uses a placement animation
Player can cancel with
BACKSPACE(INPUT_CELLPHONE_CANCEL)Package is consumed after completion or cancellation
2. Nail Synchronization
Server-Side:
All nail positions are stored in a server-side table (
nails)Each nail receives a unique ID based on table length
When a nail is placed, all clients receive synchronization event
When a nail is removed, all clients are notified
Client-Side:
Clients maintain a local table of nail objects
On player load, client requests current nail positions from server
Nail objects are created using a custom prop model
Objects are frozen in place after physics activation
3. Nail Object Creation
When a nail is synchronized to a client:
Object Creation: Custom prop model is spawned at coordinates
Physics Activation: Entity physics are activated for proper placement
Ground Alignment: Object is properly aligned with the ground surface
Freezing: Object is frozen after a short delay to prevent movement
Targeting: Interaction option is added for nail removal
Cleanup Timer: Automatic removal timer starts (configurable duration)
4. Tire Damage Detection
The system continuously monitors vehicles for nail contact:
Detection Loop:
Runs while player is in a vehicle seat
Checks all nails within 10 units of vehicle
For each nail, checks all 6 wheel positions:
wheel_lf(Left Front) - Index 0wheel_rf(Right Front) - Index 1wheel_lm(Left Middle) - Index 2wheel_rm(Right Middle) - Index 3wheel_lr(Left Rear) - Index 4wheel_rr(Right Rear) - Index 5
Damage Calculation:
Distance threshold: 0.5 units between tire bone and nail position
Damage is tracked per vehicle plate and tire index
Each nail contact adds
DamagePerNailpercentage (default: 33.335%)When damage reaches 100%, tire bursts instantly
Nail is deleted upon contact to prevent multiple hits
Damage Tracking:
Vehicle damage is stored per plate number
Prevents same nail from damaging tire multiple times
Resets when vehicle is destroyed or player leaves
5. Nail Removal
Players can remove deployed nails:
Targeting Interaction: "Remove Nails" option appears when targeting nail
Animation: Planting animation plays during removal
Progress Bar: "Taking Out Nails From Ground...." displays
Item Return: Player receives
screw_nailitem backSynchronization: All clients are notified of removal
6. Automatic Cleanup
Timer-Based Removal:
Each nail has an automatic cleanup timer
Default duration: 10 minutes (configurable in
J0.NailsCfg.CleanUp)Timer starts when nail is created
On expiration: nail object is deleted and server is notified
Prevents server memory buildup from abandoned nails
Resource Stop Cleanup:
When resource stops, all client-side nail objects are deleted
Prevents orphaned objects in the game world
Framework Integration
QBCore / Qbox
Uses
qb-coreexports for core objectCreateUseableItemfor item usage registrationFunctions.Notifyfor notificationsFunctions.AddItem/Functions.RemoveItemfor inventory
ESX
Uses
es_extendedexports for core objectlib.notifyfor notifications (via ox_lib)Custom inventory functions via server events
Inventory Integration
ox_inventory
Uses export functions:
exports.ox_inventory:AddItem/RemoveItemClient-side export:
J0-nailScript.useNail/useNailPackageItem configuration in
data/items.lua
qb-inventory
Uses framework functions:
Functions.AddItem/RemoveItemServer-side useable item registration
Item configuration in
shared/items.lua
Targeting Integration
ox_target
exports.ox_target:addLocalEntity()for nail interactionexports.ox_target:removeLocalEntity()for cleanup
qb-target
exports['qb-target']:AddTargetEntity()for interactionexports['qb-target']:RemoveTargetEntity()for cleanup
interact
exports.interact:AddLocalEntityInteraction()for interactionexports.interact:RemoveLocalEntityInteraction()for cleanup
Pursuit Escape Mechanics
Vehicle-Based Nail Deployment
One of the most exciting features for illegal roleplay is the ability to throw nails from a moving vehicle:
How It Works:
Detection: System detects when player is inside a vehicle
Throwing Animation: Player performs throwing animation
Forward Placement: Nail is calculated forward from player's position based on vehicle heading
Landing: Nail lands on the road surface behind the throwing vehicle
Pursuit Defense: Any vehicle following behind (police, rivals, etc.) will drive over the nail
Tire Damage: When pursuing vehicle's wheels contact the nail, progressive damage is applied
Strategic Use:
Illegal Players: Perfect for escaping police chases by disabling pursuing vehicles
High-Speed Chases: Throw nails while maintaining speed to create distance
Multiple Pursuers: Deploy multiple nails to disable multiple pursuing vehicles
Tactical Placement: Time your throws to maximize effectiveness
Mechanics:
Nail spawns based on vehicle's current heading (direction of travel)
Forward offset ensures nail lands behind the vehicle
Physics-based placement ensures nail stays on road surface
Works at any speed - nail placement is instant
Performance Optimization
Efficient Loops: Damage detection uses optimized distance checks
Conditional Updates: Only processes nails within range (10 units)
Memory Management: Automatic cleanup prevents object accumulation
Network Optimization: Minimal server events, efficient synchronization
Collision Optimization: Precise distance thresholds (0.5 units)
Technical Specifications
Update Rate: Damage detection runs at optimized intervals while in vehicle
Sync Range: Configurable radius for damage detection
Contact Threshold: Precise distance threshold for tire-to-nail contact
Forward Distance: Calculated forward offset for vehicle nail throwing
Physics Delay: Short delay before freezing nail object for proper placement
This system provides a realistic and performant solution for road spike deployment in FiveM roleplay servers.
Last updated