-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.lua
63 lines (54 loc) · 2.3 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
if not Config then
print("^1ERROR:^0 Config is not loaded! Check fxmanifest.lua.")
end
local QBCore, ESX
local ox_mysql = exports['oxmysql']
if Config.Framework == 'qb-core' or Config.Framework == 'qbc-core' then
QBCore = exports['qb-core']:GetCoreObject()
elseif Config.Framework == 'esx' then
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
end
RegisterNetEvent('vehiclemods:server:verifyJob', function()
local src = source
local Player
if Config.Framework == 'qb-core' or Config.Framework == 'qbc-core' then
Player = QBCore.Functions.GetPlayer(src)
elseif Config.Framework == 'esx' then
Player = ESX.GetPlayerFromId(src)
elseif Config.Framework == 'standalone' then
Player = { job = { name = 'standalone' } }
end
if Player then
local job = Player.job.name
if Config.JobAccess[job] then
TriggerClientEvent('vehiclemods:client:openVehicleModMenu', src)
else
TriggerClientEvent('ox_lib:notify', src, {title = 'Access Denied', description = 'You must be a first responder to use this.', type = 'error'})
end
end
end)
RegisterNetEvent('vehiclemods:server:saveModifications', function(vehicleModel, skin, extras)
local src = source
local Player
if Config.Framework == 'qb-core' or Config.Framework == 'qbc-core' then
Player = QBCore.Functions.GetPlayer(src)
elseif Config.Framework == 'esx' then
Player = ESX.GetPlayerFromId(src)
elseif Config.Framework == 'standalone' then
Player = { job = { name = 'standalone' } }
end
if Player then
ox_mysql:execute("INSERT INTO emergency_vehicle_mods (vehicle_model, skin, extras) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE skin = VALUES(skin), extras = VALUES(extras)",
{vehicleModel, skin, extras})
end
end)
RegisterNetEvent('vehiclemods:server:getModifications', function(vehicleModel)
local src = source
ox_mysql:execute("SELECT skin, extras FROM emergency_vehicle_mods WHERE vehicle_model = ?", {vehicleModel}, function(result)
if result and #result > 0 then
TriggerClientEvent('vehiclemods:client:returnModifications', src, result[1])
else
TriggerClientEvent('vehiclemods:client:returnModifications', src, nil)
end
end)
end)