-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
211 lines (189 loc) · 5.07 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
local inapartment = false
Citizen.CreateThread(function()
local blip = AddBlipForCoord(-270.6047, -957.9693, 30.2231)
SetBlipSprite(blip, 475)
SetBlipDisplay(blip, 4)
SetBlipColour(blip, 2)
SetBlipScale(blip, 0.8)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('Apartments')
EndTextCommandSetBlipName(blip)
end)
Citizen.CreateThread(function()
local alreadyEnteredZone = false
local text = nil
while true do
wait = 5
local ped = PlayerPedId()
local inZone = false
local dist = #(GetEntityCoords(ped)-vector3(-270.6047, -957.9693, 30.2231))
if dist <= 5.0 then
wait = 5
inZone = true
text = '<b>Apartment</b></p>[E] Press to enter your apartment'
if IsControlJustReleased(0, 38) then
TriggerEvent('esx_apartments:enterapartment')
end
else
wait = 1000
end
if inZone and not alreadyEnteredZone then
alreadyEnteredZone = true
TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
end
if not inZone and alreadyEnteredZone then
alreadyEnteredZone = false
TriggerEvent('cd_drawtextui:HideUI')
end
Citizen.Wait(wait)
end
end)
Citizen.CreateThread(function()
local alreadyEnteredZone = false
local text = nil
while true do
wait = 5
local ped = PlayerPedId()
local inZone = false
local dist = #(GetEntityCoords(ped)-vector3(151.8, -1001.36, -100.0))
if dist <= 1.5 then
wait = 5
inZone = true
text = '<b>Closet</b></p>[E] Press to open your closet'
if IsControlJustReleased(0, 38) then
TriggerEvent('esx_apartments:changeclothingmenu')
end
break
else
wait = 1000
end
if inZone and not alreadyEnteredZone then
alreadyEnteredZone = true
TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
end
if not inZone and alreadyEnteredZone then
alreadyEnteredZone = false
TriggerEvent('cd_drawtextui:HideUI')
end
Citizen.Wait(wait)
end
end)
Citizen.CreateThread(function()
local playerPool = {}
while inapartment do
local players = GetActivePlayers()
for i=1, #players do
local player = players[i]
if player ~= PlayerId() and not playerPool[player] then
playerPool[player] = true
NetworkConcealPlayer(player, true, true)
end
end
Citizen.Wait(500)
end
for k in pairs(playerPool) do
NetworkConcealPlayer(k, false, false)
end
end)
RegisterNetEvent('esx_apartments:changeclothingmenu', function()
TriggerEvent('nh-context:sendMenu', {
{
id = 1,
header = "Change Outfit",
txt = "",
params = {
event = "fivem-appearance:pickNewOutfit",
args = {
number = 1,
id = 2
}
}
},
{
id = 2,
header = "Save New Outfit",
txt = "",
params = {
event = "fivem-appearance:saveOutfit"
}
},
{
id = 3,
header = "Delete Outfit",
txt = "",
params = {
event = "fivem-appearance:deleteOutfitMenu",
args = {
number = 1,
id = 2
}
}
}
})
end)
RegisterNetEvent('esx_apartments:exit')
AddEventHandler('esx_apartments:exit', function()
local playerId, playerPed = PlayerId(), PlayerPedId()
inapartment = false
SetEntityVisible(playerPed, 1, 0)
SetPlayerInvincible(playerId, 0)
DoScreenFadeOut(1500)
SetEntityCoords(PlayerPedId(), -270.6047, -957.9693, 31.2231)
DoScreenFadeIn(1500)
end)
RegisterNetEvent('esx_apartments:enterapartment')
AddEventHandler('esx_apartments:enterapartment', function()
inapartment = true
DoScreenFadeOut(1500)
SetEntityCoords(PlayerPedId(), 151.38, -1007.95, -99.0 - 1.0)
DoScreenFadeIn(1500)
while inapartment do
SetEntityVisible(PlayerPedId(), 0, 0)
SetLocalPlayerVisibleLocally(1)
SetPlayerInvincible(PlayerId(), 1)
Citizen.Wait(0)
end
end)
--[[
RegisterNetEvent('esx_apartments:invite') #nh-context and right export
AddEventHandler('esx_apartments:invite', function()
local playersInArea = ESX.Game.GetPlayersInArea(vector3(-270.6047,-957.9693,30.2231), 10.0)
local elements = {}
for i=1, #playersInArea, 1 do
if playersInArea[i] ~= PlayerId() then
table.insert(elements, {label = GetPlayerName(playersInArea[i]), value = playersInArea[i]})
end
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'apartments_invite',
{
title = 'Invite a friend',
align = 'top-left',
elements = elements,
},
function(data, menu)
menu.close()
end,
function(data, menu)
menu.close()
end
)
end) ]]
exports.qtarget:AddTargetModel({-1663022887}, {
options = {
{
event = "esx_apartments:exit",
icon = "fas fa-sign-out-alt",
label = "Leave apartment",
num = 1
},
--[[{
event = "esx_apartments:invite",
icon = "fas fa-address-book",
label = "Invite",
num = 2
}, ]]
},
distance = 2
})