Repository navigation
Expand file tree
/
Copy pathclient.lua
More file actions
103 lines (89 loc) · 3.88 KB
/
Copy pathclient.lua
File metadata and controls
103 lines (89 loc) · 3.88 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
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
local IsJailed = false
local EarlyRelease = false
local JailCoords = vector3(1677.233, 2658.618, 45.216)
local MaxDistance = 50.0 -- Maximum distance the player can wander from the jail center
local TimeAddedForEscape = 60 -- Seconds added for escape attempts
local HasAttemptedEscape = false -- New variable to track escape attempts
RegisterNetEvent("Lumen:JailPlayer")
AddEventHandler("Lumen:JailPlayer", function(jailtime)
if IsJailed then return end
local playerPed = PlayerPedId()
if DoesEntityExist(playerPed) then
Citizen.CreateThread(function()
SetEntityCoords(playerPed, JailCoords)
IsJailed = true
EarlyRelease = false
HasAttemptedEscape = false -- Reset escape attempt flag
while jailtime > 0 and not EarlyRelease do
playerPed = PlayerPedId()
RemoveAllPedWeapons(playerPed, true)
SetEntityInvincible(playerPed, true)
if IsPedInAnyVehicle(playerPed, false) then
ClearPedTasksImmediately(playerPed)
end
if jailtime % 30 == 0 then
lib.notify({
title = 'Jail Time Remaining',
description = math.floor(jailtime) .. " seconds left until release.",
type = 'inform'
})
end
Citizen.Wait(500)
-- Only check distance if not being released
if not EarlyRelease then
local playerLoc = GetEntityCoords(playerPed, true)
local distance = #(JailCoords - playerLoc)
if distance > MaxDistance then
SetEntityCoords(playerPed, JailCoords)
jailtime = jailtime + TimeAddedForEscape
if jailtime > 1500 then
jailtime = 1500
end
if not HasAttemptedEscape then
lib.notify({
title = 'Escape Attempt',
description = "Your jail time was extended by " .. TimeAddedForEscape .. " seconds because you tried to escape.",
type = 'error'
})
TriggerServerEvent("Lumen:LogEscapeAttempt")
HasAttemptedEscape = true
end
end
end
jailtime = jailtime - 0.5
end
-- Release the player
SetEntityCoords(playerPed, 1849.0, 2585.0, 45.0)
SetEntityHeading(playerPed, 265.0)
IsJailed = false
SetEntityInvincible(playerPed, false)
lib.notify({
title = 'Released',
description = "You have been released from jail.",
type = 'success'
})
end)
end
end)
RegisterNetEvent("Lumen:UnjailPlayer")
AddEventHandler("Lumen:UnjailPlayer", function()
EarlyRelease = true
local playerPed = PlayerPedId()
SetEntityCoords(playerPed, 1849.0, 2585.0, 45.0)
SetEntityHeading(playerPed, 265.0)
IsJailed = false
SetEntityInvincible(playerPed, false)
lib.notify({
title = 'Early Release',
description = "You have been released from jail early.",
type = 'success'
})
end)
function LumenJailPlayerFromGUI(targetId, jailtime)
TriggerServerEvent("Lumen:JailPlayerServer", targetId, jailtime)
end
function LumenUnJailPlayerFromGUI(targetId)
TriggerServerEvent("Lumen:UnjailPlayerServer", targetId)
end
exports("LumenJailPlayerFromGUI", LumenJailPlayerFromGUI)
exports("LumenUnJailPlayerFromGUI", LumenUnJailPlayerFromGUI)