-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.lua
173 lines (160 loc) · 7.09 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
local isHandcuffed, isHardCuffed, isHogtied = false, false, false
local PlayerData, dragStatus, currentTask = {}, {}, {}
dragStatus.isDragged = false
local active = false
RegisterNetEvent("rpx-policejob:client:PoliceAction", function(action)
local closestPlayer, closestDistance = exports['rpx-core']:GetClosestPlayer()
if closestPlayer ~= -1 and closestDistance <= 3.0 then
action = action[1]
if not Citizen.InvokeNative(0x3AA24CCC0D451379, PlayerPedId()) then
if not LocalPlayer.state.isDead then
if action == "cuff" then
TriggerServerEvent('rpx-policejob:server:hardcuff', GetPlayerServerId(closestPlayer))
elseif action == "drag" then
TriggerServerEvent('rpx-policejob:server:drag', GetPlayerServerId(closestPlayer))
elseif action == "ankle" then
TriggerServerEvent('rpx-policejob:server:handcuff', GetPlayerServerId(closestPlayer))
elseif action == "frisk" then
exports['rpx-inventory']:openInventory('player', GetPlayerServerId(closestPlayer))
elseif action == "hogtie" then
TriggerServerEvent('rpx-policejob:server:hogtie', GetPlayerServerId(closestPlayer))
end
else
lib.notify({title = "You can't do this right now!", type = "error" })
end
else
lib.notify({title = "You can't do this right now!", type = "error" })
end
else
lib.notify({title = "Can't Find", description = "No players nearby!", type = "error" })
end
end)
Citizen.CreateThread(
function()
for _, v in pairs(Config.Stations) do
blip = Citizen.InvokeNative(0x554D9D53F696D002, 1664425300, v.x, v.y, v.z)
SetBlipSprite(blip, 1047294027, 1)
SetBlipScale(blip, 1.5)
Citizen.InvokeNative(0x9CB1A1623062F402, blip, v.label)
Citizen.InvokeNative(0x662D364ABF16DE2F, blip, GetHashKey("BLIP_MODIFIER_MP_COLOR_13"))
end
end
)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if dragStatus.isDragged then
if dragStatus.CopId ~= nil then
local targetPed = GetPlayerPed(GetPlayerFromServerId(dragStatus.CopId))
AttachEntityToEntity(PlayerPedId(), targetPed, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
if IsPedDeadOrDying(targetPed, true) then
dragStatus.isDragged = false
DetachEntity(PlayerPedId(), true, false)
end
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if isHandcuffed or isHardCuffed or isHogtied then
DisableControlAction(0, 0xB2F377E8, true) -- Attack
DisableControlAction(0, 0xC1989F95, true) -- Attack 2
DisableControlAction(0, 0x07CE1E61, true) -- Melee Attack 1
DisableControlAction(0, 0xF84FA74F, true) -- MOUSE2
DisableControlAction(0, 0xCEE12B50, true) -- MOUSE3
DisableControlAction(0, 0x8FFC75D6, true) -- Shift
DisableControlAction(0, 0xD9D0E1C0, true) -- SPACE
DisableControlAction(0, 0xCEFD9220, true) -- E
DisableControlAction(0, 0xF3830D8E, true) -- J
DisableControlAction(0, 0x80F28E95, true) -- L
DisableControlAction(0, 0xDB096B85, true) -- CTRL
DisableControlAction(0, 0xE30CD707, true) -- R
else
Citizen.Wait(500)
end
end
end)
RegisterNetEvent('rpx-policejob:client:handcuff', function()
isHandcuffed = not isHandcuffed
local playerPed = PlayerPedId()
Citizen.CreateThread(function()
if isHandcuffed then
lib.notify({ title = "You are being handcuffed!", type = "error" })
SetEnableHandcuffs(playerPed, true)
DisablePlayerFiring(playerPed, true)
SetCurrentPedWeapon(playerPed, GetHashKey('WEAPON_UNARMED'), true) -- unarm player
SetPedCanPlayGestureAnims(playerPed, false)
FreezeEntityPosition(playerPed, true)
DisplayRadar(false)
elseif not isHandcuffed then
if isHardCuffed then
FreezeEntityPosition(playerPed, false)
else
lib.notify({ title = "You are being uncuffed!", type = "success" })
ClearPedSecondaryTask(playerPed)
SetEnableHandcuffs(playerPed, false)
DisablePlayerFiring(playerPed, false)
SetPedCanPlayGestureAnims(playerPed, true)
FreezeEntityPosition(playerPed, false)
DisplayRadar(true)
end
end
end)
end)
RegisterNetEvent('rpx-policejob:client:hardcuff', function()
isHardCuffed = not isHardCuffed
Citizen.CreateThread(function()
local playerPed = PlayerPedId()
if isHardCuffed then
lib.notify({ title = "You are being handcuffed!", type = "error" })
SetEnableHandcuffs(playerPed, true)
DisablePlayerFiring(playerPed, true)
SetCurrentPedWeapon(playerPed, GetHashKey('WEAPON_UNARMED'), true) -- unarm player
SetPedCanPlayGestureAnims(playerPed, false)
DisplayRadar(false)
elseif not isHardCuffed then
lib.notify({ title = "You are being uncuffed!", type = "success" })
ClearPedSecondaryTask(playerPed)
SetEnableHandcuffs(playerPed, false)
DisablePlayerFiring(playerPed, false)
SetPedCanPlayGestureAnims(playerPed, true)
FreezeEntityPosition(playerPed, false)
DisplayRadar(true)
isHandcuffed = false
end
end)
end)
RegisterNetEvent('rpx-policejob:client:hogtie', function()
isHogtied = not isHogtied
Citizen.CreateThread(function()
local playerPed = PlayerPedId()
if isHogtied then
TaskKnockedOutAndHogtied(playerPed, 0, 0)
SetEnableHandcuffs(playerPed, true)
DisablePlayerFiring(playerPed, true)
SetCurrentPedWeapon(playerPed, GetHashKey('WEAPON_UNARMED'), true) -- unarm player
SetPedCanPlayGestureAnims(playerPed, false)
DisplayRadar(false)
lib.notify({ title = "You are being hogtied!", type = "error" })
elseif not isHogtied then
ClearPedTasksImmediately(playerPed, true, false)
ClearPedSecondaryTask(playerPed)
SetEnableHandcuffs(playerPed, false)
DisablePlayerFiring(playerPed, false)
SetPedCanPlayGestureAnims(playerPed, true)
DisplayRadar(true)
lib.notify({ title = "You are being released!", type = "success" })
end
end)
end)
RegisterNetEvent('rpx-policejob:client:drag', function(copId)
dragStatus.isDragged = not dragStatus.isDragged
dragStatus.CopId = copId
if dragStatus.isDragged then
lib.notify({ title = "You are being escorted!", type = "inform" })
else
lib.notify({ title = "You are no longer being escorted!", type = "inform" })
end
end)