-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
63 lines (63 loc) · 1.78 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
local unique = {}
for i, point in pairs(Config.points) do
local id = exports.xshop:register({
elements = point.vehicles,
job = point.job,
action = function(src, xPlayer, selected)
if unique[i] and unique[i][src] and DoesEntityExist(unique[i][src]) then
DeleteEntity(unique[i][src])
end
local ped = GetPlayerPed(src)
ESX.OneSync.SpawnVehicle(selected.name, GetEntityCoords(ped), GetEntityHeading(ped), false, function(veh)
veh = NetworkGetEntityFromNetworkId(veh)
repeat SetPedIntoVehicle(ped, veh, -1) Wait(100)
until GetPedInVehicleSeat(veh, -1) == ped
SetVehicleNumberPlateText(veh, point.job and xPlayer.job.label or Config.plate)
if unique[i] then
unique[i][src] = veh
end
end)
end
})
if point.unique then
unique[i] = {}
end
--
local grade
if point.job then
grade = 99
for _, data in pairs(point.vehicles) do
if not data.grade then
grade = 0
break
elseif data.grade < grade then
grade = data.grade
end
end
end
--
exports.xpoints:register({
coords = point.coords,
blip = not point.blip and Config.blip,
ped = point.ped,
marker = not point.ped and {},
action = {
notification = Config.notification,
key = Config.key,
xevent = function(src, xPlayer)
local elements = {}
for model, veh in pairs(point.vehicles) do
if not veh.grade or veh.grade <= xPlayer.job.grade then
table.insert(elements, {
name = model,
label = model ..
(veh.price and ('<div style="display:inline-block;color:green">' .. veh.price .. '$</div>') or '')
})
end
end
if #elements < 1 then return end
TriggerClientEvent('xshop:menuDefault', src, id, Config.title, elements)
end
}
}, point.job, grade)
end