This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
92 lines (64 loc) · 2.58 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
87
88
89
90
91
92
local gVehicleCatalogPosition = vec3(-56.60, -1096.80, 26.40)
CreateThread(function()
local blipHandler = AddBlipForCoord(gVehicleCatalogPosition)
SetBlipSprite(blipHandler, 225)
SetBlipDisplay(blipHandler, 4)
SetBlipScale(blipHandler, 1.0)
SetBlipColour(blipHandler, 3)
SetBlipAsShortRange(blipHandler, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString('Premium Deluxe Motorsport')
EndTextCommandSetBlipName(blipHandler)
while true do
local playerPed = PlayerPedId()
local playerPosition = GetEntityCoords(playerPed)
local nearMarker = false
if #(gVehicleCatalogPosition - playerPosition) < 1.0 then
ESX.Game.Utils.DrawText3D(gVehicleCatalogPosition, '~g~[E]~w~ Abrir loja de veículos', 0.6)
if IsControlJustReleased(0, 38) then
ESX.TriggerServerCallback('fivem-vehicleshop:getVehicles', function(vehicles)
if table.type(vehicles) ~= 'empty' then
SendNUIMessage(
{
type = 'SHOW_CATALOG',
vehicles = vehicles
}
)
SetNuiFocus(true, true)
end
end)
end
nearMarker = true
end
if not nearMarker then
Wait(1000)
end
Wait(0)
end
end)
local function CloseCatalog()
SetNuiFocus(false, false)
SendNUIMessage({type = 'CLOSE_CATALOG'})
end
RegisterNUICallback('fivem-vehicleshop:resetNuiFocus', function(data, cb)
SetNuiFocus(false, false)
cb({ })
end)
-- https://github.com/esx-framework/esx-legacy/blob/cae7d8e7fddf02658dcbe858d61b5eb8cfcffca8/%5Besx_addons%5D/esx_vehicleshop/client/main.lua#L224-L243
RegisterNUICallback('fivem-vehicleshop:buyVehicle', function(vehicleName, cb)
local generatedPlate = GeneratePlate()
ESX.TriggerServerCallback('fivem-vehicleshop:buyVehicle', function(success)
if success then
local playerPed = PlayerPedId()
ESX.Game.SpawnVehicle(vehicleName, vector3(-28.6, -1085.6, 25.5), 330.0, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
SetVehicleNumberPlateText(vehicle, generatedPlate)
end)
CloseCatalog()
else
CloseCatalog()
ESX.ShowNotification('Você não possui dinheiro suficiente para comprar o veículo')
end
end, vehicleName, generatedPlate)
cb({ })
end)