11-- Toggles Invincibility
22local visible = true
33RegisterNetEvent (' ps-adminmenu:client:ToggleInvisible' , function (data )
4- local data = CheckDataFromKey (data )
5- if not data or not CheckPerms (data .perms ) then return end
64 visible = not visible
7-
85 SetEntityVisible (cache .ped , visible , 0 )
96end )
107
118-- God Mode
129local godmode = false
1310RegisterNetEvent (' ps-adminmenu:client:ToggleGodmode' , function (data )
14- local data = CheckDataFromKey (data )
15- if not data or not CheckPerms (data .perms ) then return end
1611 godmode = not godmode
1712
1813 if godmode then
@@ -55,30 +50,28 @@ local function CopyCoords(data)
5550end
5651
5752RegisterCommand (" vector2" , function ()
58- if not CheckPerms (' mod' ) then return end
59- CopyCoords (" vector2" )
53+ TriggerServerEvent (' ps-adminmenu:server:ValidateCommand' , ' vector2' , ' mod' )
6054end , false )
6155
6256RegisterCommand (" vector3" , function ()
63- if not CheckPerms (' mod' ) then return end
64- CopyCoords (" vector3" )
57+ TriggerServerEvent (' ps-adminmenu:server:ValidateCommand' , ' vector3' , ' mod' )
6558end , false )
6659
6760RegisterCommand (" vector4" , function ()
68- if not CheckPerms (' mod' ) then return end
69- CopyCoords (" vector4" )
61+ TriggerServerEvent (' ps-adminmenu:server:ValidateCommand' , ' vector4' , ' mod' )
7062end , false )
7163
7264RegisterCommand (" heading" , function ()
73- if not CheckPerms (' mod' ) then return end
74- CopyCoords (" heading" )
65+ TriggerServerEvent (' ps-adminmenu:server:ValidateCommand' , ' heading' , ' mod' )
7566end , false )
7667
68+ RegisterNetEvent (' ps-adminmenu:client:CopyCoords' , function (type )
69+ CopyCoords (type )
70+ end )
71+
7772-- Infinite Ammo
7873local InfiniteAmmo = false
7974RegisterNetEvent (' ps-adminmenu:client:setInfiniteAmmo' , function (data )
80- local data = CheckDataFromKey (data )
81- if not data or not CheckPerms (data .perms ) then return end
8275 InfiniteAmmo = not InfiniteAmmo
8376
8477 if GetAmmoInPedWeapon (cache .ped , cache .weapon ) < 6 then
@@ -116,9 +109,6 @@ local function showCoordsMenu()
116109end
117110
118111RegisterNetEvent (' ps-adminmenu:client:ToggleCoords' , function (data )
119- local data = CheckDataFromKey (data )
120- if not data or not CheckPerms (data .perms ) then return end
121-
122112 showCoords = not showCoords
123113
124114 if showCoords then
128118
129119-- Set Ammo
130120RegisterNetEvent (' ps-adminmenu:client:SetAmmo' , function (data , selectedData )
131- local data = CheckDataFromKey (data )
132- if not data or not CheckPerms (data .perms ) then return end
133-
134121 local ammo = selectedData [" Ammo Amount" ].value
135122 local weapon = GetSelectedPedWeapon (cache .ped )
136123
@@ -142,8 +129,11 @@ RegisterNetEvent('ps-adminmenu:client:SetAmmo', function(data, selectedData)
142129 end
143130end )
144131
145- RegisterCommand (" setammo" , function (source )
146- if not CheckPerms (' mod' ) then return end
132+ RegisterCommand (" setammo" , function ()
133+ TriggerServerEvent (' ps-adminmenu:server:ValidateCommand' , ' setammo' , ' mod' )
134+ end , false )
135+
136+ RegisterNetEvent (' ps-adminmenu:client:SetAmmoCommand' , function ()
147137 local weapon = GetSelectedPedWeapon (cache .ped )
148138 local ammo = 999
149139 if weapon ~= nil then
@@ -152,15 +142,12 @@ RegisterCommand("setammo", function(source)
152142 else
153143 QBCore .Functions .Notify (locale (" no_weapon" ), ' error' )
154144 end
155- end , false )
145+ end )
156146
157147-- Toggle Dev
158148local ToggleDev = false
159149
160150RegisterNetEvent (' ps-adminmenu:client:ToggleDev' , function (dataKey )
161- local data = CheckDataFromKey (dataKey )
162- if not data or not CheckPerms (data .perms ) then return end
163-
164151 ToggleDev = not ToggleDev
165152
166153 TriggerEvent (" qb-admin:client:ToggleDevmode" ) -- toggle dev mode (ps-hud/qb-hud)
@@ -182,7 +169,7 @@ local toogleAdmin = lib.addKeybind({
182169
183170-- noclip
184171RegisterCommand (' nc' , function ()
185- TriggerEvent ( Config .Actions [" noclip" ].event )
172+ TriggerServerEvent ( ' ps-adminmenu:server:ValidateClientAction ' , ' noclip ' , nil , Config .Actions [" noclip" ].event , Config . Actions [ " noclip " ]. perms )
186173end , false )
187174
188175local toogleNoclip = lib .addKeybind ({
0 commit comments