-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.lua
86 lines (70 loc) · 2.52 KB
/
client.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
RegisterNetEvent('msk_givevehicle:spawnVehicle', function(props)
local playerPed = PlayerPedId()
ESX.Game.SpawnVehicle(props.model, GetEntityCoords(playerPed), GetEntityHeading(playerPed), function(vehicle)
ESX.Game.SetVehicleProperties(vehicle, props)
Config.FuelSystem(vehicle, props.fuelLevel)
if (GetResourceState("msk_vehiclekeys") == "started") then
local hasKey = exports.msk_vehiclekeys:HasPlayerKey(vehicle)
if not hasKey then
exports.msk_vehiclekeys:AddTempKey(vehicle)
end
end
end)
end)
RegisterNetEvent('msk_givevehicle:giveVehicle', function(item, veh)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
ESX.Game.SpawnVehicle(veh.model, playerCoords, 0.0, function(vehicle)
SetEntityVisible(vehicle, false, false)
SetEntityCollision(vehicle, false)
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
vehicleProps.plate = GeneratePlate()
vehicleProps.fuelLevel = 100.0
TriggerServerEvent('msk_givevehicle:setVehicle', item, vehicleProps, veh.categorie)
ESX.Game.DeleteVehicle(vehicle)
end)
end)
RegisterNetEvent('msk_givevehicle:giveVehicleCommand', function(target, categorie, model, plate, console, job, bool)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local newPlate
local carExist = false
if plate then
newPlate = plate
else
newPlate = GeneratePlate()
end
ESX.Game.SpawnVehicle(model, playerCoords, 0.0, function(vehicle)
if DoesEntityExist(vehicle) then
carExist = true
SetEntityVisible(vehicle, false, false)
SetEntityCollision(vehicle, false)
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
vehicleProps.plate = newPlate
vehicleProps.fuelLevel = 100.0
TriggerServerEvent('msk_givevehicle:setVehicleCommand', target, categorie, model, newPlate, vehicleProps, console, job, bool)
ESX.Game.DeleteVehicle(vehicle)
end
end)
Wait(2000)
if not carExist then
Config.Notification(nil, Translation[Config.Locale]['clientCommand']:format(model))
end
end)
GeneratePlate = function()
local plate
if Config.Plate.format == 'XXX XXX' then
plate = string.upper(MSK.GetRandomString(3)) .. ' ' .. math.random(100, 999)
elseif Config.Plate.format == 'XX XXXX' then
if Config.Plate.enablePrefix then
plate = Config.Plate.prefix .. ' ' .. math.random(1000, 9999)
else
plate = string.upper(MSK.GetRandomString(2)) .. ' ' .. math.random(1000, 9999)
end
end
return plate
end
logging = function(code, ...)
if not Config.Debug then return end
MSK.Logging(code, ...)
end