forked from TanguyOrtegat/es_admin2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
265 lines (223 loc) · 7.03 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
local group
local states = {}
states.frozen = false
states.frozenPos = nil
Citizen.CreateThread(function()
while true do
Wait(0)
if (IsControlJustPressed(1, 212) and IsControlJustPressed(1, 213)) then
if group ~= "user" then
SetNuiFocus(true, true)
SendNUIMessage({type = 'open', players = getPlayers()})
end
end
end
end)
RegisterNetEvent('es_admin:setGroup')
AddEventHandler('es_admin:setGroup', function(g)
group = g
end)
RegisterNUICallback('close', function(data, cb)
SetNuiFocus(false)
end)
RegisterNUICallback('quick', function(data, cb)
if data.type == "slay_all" or data.type == "bring_all" or data.type == "slap_all" then
TriggerServerEvent('es_admin:all', data.type)
else
TriggerServerEvent('es_admin:quick', data.id, data.type)
end
end)
RegisterNUICallback('set', function(data, cb)
TriggerServerEvent('es_admin:set', data.type, data.user, data.param)
end)
local noclip = false
RegisterNetEvent('es_admin:quick')
AddEventHandler('es_admin:quick', function(t, target)
if t == "slay" then SetEntityHealth(PlayerPedId(), 0) end
if t == "goto" then SetEntityCoords(PlayerPedId(), GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(target)))) end
if t == "bring" then
states.frozenPos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(target)))
SetEntityCoords(PlayerPedId(), GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(target))))
end
if t == "crash" then
Citizen.Trace("You're being crashed, so you know. This server sucks.\n")
Citizen.CreateThread(function()
while true do end
end)
end
if t == "slap" then ApplyForceToEntity(PlayerPedId(), 1, 9500.0, 3.0, 7100.0, 1.0, 0.0, 0.0, 1, false, true, false, false) end
if t == "noclip" then
local msg = "disabled"
if(noclip == false)then
noclip_pos = GetEntityCoords(GetPlayerPed(-1), false)
end
noclip = not noclip
if(noclip)then
msg = "enabled"
end
TriggerEvent("chatMessage", "SYSTEM", {255, 0, 0}, "Noclip has been ^2^*" .. msg)
end
if t == "freeze" then
local player = PlayerId()
local ped = GetPlayerPed(-1)
states.frozen = not states.frozen
states.frozenPos = GetEntityCoords(ped, false)
if not state then
if not IsEntityVisible(ped) then
SetEntityVisible(ped, true)
end
if not IsPedInAnyVehicle(ped) then
SetEntityCollision(ped, true)
end
FreezeEntityPosition(ped, false)
--SetCharNeverTargetted(ped, false)
SetPlayerInvincible(player, false)
else
SetEntityCollision(ped, false)
FreezeEntityPosition(ped, true)
--SetCharNeverTargetted(ped, true)
SetPlayerInvincible(player, true)
--RemovePtfxFromPed(ped)
if not IsPedFatallyInjured(ped) then
ClearPedTasksImmediately(ped)
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
if(states.frozen)then
ClearPedTasksImmediately(GetPlayerPed(-1))
SetEntityCoords(GetPlayerPed(-1), states.frozenPos)
end
end
end)
local heading = 0
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if(noclip)then
SetEntityCoordsNoOffset(GetPlayerPed(-1), noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0)
if(IsControlPressed(1, 34))then
heading = heading + 1.5
if(heading > 360)then
heading = 0
end
SetEntityHeading(GetPlayerPed(-1), heading)
end
if(IsControlPressed(1, 9))then
heading = heading - 1.5
if(heading < 0)then
heading = 360
end
SetEntityHeading(GetPlayerPed(-1), heading)
end
if(IsControlPressed(1, 8))then
noclip_pos = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 1.0, 0.0)
end
if(IsControlPressed(1, 32))then
noclip_pos = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, -1.0, 0.0)
end
if(IsControlPressed(1, 27))then
noclip_pos = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 0.0, 1.0)
end
if(IsControlPressed(1, 173))then
noclip_pos = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 0.0, -1.0)
end
end
end
end)
RegisterNetEvent('es_admin:spawnVehicle')
AddEventHandler('es_admin:spawnVehicle', function(v)
local carid = GetHashKey(v)
local playerPed = GetPlayerPed(-1)
if playerPed and playerPed ~= -1 then
RequestModel(carid)
while not HasModelLoaded(carid) do
Citizen.Wait(0)
end
local playerCoords = GetEntityCoords(playerPed)
veh = CreateVehicle(carid, playerCoords, 0.0, true, false)
SetVehicleAsNoLongerNeeded(veh)
TaskWarpPedIntoVehicle(playerPed, veh, -1)
end
end)
RegisterNetEvent('es_admin:freezePlayer')
AddEventHandler("es_admin:freezePlayer", function(state)
local player = PlayerId()
local ped = GetPlayerPed(-1)
states.frozen = state
states.frozenPos = GetEntityCoords(ped, false)
if not state then
if not IsEntityVisible(ped) then
SetEntityVisible(ped, true)
end
if not IsPedInAnyVehicle(ped) then
SetEntityCollision(ped, true)
end
FreezeEntityPosition(ped, false)
--SetCharNeverTargetted(ped, false)
SetPlayerInvincible(player, false)
else
SetEntityCollision(ped, false)
FreezeEntityPosition(ped, true)
--SetCharNeverTargetted(ped, true)
SetPlayerInvincible(player, true)
--RemovePtfxFromPed(ped)
if not IsPedFatallyInjured(ped) then
ClearPedTasksImmediately(ped)
end
end
end)
RegisterNetEvent('es_admin:teleportUser')
AddEventHandler('es_admin:teleportUser', function(x, y, z)
SetEntityCoords(GetPlayerPed(-1), x, y, z)
states.frozenPos = {x = x, y = y, z = z}
end)
RegisterNetEvent('es_admin:slap')
AddEventHandler('es_admin:slap', function()
local ped = GetPlayerPed(-1)
ApplyForceToEntity(ped, 1, 9500.0, 3.0, 7100.0, 1.0, 0.0, 0.0, 1, false, true, false, false)
end)
RegisterNetEvent('es_admin:givePosition')
AddEventHandler('es_admin:givePosition', function()
local pos = GetEntityCoords(GetPlayerPed(-1))
local string = "{ ['x'] = " .. pos.x .. ", ['y'] = " .. pos.y .. ", ['z'] = " .. pos.z .. " },\n"
TriggerServerEvent('es_admin:givePos', string)
TriggerEvent('chatMessage', 'SYSTEM', {255, 0, 0}, 'Position saved to file.')
end)
RegisterNetEvent('es_admin:kill')
AddEventHandler('es_admin:kill', function()
SetEntityHealth(GetPlayerPed(-1), 0)
end)
RegisterNetEvent('es_admin:heal')
AddEventHandler('es_admin:heal', function()
SetEntityHealth(GetPlayerPed(-1), 200)
end)
RegisterNetEvent('es_admin:crash')
AddEventHandler('es_admin:crash', function()
while true do
end
end)
RegisterNetEvent("es_admin:noclip")
AddEventHandler("es_admin:noclip", function(t)
local msg = "disabled"
if(noclip == false)then
noclip_pos = GetEntityCoords(GetPlayerPed(-1), false)
end
noclip = not noclip
if(noclip)then
msg = "enabled"
end
TriggerEvent("chatMessage", "SYSTEM", {255, 0, 0}, "Noclip has been ^2^*" .. msg)
end)
function getPlayers()
local players = {}
for i = 0,32 do
if NetworkIsPlayerActive(i) then
table.insert(players, {id = GetPlayerServerId(i), name = GetPlayerName(i)})
end
end
return players
end