-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathclient.lua
More file actions
161 lines (136 loc) · 4.17 KB
/
Copy pathclient.lua
File metadata and controls
161 lines (136 loc) · 4.17 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
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
RegisterNetEvent('BanSql:Respond')
AddEventHandler('BanSql:Respond', function()
TriggerServerEvent("BanSql:CheckMe")
end)
local menuOpen = false
local currentToken = nil
local function setMenuState(open)
menuOpen = open
SetNuiFocus(open, open)
end
RegisterNetEvent('BanSql:UI:Open')
AddEventHandler('BanSql:UI:Open', function(payload)
if not payload then
return
end
currentToken = payload.token
setMenuState(true)
SendNUIMessage({
action = 'openMenu',
token = payload.token,
texts = payload.texts or {}
})
end)
RegisterNetEvent('BanSql:UI:PlayersResult')
AddEventHandler('BanSql:UI:PlayersResult', function(payload)
SendNUIMessage({
action = 'playersResult',
requestId = payload and payload.requestId,
success = payload and payload.success,
message = payload and payload.message,
results = payload and payload.results or {},
hasMore = payload and payload.hasMore,
nextOffset = payload and payload.nextOffset
})
end)
RegisterNetEvent('BanSql:UI:HistoryResult')
AddEventHandler('BanSql:UI:HistoryResult', function(payload)
SendNUIMessage({
action = 'historyResult',
requestId = payload and payload.requestId,
success = payload and payload.success,
message = payload and payload.message,
results = payload and payload.results or {},
hasMore = payload and payload.hasMore,
nextOffset = payload and payload.nextOffset
})
end)
RegisterNetEvent('BanSql:UI:BanResult')
AddEventHandler('BanSql:UI:BanResult', function(payload)
SendNUIMessage({
action = 'banResult',
success = payload and payload.success,
message = payload and payload.message
})
end)
RegisterNetEvent('BanSql:UI:UnbanResult')
AddEventHandler('BanSql:UI:UnbanResult', function(payload)
SendNUIMessage({
action = 'unbanResult',
success = payload and payload.success,
message = payload and payload.message
})
end)
RegisterNetEvent('BanSql:UI:Close')
AddEventHandler('BanSql:UI:Close', function()
if menuOpen then
setMenuState(false)
end
currentToken = nil
SendNUIMessage({ action = 'closeMenu' })
end)
RegisterNUICallback('closeMenu', function(data, cb)
if currentToken then
TriggerServerEvent('BanSql:UI:CloseSession', currentToken)
end
currentToken = nil
setMenuState(false)
cb({ success = true })
end)
RegisterNUICallback('searchByName', function(data, cb)
if not menuOpen then
cb({ success = false })
return
end
local hideSensitive = true
if data and data.hideSensitive ~= nil then
hideSensitive = data.hideSensitive
end
TriggerServerEvent('BanSql:UI:SearchByName', (data and data.token) or currentToken, data and data.requestId, data and data.query or "", data and data.offset or 0, hideSensitive)
cb({ success = true })
end)
RegisterNUICallback('loadRecentPlayers', function(data, cb)
if not menuOpen then
cb({ success = false })
return
end
local hideSensitive = true
if data and data.hideSensitive ~= nil then
hideSensitive = data.hideSensitive
end
TriggerServerEvent('BanSql:UI:RecentPlayers', (data and data.token) or currentToken, data and data.requestId, data and data.offset or 0, hideSensitive)
cb({ success = true })
end)
RegisterNUICallback('loadBanHistory', function(data, cb)
if not menuOpen then
cb({ success = false })
return
end
TriggerServerEvent('BanSql:UI:BanHistory', (data and data.token) or currentToken, data and data.requestId, data and data.offset or 0)
cb({ success = true })
end)
RegisterNUICallback('submitBan', function(data, cb)
if not menuOpen then
cb({ success = false })
return
end
TriggerServerEvent('BanSql:UI:CreateBan',
(data and data.token) or currentToken,
data and data.playerId,
data and data.days,
data and data.permanent,
data and data.reason
)
cb({ success = true })
end)
RegisterNUICallback('unbanLicense', function(data, cb)
if not menuOpen then
cb({ success = false })
return
end
TriggerServerEvent('BanSql:UI:UnbanLicense', (data and data.token) or currentToken, data and data.license or "")
cb({ success = true })
end)
--Event Demo
--TriggerServerEvent("BanSql:ICheat")
--TriggerServerEvent("BanSql:ICheat", "Auto-Cheat Custom Reason")