-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathclient.lua
More file actions
71 lines (65 loc) · 2.22 KB
/
Copy pathclient.lua
File metadata and controls
71 lines (65 loc) · 2.22 KB
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
local isSitting = false
QBCore = exports["qb-core"]:GetCoreObject()
local function SitChairThread()
isSitting = true
CreateThread(function()
QBCore.Functions.Notify("Press [E] to stand up.")
while isSitting do
Wait(0)
if IsControlJustPressed(0, 38) then
isSitting = false
ClearPedTasks(PlayerPedId())
end
end
end)
end
CreateThread(function ()
for k, v in pairs(Config.ChairObjects) do
exports['qb-target']:AddTargetModel(v.objname, {
options = {
{
type = "client",
event = "qb-chairs:client:sitchairobject",
icon = "fas fa-chair",
label = "Sit",
offset = vector3(v.offsetX, v.offsetY, v.offsetZ),
direction = v.direction
},
},
distance = 3.0
})
end
end)
CreateThread(function()
for k, v in pairs(Config.ChairZones) do
exports["qb-target"]:AddBoxZone("chairzones"..k,vector3(v.x, v.y, v.z), 0.6, 0.6, {
name="chairzones"..k,
heading=34,
debugPoly=false,
minZ=v.z - 2.0,
maxZ=v.z
}, {
options = {
{
event = "qb-chairs:client:sitchairzones",
icon = "fas fa-chair",
label = "Take A Seat",
coords = v
},
},
job = {"all"},
distance = 2.5
})
end
end)
RegisterNetEvent("qb-chairs:client:sitchairobject", function(data)
local objCoords = GetEntityCoords(data.entity)
local offset = data.offset
TaskStartScenarioAtPosition(PlayerPedId(), "PROP_HUMAN_SEAT_CHAIR_MP_PLAYER", objCoords.x + offset.x, objCoords.y + offset.y, objCoords.z + offset.z, GetEntityHeading(data.entity) + data.direction, 0, true, true)
SitChairThread()
end)
RegisterNetEvent("qb-chairs:client:sitchairzones", function(data)
local coords = data.coords
TaskStartScenarioAtPosition(PlayerPedId(), "PROP_HUMAN_SEAT_CHAIR_MP_PLAYER", coords.x, coords.y, coords.z -0.5, coords.w, 0, true, true)
SitChairThread()
end)