-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathclient.lua
228 lines (200 loc) · 7.73 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
local Key = Config.Key
local CanOpen = Config.CanOpenMenuWhenDead
local Inmenu
local spectating = false
local lastcoords = { x = 0, y = 0, z = 0 }
local T = Translation.Langs[Config.Lang]
MenuData = exports.vorp_menu:GetMenuData()
VORP = exports.vorp_core:GetCore()
AddEventHandler("onResourceStop", function(resourceName)
if resourceName ~= GetCurrentResourceName() then
return
end
local player = PlayerPedId()
ClearPedTasksImmediately(player, true, true) -- Clear tasks
Closem() -- Close menu
AdminAllowed = false
end)
AddEventHandler("onClientResourceStart", function(resourceName)
if resourceName ~= GetCurrentResourceName() then
return
end
if not Config.DevMode then return end
AdminAllowed = false
local player = GetPlayerServerId(tonumber(PlayerId()))
Wait(100)
TriggerServerEvent("vorp_admin:getStaffInfo", player)
end)
local function CanOpenUsersMenu()
if Config.UseUsersMenu then
TriggerServerEvent("vorp_admin:GetGroup")
OpenUsersMenu()
end
end
local function OpenAdminMenu()
local AdminAllowed = IsAdminAllowed("vorp.staff.OpenMenu")
if AdminAllowed then
OpenMenu()
return true
end
return false
end
CreateThread(function()
repeat Wait(3000) until LocalPlayer.state.IsInSession
if Config.useAdminCommand then
TriggerEvent('chat:addSuggestion', '/' .. Config.commandAdmin, 'Open admin menu or use pagedown', { {} })
RegisterCommand(Config.commandAdmin, function()
local AdminAllowed = IsAdminAllowed("vorp.staff.OpenMenu")
if AdminAllowed then
OpenMenu()
return true
end
end, false)
end
while true do
local player = PlayerPedId()
local isDead = IsPedDeadOrDying(player, false)
if CanOpen then
if IsControlJustPressed(0, Key) and not Inmenu then
if not OpenAdminMenu() then
CanOpenUsersMenu()
end
end
else
if IsControlJustPressed(0, Key) and not isDead and not Inmenu then
if not OpenAdminMenu() then
CanOpenUsersMenu()
end
end
end
Wait(0)
end
end)
----- EVENTS
RegisterNetEvent("vorp_admin:Freezeplayer", function(state)
FreezeEntityPosition(PlayerPedId(), state)
end)
RegisterNetEvent("vorp_admin:respawn", function()
Wait(50)
DoScreenFadeOut(1000)
repeat Wait(0) until not IsScreenFadingOut()
FreezeEntityPosition(PlayerPedId(), true)
Wait(1000)
DoScreenFadeIn(4000)
repeat Wait(0) until not IsScreenFadingIn()
FreezeEntityPosition(PlayerPedId(), false)
TriggerEvent('vorp:ShowBottomRight', T.Notify.reviseRules, 10000)
end)
RegisterNetEvent("vorp_admin:spectatePlayer", function(target, targetCoords)
local admin = PlayerPedId()
local ped = 0
if not spectating then
DoScreenFadeOut(2000)
repeat Wait(0) until not IsScreenFadingOut()
lastcoords = GetEntityCoords(admin)
SetEntityVisible(admin, false)
SetEntityCanBeDamaged(admin, false)
SetEntityInvincible(admin, true)
SetEntityCoords(admin, targetCoords.x + 15, targetCoords.y + 15, targetCoords.z, false, false, false, false)
Wait(500)
ped = GetPlayersClient(target)
Wait(500)
Camera = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
AttachCamToEntity(Camera, ped, 0.0, -2.0, 1.0, false)
SetCamActive(Camera, true)
RenderScriptCams(true, true, 1, true, true, 0)
DoScreenFadeIn(2000)
repeat Wait(0) until IsScreenFadingIn()
spectating = true
else
DoScreenFadeOut(2000)
repeat Wait(0) until not IsScreenFadingOut()
RenderScriptCams(true, false, 1, true, true, 0)
DestroyCam(Camera, true)
DestroyAllCams(true)
SetEntityCoords(admin, lastcoords.x, lastcoords.y, lastcoords.z - 1, false, false, false, false)
SetEntityVisible(admin, true)
SetEntityCanBeDamaged(admin, false)
SetEntityInvincible(admin, true)
DoScreenFadeIn(2000)
repeat Wait(0) until IsScreenFadingIn()
spectating = false
end
end)
local lastLocation = nil
------------------------- TELEPORT EVENTS FROM SERVER -------------------------------
RegisterNetEvent("vorp_admin:gotoPlayer", function(targetCoords)
lastLocation = GetEntityCoords(PlayerPedId())
SetEntityCoords(PlayerPedId(), targetCoords.x, targetCoords.y, targetCoords.z, false, false, false, false)
end)
RegisterNetEvent("vorp_admin:sendAdminBack", function()
if lastLocation then
SetEntityCoords(PlayerPedId(), lastLocation.x, lastLocation.y, lastLocation.z, false, false, false, false)
lastLocation = nil
end
end)
RegisterNetEvent("vorp_admin:Bring", function(adminCoords)
lastLocation = GetEntityCoords(PlayerPedId())
SetEntityCoords(PlayerPedId(), adminCoords.x, adminCoords.y, adminCoords.z, false, false, false, false)
end)
RegisterNetEvent("vorp_admin:TeleportPlayerBack", function()
if lastLocation then
SetEntityCoords(PlayerPedId(), lastLocation.x, lastLocation.y, lastLocation.z, false, false, false, false)
lastLocation = nil
end
end)
-----------------------------------------------------------------------------
-- Show items inventory
RegisterNetEvent("vorp_admin:getplayerInventory", function(inventorydata)
OpenInventory(inventorydata)
end)
-------------------------- Troll Actions Events ------------------------------
RegisterNetEvent('vorp_admin:ClientTrollKillPlayerHandler', function()
SetEntityHealth(PlayerPedId(), 0, 0)
end)
RegisterNetEvent('vorp_admin:ClientTrollInvisbleHandler', function()
local player = PlayerPedId()
if IsEntityVisible(player) then
SetEntityVisible(player, false)
else
SetEntityVisible(player, true)
end
end)
RegisterNetEvent('vorp_admin:ClientTrollLightningStrikePlayerHandler', function(coords)
ForceLightningFlashAtCoords(coords.x, coords.y, coords.z, -1.0)
end)
RegisterNetEvent('vorp_admin:ClientTrollSetPlayerOnFireHandler', function()
local model = 'p_campfire02xb'
if not HasModelLoaded(model) then
RequestModel(model, false)
repeat Wait(0) until HasModelLoaded(model)
end
local object = CreateObject(joaat(model), 0, 0, 0, false, false, false)
repeat Wait(0) until DoesEntityExist(object)
AttachEntityToEntity(object, PlayerPedId(), 41, 1000, 1000, 10000, 0, 0, 0, false, false, true, false, 1000, false, false, false)
Wait(5000)
DeleteObject(object)
end)
RegisterNetEvent('vorp_admin:ClientTrollTPToHeavenHandler', function()
local pl = GetEntityCoords(PlayerPedId())
SetEntityCoords(PlayerPedId(), pl.x, pl.y, pl.z + 200, false, false, false, false)
end)
RegisterNetEvent('vorp_admin:ClientTrollRagdollPlayerHandler', function()
SetPedToRagdoll(PlayerPedId(), 5000, 5000, 0, false, false, false)
end)
RegisterNetEvent('vorp_admin:ClientDrainPlayerStamHandler', function()
Citizen.InvokeNative(0xC3D4B754C0E86B9E, PlayerPedId(), -1000.0)
end)
RegisterNetEvent('vorp_admin:ClientHandcuffPlayerHandler', function()
local player = PlayerPedId()
if not IsPedCuffed(player) then
SetEnableHandcuffs(player, true, false)
else
SetEnableHandcuffs(player, false, false)
end
end)
RegisterNetEvent('vorp_admin:ClientTempHighPlayerHandler', function()
AnimpostfxPlay('MP_BountyLagrasSwamp')
Wait(15000)
AnimpostfxStop('MP_BountyLagrasSwamp')
end)