-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcl.lua
160 lines (136 loc) · 5.17 KB
/
cl.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
local QBCore = exports['qb-core']:GetCoreObject()
local zones = {}
function createVisualZone(position, zoneId)
local zone = {}
local blip = AddBlipForRadius(position.x, position.y, position.z, 50.0)
SetBlipColour(blip, 1)
SetBlipAlpha(blip, 128)
zone.blip = blip
zones[zoneId] = zone
return zone
end
CreateThread(function()
while true do
Wait(0)
for _, zone in ipairs(zones) do
DrawMarker(1, zone.position.x, zone.position.y, zone.position.z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, zone.size.x, zone.size.y, zone.size.z, zone.color.r, zone.color.g, zone.color.b, zone.color.a, false, false, 2, false, nil, nil, false)
end
end
end)
function removeVisualZone(zoneId)
if zones[zoneId] then
RemoveBlip(zones[zoneId].blip) -- Remove the blip associated with the zone
zones[zoneId] = nil -- Clear the entry from the zones table
else
print("Zone with ID " .. zoneId .. " does not exist.")
end
end
function spawnProps()
for _, prop in pairs(Config.RoofRunning["acprops"]) do
local model = GetHashKey(prop.model)
RequestModel(model)
while not HasModelLoaded(model) do
Wait(1)
end
-- Set the last parameter to false to make the object static
local obj = CreateObject(model, prop.coords.x, prop.coords.y, prop.coords.z, false, false, false)
SetModelAsNoLongerNeeded(model)
-- Freeze the object to ensure it cannot move
FreezeEntityPosition(obj, true)
PlaceObjectOnGroundProperly(obj)
createTextUIOnProp(obj)
table.insert(Config.spawnedProps, obj)
end
end
function createTextUIOnProp(entity)
exports['j-textui']:create3DTextUIOnEntity(entity, {
displayDist = 4.0,
interactDist = 3.0,
enableKeyClick = true,
keyNum = 38,
key = "E",
text = "Remove AC",
theme = "green",
triggerData = {
triggerName = "jomidar-rr:cl:start",
args = {entity = entity}
}
})
end
function deleteAllProps()
for _, prop in ipairs(Config.spawnedProps) do
if DoesEntityExist(prop) then
FreezeEntityPosition(prop, false) -- Unfreeze if needed in future
deleteTextUIFromProp(prop)
DeleteObject(prop)
end
end
Config.spawnedProps = {}
end
RegisterNetEvent('jomidar-rr:stop')
AddEventHandler('jomidar-rr:stop', function()
removeVisualZone("centralZone")
SendNUIMessage({showUI = false; })
end)
RegisterNetEvent('jomidar-rr:start')
AddEventHandler('jomidar-rr:start', function()
QBCore.Functions.TriggerCallback('jomidar-rr:sv:checkTime', function(time)
if time then
spawnProps()
local zoneId = "centralZone"
createVisualZone(vector3(-588.79, -276.88, 51.4), zoneId)
SendNUIMessage({showUI = true; }) -- Sends a message to the js file.
end
end)
end)
RegisterNetEvent('jomidar-rr:cl:start')
AddEventHandler('jomidar-rr:cl:start', function(data)
local entity = data.entity
local player = source -- Assuming this script is running server-side, 'source' represents the player's server ID.
if DoesEntityExist(entity) then
-- Start the skill check game
exports['skillchecks']:startSameGame(Config.MiniTime , Config.Gridx, Config.Gridy , function(success)
if success then
QBCore.Functions.Progressbar("remove_ac", "Steal Ac Part..", Config.Progressbar, false, true, {
disableMovement = true,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = "mini@repair",
anim = "fixing_a_ped",
flags = 49,
}, {}, {}, function()
-- Done with progress bar
if DoesEntityExist(entity) then
-- Remove the 3D text UI from the prop
deleteTextUIFromProp(entity)
-- Delete the prop
DeleteObject(entity)
-- Success notification
QBCore.Functions.Notify("AC Part successfully removed!", "success", 5000)
TriggerServerEvent('jomidar:handleItemSpawn')
removeVisualZone("centralZone")
SendNUIMessage({
showUI = true,
})
end
end, function()
-- Cancelled progress bar
QBCore.Functions.Notify("Failed to remove AC Part. Try again!", "error", 5000)
end)
else
-- Error notification
QBCore.Functions.Notify("Failed To Breach The Security System. Try again!", "error", 5000)
end
end)
end
end)
function deleteTextUIFromProp(entity)
exports['j-textui']:delete3DTextUI(entity)
end
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
deleteAllProps()
end
end)