Repository navigation
Expand file tree
/
Copy pathclient.lua
More file actions
executable file
·74 lines (59 loc) · 1.79 KB
/
Copy pathclient.lua
File metadata and controls
executable file
·74 lines (59 loc) · 1.79 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
--[[ QUESTION ANTI RP -- @DiiiaZoTe ]]
-- ***************** NUI Variables
local questionOpen = false
-- ***************** Spawning
AddEventHandler('playerSpawned', function(spawn)
TriggerServerEvent('antirpquestion:didQuestion')
end)
RegisterNetEvent('antirpquestion:notMade')
AddEventHandler('antirpquestion:notMade', function()
openGui()
questionOpen = true
end)
-- ***************** Open Gui and Focus NUI
function openGui()
SetNuiFocus(true)
SendNUIMessage({openQuestion = true})
end
-- ***************** Close Gui and disable NUI
function closeGui()
questionOpen = false
SetNuiFocus(false)
SendNUIMessage({openQuestion = false})
end
-- ***************** Disable controls while GUI open
Citizen.CreateThread(function()
while true do
if questionOpen then
local ply = GetPlayerPed(-1)
local active = true
DisableControlAction(0, 1, active) -- LookLeftRight
DisableControlAction(0, 2, active) -- LookUpDown
DisablePlayerFiring(ply, true) -- Disable weapon firing
DisableControlAction(0, 142, active) -- MeleeAttackAlternate
DisableControlAction(0, 106, active) -- VehicleMouseControlOverride
if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate
SendNUIMessage({type = "click"})
end
end
Citizen.Wait(0)
end
end)
-- ***************** NUI Callback Methods
-- Callbacks pages opening
RegisterNUICallback('question', function(data, cb)
SendNUIMessage({openSection = "question"})
cb('ok')
end)
-- Callback actions triggering server events
RegisterNUICallback('close', function(data, cb)
-- if question success
closeGui()
TriggerServerEvent('antirpquestion:success')
cb('ok')
end)
RegisterNUICallback('kick', function(data, cb)
closeGui()
TriggerServerEvent('antirpquestion:kick')
cb('ok')
end)