Add FiveM resources and templates for documentation and code snippets

- Introduced a new code snippets resource for common FiveM patterns in Lua and JavaScript.
- Added a framework comparison document outlining Standalone, ESX, and QBCore features.
- Created search results view for FiveM documentation queries.
- Developed client and server template scripts for ESX and QBCore frameworks.
- Implemented NUI templates including HTML, CSS, and JavaScript for user interfaces.
- Established routes for documentation and console commands.
- Added tests for various features including documentation routes and tool functionalities.
- Configured Vite for asset management with Laravel.
- Updated .gitignore files for storage and framework directories.
This commit is contained in:
Adrian Mejias committed 2026-02-28 21:53:04 -06:00
1 parent 41e89d9023
commit d3d1f5fdb3
112 files changed
+51106

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
FiveM Events Reference
==================================================
@foreach($eventsByType as $type => $events)
{{ strtoupper($type) }} EVENTS:
@foreach($events as $event)
• {{ $event['name'] }} - {{ $event['description'] }}
@endforeach
@endforeach
@@ -0,0 +1,30 @@
Event: {{ $event['name'] }}
==================================================
Type: {{ $event['type'] }}
Side: {{ $event['side'] }}
Description:
{{ $event['description'] }}
@if(!empty($event['parameters']))
Parameters:
@foreach($event['parameters'] as $param)
• {{ $param['name'] }} ({{ $param['type'] }}): {{ $param['description'] }}
@endforeach
@endif
@php
$exampleKey = $language === 'js' ? 'js_example' : 'lua_example';
$langName = $language === 'js' ? 'JavaScript' : 'Lua';
@endphp
@if(isset($event[$exampleKey]))
{{ $langName }} Example:
```{{ $language }}
{{ $event[$exampleKey] }}
```
@endif
@if(isset($event['documentation']))
Documentation: {{ $event['documentation'] }}
@endif
@@ -0,0 +1,32 @@
Native Function: {{ $native['name'] }}
==================================================
Namespace: {{ $native['namespace'] }}
Description:
{{ $native['description'] }}
@if(!empty($native['parameters']))
Parameters:
@foreach($native['parameters'] as $param)
• {{ $param['name'] }} ({{ $param['type'] }}): {{ $param['description'] }}
@endforeach
@endif
Returns: {{ $native['returns']['type'] }}
@if($native['returns']['description'] !== 'No return value')
{{ $native['returns']['description'] }}
@endif
@php
$exampleKey = $language === 'js' ? 'js_example' : 'lua_example';
$langName = $language === 'js' ? 'JavaScript' : 'Lua';
@endphp
@if(isset($native[$exampleKey]))
{{ $langName }} Example:
```{{ $language }}
{{ $native[$exampleKey] }}
```
@endif
Documentation: https://docs.fivem.net/natives/?_{{ $native['name'] }}
@@ -0,0 +1,11 @@
FiveM Resource Boilerplate: {{ $resourceName }}
==================================================
Generated files:
@foreach($files as $filename => $content)
📄 {{ $filename }}
--------------------------------------------------
{{ $content }}
@endforeach
@@ -0,0 +1,258 @@
# FiveM Development Best Practices
## Performance Optimization
### 1. Use Citizen.Wait() Efficiently
**Bad:**
```lua
Citizen.CreateThread(function()
while true do
Citizen.Wait(0) -- Runs every frame!
-- Code that doesn't need to run every frame
end
end)
```
**Good:**
```lua
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000) -- Runs once per second
-- Code here
end
end)
```
### 2. Avoid GetPlayerPed(-1) in Loops
**Bad:**
```lua
while true do
local ped = GetPlayerPed(-1) -- Called every iteration
local coords = GetEntityCoords(ped)
Citizen.Wait(0)
end
```
**Good:**
```lua
local ped = PlayerPedId() -- Cache outside loop
while true do
local coords = GetEntityCoords(ped)
Citizen.Wait(0)
end
```
### 3. Use Distance Checks Before Expensive Operations
```lua
local myCoords = GetEntityCoords(PlayerPedId())
local distance = #(myCoords - targetCoords)
if distance < 100.0 then
-- Only do expensive operations when close
DrawMarker(...)
end
```
### 4. Batch Database Queries
**Bad:**
```lua
for _, player in pairs(players) do
MySQL.Async.fetchAll('SELECT * FROM users WHERE id = @id', {
['@id'] = player.id
})
end
```
**Good:**
```lua
local ids = {}
for _, player in pairs(players) do
table.insert(ids, player.id)
end
MySQL.Async.fetchAll('SELECT * FROM users WHERE id IN (@ids)', {
['@ids'] = table.concat(ids, ',')
})
```
## Security Best Practices
### 1. Always Validate Server Events
```lua
RegisterNetEvent('myresource:giveMoney', function(amount)
local _source = source
-- Validate source
if not _source or _source < 1 then return end
-- Validate amount
if type(amount) ~= 'number' or amount <= 0 or amount > 10000 then
print(('Invalid amount from player %s'):format(_source))
return
end
-- Process only after validation
Player(_source).addMoney(amount)
end)
```
### 2. Never Trust Client Data
- All game-changing logic should be on the server
- Validate all client requests
- Use server-side checks for important operations
### 3. Don't Expose Admin Events
**Bad:**
```lua
RegisterNetEvent('admin:giveWeapon') -- Client can trigger!
```
**Good:**
```lua
-- Use server commands instead
RegisterCommand('giveweapon', function(source, args)
if IsPlayerAceAllowed(source, 'admin.weapons') then
-- Safe to execute
end
end, true)
```
## Code Organization
### 1. Use Config Files
```lua
-- config.lua
Config = {}
Config.MaxDistance = 100.0
Config.CheckInterval = 1000
Config.EnableDebug = false
-- client.lua
if distance < Config.MaxDistance then
-- Easy to tweak without touching logic
end
```
### 2. Modularize Your Code
```lua
-- utils.lua
function GetPlayerDistance(player1, player2)
local coords1 = GetEntityCoords(GetPlayerPed(player1))
local coords2 = GetEntityCoords(GetPlayerPed(player2))
return #(coords1 - coords2)
end
-- main.lua
local distance = GetPlayerDistance(source, target)
```
### 3. Use Proper Event Naming
```lua
-- Good naming convention
RegisterNetEvent('resourcename:category:action')
RegisterNetEvent('cardealer:purchase:vehicle')
RegisterNetEvent('banking:account:withdraw')
-- Avoid generic names
RegisterNetEvent('action') -- Too generic!
RegisterNetEvent('event1') -- Not descriptive!
```
## Resource Management
### 1. Clean Up After Yourself
```lua
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
-- Clean up threads, blips, entities, etc.
isRunning = false
RemoveBlip(myBlip)
DeleteEntity(myVehicle)
end
end)
```
### 2. Don't Create Unnecessary Entities
```lua
-- Delete vehicles when no longer needed
if DoesEntityExist(vehicle) then
DeleteEntity(vehicle)
end
-- Clean up peds
if DoesEntityExist(ped) then
DeletePed(ped)
end
```
### 3. Manage Network Ownership
```lua
-- Set network IDs for entities you want to sync
NetworkRegisterEntityAsNetworked(entity)
local netId = NetworkGetNetworkIdFromEntity(entity)
```
## Testing & Debugging
### 1. Use Conditional Debug Prints
```lua
if Config.Debug then
print(('[DEBUG] Player %s at coords: %s'):format(source, coords))
end
```
### 2. Error Handling
```lua
local success, error = pcall(function()
-- Code that might error
MySQL.Async.fetchAll(query)
end)
if not success then
print(('Error: %s'):format(error))
end
```
### 3. Use Convars for Configuration
```lua
-- Set in server.cfg
setr myresource:maxdistance "100"
-- Read in script
local maxDistance = GetConvarInt('myresource:maxdistance', 50)
```
## Framework-Specific Tips
### ESX
```lua
-- Always check if ESX is loaded
ESX = exports['es_extended']:getSharedObject()
-- Use ESX callbacks for server communication
ESX.TriggerServerCallback('myresource:getData', function(data)
print(data)
end)
```
### QBCore
```lua
-- Get QBCore object properly
local QBCore = exports['qb-core']:GetCoreObject()
-- Use QBCore functions
local Player = QBCore.Functions.GetPlayer(source)
if Player then
Player.Functions.AddMoney('cash', amount)
end
```
## Common Pitfalls
1. **Using GetPlayerPed(-1) instead of PlayerPedId()** - Less efficient
2. **Not cleaning up on resource restart** - Memory leaks
3. **Trusting client-side coordinates** - Security risk
4. **Running expensive operations every frame** - Performance issues
5. **Not validating server events** - Exploits waiting to happen
6. **Hardcoding values** - Use config files instead
7. **Not using exports properly** - Creates tight coupling
@@ -0,0 +1,178 @@
# Common FiveM Code Snippets
Quick reference for frequently used code patterns.
## Player Distance Check
### Lua
```lua
-- Check distance between two players
local ped1 = GetPlayerPed(source)
local ped2 = GetPlayerPed(targetPlayer)
local coords1 = GetEntityCoords(ped1)
local coords2 = GetEntityCoords(ped2)
local distance = #(coords1 - coords2)
if distance < 5.0 then
-- Players are close enough
end
```
### JavaScript
```javascript
// Check distance between two players
const ped1 = GetPlayerPed(source);
const ped2 = GetPlayerPed(targetPlayer);
const coords1 = GetEntityCoords(ped1, false);
const coords2 = GetEntityCoords(ped2, false);
const distance = Math.sqrt(
Math.pow(coords1[0] - coords2[0], 2) +
Math.pow(coords1[1] - coords2[1], 2) +
Math.pow(coords1[2] - coords2[2], 2)
);
if (distance < 5.0) {
// Players are close enough
}
```
## Safe Event Handler
### Lua
```lua
-- Server-side event with validation
RegisterNetEvent('myresource:doSomething', function(data)
local _source = source
-- Validate source
if not _source or _source < 1 then return end
-- Validate data
if type(data) ~= 'table' or not data.id then return end
-- Process event safely
print(('Player %s triggered event with ID: %s'):format(_source, data.id))
end)
```
### JavaScript
```javascript
// Server-side event with validation
onNet('myresource:doSomething', (data) => {
const _source = source;
// Validate source
if (!_source || _source < 1) return;
// Validate data
if (typeof data !== 'object' || !data.id) return;
// Process event safely
console.log(`Player ${_source} triggered event with ID: ${data.id}`);
});
```
## Thread with Cleanup
### Lua
```lua
-- Citizen thread with proper cleanup
local isRunning = true
Citizen.CreateThread(function()
while isRunning do
Citizen.Wait(0)
-- Your code here
if IsControlJustPressed(0, 38) then -- E key
print('E pressed!')
end
end
end)
-- Cleanup function
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
isRunning = false
end
end)
```
### JavaScript
```javascript
// SetInterval with cleanup
let isRunning = true;
const intervalId = setInterval(() => {
if (!isRunning) {
clearInterval(intervalId);
return;
}
// Your code here
if (IsControlJustPressed(0, 38)) { // E key
console.log('E pressed!');
}
}, 0);
// Cleanup
on('onResourceStop', (resource) => {
if (resource === GetCurrentResourceName()) {
isRunning = false;
}
});
```
## Database Query with Callback
### Lua
```lua
-- MySQL async query pattern
MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier', {
['@identifier'] = identifier
}, function(result)
if result[1] then
print(('Found user: %s'):format(result[1].name))
else
print('User not found')
end
end)
```
### JavaScript
```javascript
// oxmysql query pattern
const result = await exports.oxmysql.query('SELECT * FROM users WHERE identifier = ?', [identifier]);
if (result.length > 0) {
console.log(`Found user: ${result[0].name}`);
} else {
console.log('User not found');
}
```
## NUI Callback
### Lua
```lua
-- Client-side NUI callback handler
RegisterNUICallback('buttonClick', function(data, cb)
-- Process the callback
print(('Button clicked: %s'):format(data.button))
-- Send response back to NUI
cb({ success = true, message = 'Action completed' })
end)
```
### JavaScript
```javascript
// Client-side NUI callback handler
RegisterNUICallback('buttonClick', (data, cb) => {
// Process the callback
console.log(`Button clicked: ${data.button}`);
// Send response back to NUI
cb({ success: true, message: 'Action completed' });
});
```
@@ -0,0 +1,260 @@
# FiveM Framework Comparison
## Overview
| Feature | Standalone | ESX | QBCore |
|---------|-----------|-----|--------|
| **Complexity** | Low | Medium | Medium-High |
| **Player System** | None | Built-in | Built-in |
| **Inventory** | None | Basic | Advanced |
| **Database** | Optional | MySQL | MySQL/oxmysql |
| **Jobs** | Manual | Built-in | Built-in |
| **Community** | N/A | Large | Growing |
| **Learning Curve** | Easy | Moderate | Moderate-Hard |
## Standalone
### When to Use
- Simple resources (maps, MLOs, vehicles)
- Custom systems from scratch
- Learning FiveM basics
- No framework dependencies needed
### Pros
- Complete control
- No framework overhead
- Lightweight
- No version conflicts
### Cons
- Must build everything yourself
- No standardized player system
- Harder to integrate with other resources
- More initial work
### Example Code
```lua
-- No framework, direct natives
RegisterNetEvent('myresource:doSomething', function(data)
local ped = GetPlayerPed(source)
local coords = GetEntityCoords(ped)
TriggerClientEvent('myresource:response', source, {
success = true,
coords = coords
})
end)
```
## ESX (es_extended)
### When to Use
- Building roleplay servers
- Need player accounts/jobs/inventory
- Want established ecosystem
- Prefer simpler structure
### Pros
- Huge community and resources
- Lots of free scripts available
- Well-documented
- Mature and stable
- Simpler than QBCore
### Cons
- Older codebase
- Some performance issues
- Less modern features
- Can feel outdated
### Core Features
- Player accounts and identifiers
- Job system
- Basic inventory
- Money (cash, bank, black money)
- Vehicle ownership
- Society system (businesses)
### Example Code
```lua
-- Server-side ESX
ESX = exports['es_extended']:getSharedObject()
RegisterNetEvent('myresource:buyItem', function(itemName, amount)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.getMoney() >= price then
xPlayer.removeMoney(price)
xPlayer.addInventoryItem(itemName, amount)
end
end)
-- Client-side ESX
ESX = exports['es_extended']:getSharedObject()
RegisterNetEvent('esx:playerLoaded', function(playerData)
PlayerData = playerData
end)
```
### Common ESX Functions
```lua
-- Server-side
xPlayer.getMoney()
xPlayer.addMoney(amount)
xPlayer.removeMoney(amount)
xPlayer.getAccount(account).money
xPlayer.addAccountMoney(account, amount)
xPlayer.removeAccountMoney(account, amount)
xPlayer.getInventoryItem(item)
xPlayer.addInventoryItem(item, count)
xPlayer.removeInventoryItem(item, count)
xPlayer.getJob()
xPlayer.setJob(job, grade)
-- Client-side
ESX.ShowNotification(msg)
ESX.UI.Menu.Open(type, namespace, name, data, submit, cancel)
ESX.Game.SpawnVehicle(model, coords, heading, cb)
ESX.Game.DeleteVehicle(vehicle)
```
## QBCore (qb-core)
### When to Use
- Modern roleplay servers
- Need advanced features
- Want active development
- Prefer modular design
### Pros
- Modern codebase
- Active development
- Advanced inventory
- Better performance optimization
- More features out of box
- Flexible metadata system
### Cons
- Steeper learning curve
- Smaller community than ESX
- Fewer free resources
- More complex structure
- Breaking changes in updates
### Core Features
- Advanced player management
- Comprehensive inventory system
- Metadata system
- Gang system
- Crafting system
- Housing system
- Vehicle keys
- Stash system
### Example Code
```lua
-- Server-side QBCore
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('myresource:buyItem', function(itemName, amount)
local Player = QBCore.Functions.GetPlayer(source)
if Player.Functions.RemoveMoney('cash', price) then
Player.Functions.AddItem(itemName, amount)
end
end)
-- Client-side QBCore
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
PlayerData = QBCore.Functions.GetPlayerData()
end)
```
### Common QBCore Functions
```lua
-- Server-side
Player.Functions.AddMoney(type, amount)
Player.Functions.RemoveMoney(type, amount)
Player.Functions.GetMoney(type)
Player.Functions.AddItem(item, amount, slot, info)
Player.Functions.RemoveItem(item, amount, slot)
Player.Functions.GetItemByName(item)
Player.Functions.SetJob(job, grade)
Player.Functions.SetGang(gang, grade)
Player.Functions.SetMetaData(key, val)
Player.Functions.GetMetaData(key)
-- Client-side
QBCore.Functions.Notify(text, type, length)
QBCore.Functions.DrawText(text, position)
QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked)
QBCore.Functions.DeleteVehicle(vehicle)
QBCore.Functions.GetPlayerData()
```
## Migration Guide
### Standalone to ESX
1. Add `@es_extended/locale.lua` to fxmanifest
2. Add ESX dependency
3. Replace custom player system with ESX.GetPlayerFromId()
4. Convert money/inventory to ESX functions
### Standalone to QBCore
1. Add QB dependency to fxmanifest
2. Replace player system with QBCore.Functions.GetPlayer()
3. Convert all money/inventory operations
4. Update notifications to QBCore.Functions.Notify()
### ESX to QBCore
Common conversions:
| ESX | QBCore |
|-----|--------|
| `ESX.GetPlayerFromId(source)` | `QBCore.Functions.GetPlayer(source)` |
| `xPlayer.getMoney()` | `Player.Functions.GetMoney('cash')` |
| `xPlayer.addMoney(amount)` | `Player.Functions.AddMoney('cash', amount)` |
| `xPlayer.getInventoryItem(item)` | `Player.Functions.GetItemByName(item)` |
| `ESX.ShowNotification(msg)` | `QBCore.Functions.Notify(msg)` |
| `xPlayer.getJob()` | `Player.PlayerData.job` |
| `xPlayer.identifier` | `Player.PlayerData.citizenid` |
## Which Should You Choose?
### Choose Standalone If:
- Building simple resources
- Learning FiveM development
- Don't need player/economy system
- Want maximum flexibility
### Choose ESX If:
- Building traditional RP server
- Want lots of compatible resources
- Need stable, proven system
- Prefer simpler structure
- Large community support is priority
### Choose QBCore If:
- Want modern features
- Building advanced RP server
- Need better performance
- Want active development
- Flexible enough to customize deeply
## Performance Comparison
**Standalone**: Best (no framework overhead)
**ESX**: Good (some overhead from player system)
**QBCore**: Good-Very Good (optimized but more features)
## Conclusion
All three options are valid depending on your needs:
- **Standalone** for simple/custom projects
- **ESX** for traditional RP with maximum compatibility
- **QBCore** for modern RP with advanced features
The "best" framework depends on your specific requirements, technical skill, and server goals.
@@ -0,0 +1,8 @@
FiveM Documentation Results for: {{ $query }}
@foreach($results as $result)
📚 {{ $result['title'] }}
URL: {{ $result['url'] }}
{{ $result['description'] }}
@endforeach
@@ -0,0 +1,31 @@
// Client-side script
@if($framework === 'esx')
let ESX = null;
on('esx:getSharedObject', (obj) => { ESX = obj; });
@elseif($framework === 'qbcore')
const QBCore = exports['qb-core'].GetCoreObject();
@endif
// Resource started
on('onClientResourceStart', (resourceName) => {
if (GetCurrentResourceName() !== resourceName) return;
console.log('Resource started on client');
// Your initialization code here
});
// Example command
RegisterCommand('test', () => {
emit('chat:addMessage', {
args: ['Script', 'Test command executed!']
});
}, false);
// Example thread
setInterval(() => {
// Your periodic code here
}, 1000);
@@ -0,0 +1,33 @@
-- Client-side script
@if($framework === 'esx')
ESX = exports['es_extended']:getSharedObject()
@elseif($framework === 'qbcore')
local QBCore = exports['qb-core']:GetCoreObject()
@endif
-- Resource started
AddEventHandler('onClientResourceStart', function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
print('Resource started on client')
-- Your initialization code here
end)
-- Example command
RegisterCommand('test', function()
TriggerEvent('chat:addMessage', {
args = { 'Script', 'Test command executed!' }
})
end, false)
-- Example thread
CreateThread(function()
while true do
Wait(1000)
-- Your periodic code here
end
end)
@@ -0,0 +1,14 @@
// Configuration
const Config = {
Debug: false,
// Add your config options here
Options: {
example: true
}
};
// Export for use in other files
if (typeof exports !== 'undefined') {
exports('GetConfig', () => Config);
}
@@ -0,0 +1,8 @@
Config = {}
Config.Debug = false
-- Add your config options here
Config.Options = {
example = true
}
@@ -0,0 +1,57 @@
fx_version 'cerulean'
game 'gta5'
author '{{ $author }}'
description '{{ $description }}'
version '{{ $version }}'
@if($framework === 'esx')
shared_script '@es_extended/imports.lua'
@elseif($framework === 'qbcore')
shared_script '@qb-core/shared/locale.lua'
@endif
shared_scripts {
@if($framework === 'esx')
'@es_extended/locale.lua',
'locales/*.lua',
@endif
'config.{{ $scriptExt }}'
}
@if($includeClient)
client_scripts {
'client/main.{{ $scriptExt }}'
}
@endif
@if($includeServer)
server_scripts {
@if($framework === 'esx')
'@mysql-async/lib/MySQL.lua',
@elseif($framework === 'qbcore')
'@oxmysql/lib/MySQL.lua',
@endif
'server/main.{{ $scriptExt }}'
}
@endif
-- Uncomment if using NUI
-- ui_page 'html/index.html'
--
-- files {
-- 'html/index.html',
-- 'html/style.css',
-- 'html/script.js'
-- }
-- dependencies {
@if($framework === 'esx')
-- 'es_extended'
@elseif($framework === 'qbcore')
-- 'qb-core'
@endif
-- }
lua54 'yes'
@@ -0,0 +1,40 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background: transparent;
}
#app {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.container {
background: rgba(0, 0, 0, 0.9);
padding: 2rem;
border-radius: 8px;
color: white;
min-width: 400px;
}
button {
background: #3b82f6;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
margin-top: 1rem;
}
button:hover {
background: #2563eb;
}
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FiveM NUI</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="app" style="display: none;">
<div class="container">
<h1>FiveM NUI Interface</h1>
<p>Your UI content here</p>
<button id="closeBtn">Close</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</body>
</html>
@@ -0,0 +1,21 @@
window.addEventListener('message', (event) => {
const data = event.data;
if (data.action === 'show') {
$('#app').fadeIn();
} else if (data.action === 'hide') {
$('#app').fadeOut();
}
});
$('#closeBtn').click(() => {
$.post(`https://${{ '{GetParentResourceName()}' }}/close`, JSON.stringify({}));
$('#app').fadeOut();
});
$(document).keyup((e) => {
if (e.key === 'Escape') {
$.post(`https://${{ '{GetParentResourceName()}' }}/close`, JSON.stringify({}));
$('#app').fadeOut();
}
});
@@ -0,0 +1,21 @@
window.addEventListener('message', function(event) {
local data = event.data
if data.action == 'show' then
$('#app').fadeIn()
elseif data.action == 'hide' then
$('#app').fadeOut()
end
end)
$('#closeBtn').click(function()
$.post('https://' .. GetParentResourceName() .. '/close', JSON.stringify({}))
$('#app').fadeOut()
end)
$(document).keyup(function(e)
if e.key == 'Escape' then
$.post('https://' .. GetParentResourceName() .. '/close', JSON.stringify({}))
$('#app').fadeOut()
end
end)
@@ -0,0 +1,37 @@
// Server-side script
@if($framework === 'esx')
const ESX = exports['es_extended'].getSharedObject();
@elseif($framework === 'qbcore')
const QBCore = exports['qb-core'].GetCoreObject();
@endif
// Resource started
on('onServerResourceStart', (resourceName) => {
if (GetCurrentResourceName() !== resourceName) return;
console.log('Resource started on server');
// Your initialization code here
});
// Player connecting
on('playerConnecting', (name, setKickReason, deferrals) => {
const player = global.source;
deferrals.defer();
// Check player here
deferrals.done();
});
// Example server event
onNet('resourceName:serverEvent', (data) => {
const player = global.source;
console.log(`Received event from player ${{ '{player}' }}`);
// Trigger back to client
emitNet('resourceName:clientEvent', player, { success: true });
});
@@ -0,0 +1,37 @@
-- Server-side script
@if($framework === 'esx')
ESX = exports['es_extended']:getSharedObject()
@elseif($framework === 'qbcore')
local QBCore = exports['qb-core']:GetCoreObject()
@endif
-- Resource started
AddEventHandler('onServerResourceStart', function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
print('Resource started on server')
-- Your initialization code here
end)
-- Player connecting
AddEventHandler('playerConnecting', function(name, setKickReason, deferrals)
local player = source
deferrals.defer()
-- Check player here
deferrals.done()
end)
-- Example server event
RegisterNetEvent('resourceName:serverEvent', function(data)
local player = source
print('Received event from player ' .. player)
-- Trigger back to client
TriggerClientEvent('resourceName:clientEvent', player, { success = true })
end)