NR_PawnShop
A simple and efficient pawn shop script for QBX/QBCore that allows players to sell items to an NPC vendor for cash.
Features
- Interactive NPC vendor - Static ped at a configurable location with clipboard animation
- Map blip - Customizable blip marking the pawn shop location
- ox_target integration - Clean third-eye interaction system for selling items
- ox_inventory compatible - Full integration with ox_inventory
- Dynamic menu system - Context menu showing available items with prices and quantities
- Input validation - Comprehensive server-side checks to prevent exploits
- Configurable pricing - Easy-to-edit item prices in the config
- Visual feedback - Clear notifications for all transactions
Dependencies
| Resource | Description | Required |
|---|---|---|
| qbx_core | Core framework | Yes |
| ox_lib | UI library (context menus, input dialogs) | Yes |
| ox_target | Interaction system | Yes |
| ox_inventory | Inventory system | Yes |
Installation
Step 1: Download
Download NR_PawnShop and extract it to your resources folder:
server/
└── resources/
└── [nightrider]/
└── NR_PawnShop/
Step 2: server.cfg
Add the resource to your server configuration:
ensure NR_PawnShop
Step 3: Configuration
Configure the location, ped model, and item prices in cl_main.lua.
Step 4: Restart
Restart your server to load the resource.
Make sure qbx_core, ox_lib, ox_target, and ox_inventory are all started before NR_PawnShop in your server.cfg.
How It Works
1. Finding the Shop
A blip appears on the map marking the pawn shop location (default: near Grove Street). Players navigate to the location and find an NPC vendor.
2. Opening the Menu
Approach the NPC and use ox_target (third eye) to interact. Select "Sell Items" from the target menu.
3. Selecting Items
A context menu opens showing all sellable items currently in the player's inventory. Each item displays the item name, price per unit, and quantity owned.
4. Selling
Click on an item to sell. An input dialog appears asking how many to sell, showing the available quantity and price per unit. Enter the amount and confirm.
5. Transaction Complete
Items are removed from inventory, cash is added to the player's account, and a success notification shows the total amount earned.
Configuration
Location & NPC Settings
PedLocation = vec4(149.25, -1714.29, 29.32, 140.29) -- x, y, z, heading
PedModel = 'a_m_m_business_01' -- Ped model hash
Blip Customization
BlipSprite = 605 -- Blip icon ID
BlipScale = 0.7 -- Blip size
BlipColor = 2 -- Blip color (2 = green)
BlipName = "Pawn Shop" -- Label on map
Item Pricing
Edit the Items table in the config to add/remove items or change prices:
Items = {
['itemname'] = price,
['goldbar'] = 10000,
['diamond'] = 3000,
-- Add custom items here
}
Supported item categories:
- Car jacking loot (batteries, subwoofers, phones, laptops)
- Jewelry (rings, necklaces, watches, bracelets)
- Heist items (art pieces, thermite, crew USB)
- Mansion/house robbery loot (laptops, electronics)
- Valuables (gold bars, diamonds, skulls)
- Miscellaneous (documents, keys, checkbooks)
Customization
Changing the Ped Model
Update PedModel with any valid ped model:
PedModel = 's_m_y_dealer_01' -- Drug dealer appearance
PedModel = 'a_m_m_hillbilly_01' -- Hillbilly appearance
PedModel = 'g_m_m_chigoon_01' -- Chinese gangster
Modifying Ped Animation
In the ped spawn thread, change the scenario:
TaskStartScenarioInPlace(StorePed, "WORLD_HUMAN_SMOKING", 0, true) -- Smoking
TaskStartScenarioInPlace(StorePed, "WORLD_HUMAN_STAND_IMPATIENT", 0, true) -- Impatient
Changing Payment Method
Modify the server event to pay differently:
-- Current: Pays in cash
Player.Functions.AddMoney('cash', totalPrice)
-- Alternative: Pay to bank
Player.Functions.AddMoney('bank', totalPrice)
-- Alternative: Split payment
Player.Functions.AddMoney('cash', totalPrice * 0.7)
Player.Functions.AddMoney('bank', totalPrice * 0.3)
Security Features
Client-Side Validation
- Checks if player has items before showing in menu
- Validates quantity input against inventory
- Ensures minimum/maximum ranges for input
- Prevents invalid data types
Server-Side Validation
- Parameter type checking - Validates itemName (string), amount (number), price (number)
- Inventory verification - Double-checks item count via
ox_inventory:GetItemCount() - Amount validation - Ensures player has sufficient quantity
- Transaction atomicity - Items removed before money added
Performance
| Metric | Value |
|---|---|
| Resmon impact | ~0.00ms (idle), ~0.01ms (menu open) |
| Network traffic | Minimal (only on transactions) |
| Database queries | None (uses ox_inventory queries) |
| Threads | 3 total (blip, ped spawn, ox_target setup) |
Troubleshooting
Ped not spawning
- Verify coordinates are correct
- Check if ped model exists
- Ensure ox_target is running
Items not showing in menu
- Confirm item names match ox_inventory item names exactly
- Check if items are in the Items table in config
- Verify player actually has items in inventory
Can't interact with ped
- Make sure ox_target is started before this resource
- Check for console errors
- Verify ped exists with
/getcoordsnear the location
Transaction failing
- Check server console for validation errors
- Ensure ox_inventory is functioning
- Verify player has sufficient items
Menu not opening
- Confirm ox_lib is loaded
- Check for client-side errors in F8 console
- Verify qbx_core notifications are working
Support
Need help? Join our Discord server for community support and updates.