forked from darktrovx/devyn-laundry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
147 lines (139 loc) · 5.69 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
local QBCore = exports['qb-core']:GetCoreObject()
local washers = { }
for k,v in pairs(Config.washers) do
if washers[k] == nil then
washers[k] = {washing = false, ready = false}
end
end
RegisterNetEvent("laundry:client:isWashing")
AddEventHandler("laundry:client:isWashing", function(id, verify)
washers[id].isWashing = verify
end)
RegisterNetEvent("laundry:client:isReady")
AddEventHandler("laundry:client:isReady", function(id, verify)
washers[id].isReady = verify
end)
CreateThread(function()
local pay
for washer, data in pairs(Config.washers) do
if Config.washers[washer].cost > 0 then
pay = "for $" .. Config.washers[washer].cost
else
pay = ""
end
exports['qb-target']:AddBoxZone("wash"..washer, vector3(data.vec.x, data.vec.y, data.vec.z), 1.8, 1.3, {
name="wash"..washer,
heading=data.vec.w,
debugPoly=data.debug,
minZ=data.vec.z - 1.25,
maxZ=data.vec.z + 1.25,
}, {
options = {
{
type = "client",
event = "laundry:openwasher",
icon = "fa-solid fa-gauge-high",
label = "Open Washer",
id = washer,
canInteract = function()
return not washers[washer].isWashing
end
},
{
type = "server",
event = "laundry:startwasher",
icon = "fa-solid fa-hourglass-start",
label = "Start Washer " .. pay,
id = washer,
canInteract = function()
return not washers[washer].isWashing
end
},
{
type = "server",
event = "laundry:check",
icon = "fa-solid fa-hourglass-start",
label = "Check Remaining Time",
id = washer,
canInteract = function()
return (washers[washer].isWashing and not washers[washer].isReady)
end
},
{
type = "server",
event = "laundry:collect",
icon = "fa-solid fa-hand-holding-usd",
label = "Collect Money",
id = washer,
canInteract = function()
return washers[washer].isReady
end
},
},
distance = 3.0
})
end
if Config.UseTargetDoors then
exports['qb-target']:AddBoxZone("laundryentrance", Config.Entrance.coords, Config.Entrance.width, Config.Entrance.length, {
name = "laundryentrance",
heading = Config.Entrance.coords.w,
debugPoly = Config.Entrance.Debug,
minZ = Config.Entrance.coords.z - Config.Entrance.minZ,
maxZ = Config.Entrance.coords.z + Config.Entrance.maxZ,
}, {
options = {
{
label = Config.Entrance.text,
action = function()
local targetPos = Config.Exit.coords
local Player = PlayerPedId()
DoScreenFadeOut(1000)
Wait(1000)
FreezeEntityPosition(Player, true)
SetEntityCoords(Player, targetPos.x, targetPos.y, targetPos.z-1)
SetEntityHeading(Player, targetPos.w)
DoScreenFadeIn(1000)
Wait(1000)
FreezeEntityPosition(Player, false)
end
},
},
distance = 2.0
})
exports['qb-target']:AddBoxZone("laundryexit", Config.Exit.coords, Config.Exit.width, Config.Exit.length, {
name = "laundryexit",
heading = Config.Exit.coords.w,
debugPoly = Config.Exit.Debug,
minZ = Config.Exit.coords.z - Config.Exit.minZ,
maxZ = Config.Exit.coords.z + Config.Exit.maxZ,
}, {
options = {
{
label = Config.Exit.text,
action = function()
local targetPos = Config.Entrance.coords
local Player = PlayerPedId()
DoScreenFadeOut(1000)
Wait(1000)
FreezeEntityPosition(Player, true)
SetEntityCoords(Player, targetPos.x, targetPos.y, targetPos.z-1)
SetEntityHeading(Player, targetPos.w)
DoScreenFadeIn(1000)
Wait(1000)
FreezeEntityPosition(Player, false)
end
},
},
distance = 2.0
})
end
end)
-- Open the passed washerId's stash.
RegisterNetEvent("laundry:openwasher", function(data)
if not checka then
TriggerServerEvent("inventory:server:OpenInventory", "stash", "washer"..data.id, {maxweight = 1500000, slots = 10})
TriggerEvent("inventory:client:SetCurrentStash", "washer"..data.id)
else
QBCore.Functions.Notify('This washer is currently cleaning!', 'error', 1500)
end
end)