forked from Blumlaut/EasyAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui_c.lua
672 lines (580 loc) · 21.8 KB
/
gui_c.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
------------------------------------
------------------------------------
---- DONT TOUCH ANY OF THIS IF YOU DON'T KNOW WHAT YOU ARE DOING
---- THESE ARE **NOT** CONFIG VALUES, USE THE CONVARS IF YOU WANT TO CHANGE SOMETHING
------------------------------------
------------------------------------
isAdmin = false
showLicenses = false
settings = {
button = 289,
forceShowGUIButtons = false,
}
permissions = {
ban = false,
kick = false,
spectate = false,
unban = false,
teleport = false,
manageserver = false,
slap = false,
freeze = false,
screenshot = false,
immune = false,
anon = false,
mute = false,
}
_menuPool = NativeUI.CreatePool()
-- generate "slap" table once
local SlapAmount = {}
for i=1,20 do
table.insert(SlapAmount,i)
end
function handleOrientation(orientation)
if orientation == "right" then
return 1320
elseif orientation == "middle" then
return 730
elseif orientation == "left" then
return 0
end
end
Citizen.CreateThread(function()
TriggerServerEvent("EasyAdmin:amiadmin")
TriggerServerEvent("EasyAdmin:requestBanlist")
TriggerServerEvent("EasyAdmin:requestCachedPlayers")
if not GetResourceKvpString("ea_menuorientation") then
SetResourceKvp("ea_menuorientation", "right")
SetResourceKvpInt("ea_menuwidth", 0)
menuWidth = 0
menuOrientation = handleOrientation("right")
else
menuWidth = GetResourceKvpInt("ea_menuwidth")
menuOrientation = handleOrientation(GetResourceKvpString("ea_menuorientation"))
end
mainMenu = NativeUI.CreateMenu("EasyAdmin", "~b~Admin Menu", menuOrientation, 0)
_menuPool:Add(mainMenu)
mainMenu:SetMenuWidthOffset(menuWidth)
_menuPool:ControlDisablingEnabled(false)
_menuPool:MouseControlsEnabled(false)
while true do
if _menuPool then
_menuPool:ProcessMenus()
end
if IsControlJustReleased(0, settings.button) and isAdmin == true then --M by default
-- clear and re-create incase of permission change+player count change
if strings then
banLength = {
{label = GetLocalisedText("permanent"), time = 10444633200},
{label = GetLocalisedText("oneday"), time = 86400},
{label = GetLocalisedText("threedays"), time = 259200},
{label = GetLocalisedText("oneweek"), time = 518400},
{label = GetLocalisedText("twoweeks"), time = 1123200},
{label = GetLocalisedText("onemonth"), time = 2678400},
{label = GetLocalisedText("oneyear"), time = 31536000},
}
if mainMenu:Visible() then
mainMenu:Visible(false)
_menuPool:Remove()
collectgarbage()
else
GenerateMenu()
mainMenu:Visible(true)
end
else
TriggerServerEvent("EasyAdmin:amiadmin")
end
end
Citizen.Wait(1)
end
end)
function DrawPlayerInfo(target)
drawTarget = target
drawInfo = true
end
function StopDrawPlayerInfo()
drawInfo = false
drawTarget = 0
end
local banlistPage = 1
function GenerateMenu() -- this is a big ass function
TriggerServerEvent("EasyAdmin:requestCachedPlayers")
_menuPool:Remove()
_menuPool = NativeUI.CreatePool()
collectgarbage()
if not GetResourceKvpString("ea_menuorientation") then
SetResourceKvp("ea_menuorientation", "right")
SetResourceKvpInt("ea_menuwidth", 0)
menuWidth = 0
menuOrientation = handleOrientation("right")
else
menuWidth = GetResourceKvpInt("ea_menuwidth")
menuOrientation = handleOrientation(GetResourceKvpString("ea_menuorientation"))
end
mainMenu = NativeUI.CreateMenu("EasyAdmin", "~b~Admin Menu", menuOrientation, 0)
_menuPool:Add(mainMenu)
mainMenu:SetMenuWidthOffset(menuWidth)
_menuPool:ControlDisablingEnabled(false)
_menuPool:MouseControlsEnabled(false)
playermanagement = _menuPool:AddSubMenu(mainMenu, GetLocalisedText("playermanagement"),"",true)
servermanagement = _menuPool:AddSubMenu(mainMenu, GetLocalisedText("servermanagement"),"",true)
settingsMenu = _menuPool:AddSubMenu(mainMenu, GetLocalisedText("settings"),"",true)
mainMenu:SetMenuWidthOffset(menuWidth)
playermanagement:SetMenuWidthOffset(menuWidth)
servermanagement:SetMenuWidthOffset(menuWidth)
settingsMenu:SetMenuWidthOffset(menuWidth)
-- util stuff
players = {}
local localplayers = {}
for i = 0, 256 do
if NetworkIsPlayerActive( i ) then
table.insert( localplayers, GetPlayerServerId(i) )
end
end
table.sort(localplayers)
for i,thePlayer in ipairs(localplayers) do
table.insert(players,GetPlayerFromServerId(thePlayer))
end
for i,thePlayer in ipairs(players) do
thisPlayer = _menuPool:AddSubMenu(playermanagement,"["..GetPlayerServerId(thePlayer).."] "..GetPlayerName(thePlayer),"",true)
thisPlayer:SetMenuWidthOffset(menuWidth)
-- generate specific menu stuff, dirty but it works for now
if permissions.kick then
local thisKickMenu = _menuPool:AddSubMenu(thisPlayer,GetLocalisedText("kickplayer"),"",true)
thisKickMenu:SetMenuWidthOffset(menuWidth)
local thisItem = NativeUI.CreateItem(GetLocalisedText("reason"),GetLocalisedText("kickreasonguide"))
thisKickMenu:AddItem(thisItem)
KickReason = GetLocalisedText("noreason")
thisItem:RightLabel(KickReason)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 128 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result and result ~= "" then
KickReason = result
thisItem:RightLabel(result) -- this is broken for now
else
KickReason = GetLocalisedText("noreason")
end
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("confirmkick"),GetLocalisedText("confirmkickguide"))
thisKickMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
if KickReason == "" then
KickReason = GetLocalisedText("noreason")
end
TriggerServerEvent("EasyAdmin:kickPlayer", GetPlayerServerId( thePlayer ), KickReason)
BanTime = 1
BanReason = ""
_menuPool:CloseAllMenus()
Citizen.Wait(800)
GenerateMenu()
playermanagement:Visible(true)
end
end
if permissions.ban then
local thisBanMenu = _menuPool:AddSubMenu(thisPlayer,GetLocalisedText("banplayer"),"",true)
thisBanMenu:SetMenuWidthOffset(menuWidth)
local thisItem = NativeUI.CreateItem(GetLocalisedText("reason"),GetLocalisedText("banreasonguide"))
thisBanMenu:AddItem(thisItem)
BanReason = GetLocalisedText("noreason")
thisItem:RightLabel(BanReason)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 128 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result and result ~= "" then
BanReason = result
thisItem:RightLabel(result) -- this is broken for now
else
BanReason = GetLocalisedText("noreason")
end
end
local bt = {}
for i,a in ipairs(banLength) do
table.insert(bt, a.label)
end
local thisItem = NativeUI.CreateListItem(GetLocalisedText("banlength"),bt, 1,GetLocalisedText("banlengthguide") )
thisBanMenu:AddItem(thisItem)
local BanTime = 1
thisItem.OnListChanged = function(sender,item,index)
BanTime = index
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("confirmban"),GetLocalisedText("confirmbanguide"))
thisBanMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
if BanReason == "" then
BanReason = GetLocalisedText("noreason")
end
TriggerServerEvent("EasyAdmin:banPlayer", GetPlayerServerId( thePlayer ), BanReason, banLength[BanTime].time, GetPlayerName( thePlayer ))
BanTime = 1
BanReason = ""
_menuPool:CloseAllMenus()
Citizen.Wait(800)
GenerateMenu()
playermanagement:Visible(true)
end
end
if permissions.mute then
local thisItem = NativeUI.CreateItem(GetLocalisedText("mute"),GetLocalisedText("muteguide"))
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:mutePlayer", GetPlayerServerId( thePlayer ))
end
end
if permissions.spectate then
local thisItem = NativeUI.CreateItem(GetLocalisedText("spectateplayer"), "")
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:requestSpectate",GetPlayerServerId(thePlayer))
end
end
if permissions.teleport then
local thisItem = NativeUI.CreateItem(GetLocalisedText("teleporttoplayer"),"")
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(thePlayer),true))
local heading = GetEntityHeading(GetPlayerPed(player))
SetEntityCoords(PlayerPedId(), x,y,z,0,0,heading, false)
end
end
if permissions.teleport then
local thisItem = NativeUI.CreateItem(GetLocalisedText("teleportplayertome"),"")
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
local px,py,pz = table.unpack(GetEntityCoords(PlayerPedId(),true))
TriggerServerEvent("EasyAdmin:TeleportPlayerToCoords", GetPlayerServerId(thePlayer), px,py,pz)
end
end
if permissions.slap then
local thisItem = NativeUI.CreateSliderItem(GetLocalisedText("slapplayer"), SlapAmount, 20, false, false)
thisPlayer:AddItem(thisItem)
thisItem.OnSliderSelected = function(index)
TriggerServerEvent("EasyAdmin:SlapPlayer", GetPlayerServerId(thePlayer), index*10)
end
end
if permissions.freeze then
local sl = {GetLocalisedText("on"), GetLocalisedText("off")}
local thisItem = NativeUI.CreateListItem(GetLocalisedText("setplayerfrozen"), sl, 1)
thisPlayer:AddItem(thisItem)
thisPlayer.OnListSelect = function(sender, item, index)
if item == thisItem then
i = item:IndexToItem(index)
if i == GetLocalisedText("on") then
TriggerServerEvent("EasyAdmin:FreezePlayer", GetPlayerServerId(thePlayer), true)
else
TriggerServerEvent("EasyAdmin:FreezePlayer", GetPlayerServerId(thePlayer), false)
end
end
end
end
if permissions.screenshot then
local thisItem = NativeUI.CreateItem(GetLocalisedText("takescreenshot"),"")
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:TakeScreenshot", GetPlayerServerId(thePlayer))
end
end
_menuPool:ControlDisablingEnabled(false)
_menuPool:MouseControlsEnabled(false)
end
thisPlayer = _menuPool:AddSubMenu(playermanagement,GetLocalisedText("allplayers"),"",true)
thisPlayer:SetMenuWidthOffset(menuWidth)
if permissions.teleport then
-- "all players" function
local thisItem = NativeUI.CreateItem(GetLocalisedText("teleporttome"), GetLocalisedText("teleporttomeguide"))
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
local px,py,pz = table.unpack(GetEntityCoords(PlayerPedId(),true))
TriggerServerEvent("EasyAdmin:TeleportPlayerToCoords", -1, px,py,pz)
end
end
CachedList = _menuPool:AddSubMenu(playermanagement,GetLocalisedText("cachedplayers"),"",true)
CachedList:SetMenuWidthOffset(menuWidth)
if permissions.ban then
for i, cachedplayer in pairs(cachedplayers) do
if cachedplayer.droppedTime then
thisPlayer = _menuPool:AddSubMenu(CachedList,"["..cachedplayer.id.."] "..cachedplayer.name,"",true)
thisPlayer:SetMenuWidthOffset(menuWidth)
local thisBanMenu = _menuPool:AddSubMenu(thisPlayer,GetLocalisedText("banplayer"),"",true)
thisBanMenu:SetMenuWidthOffset(menuWidth)
local thisItem = NativeUI.CreateItem(GetLocalisedText("reason"),GetLocalisedText("banreasonguide"))
thisBanMenu:AddItem(thisItem)
BanReason = GetLocalisedText("noreason")
thisItem:RightLabel(BanReason)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 128 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result and result ~= "" then
BanReason = result
thisItem:RightLabel(result) -- this is broken for now
else
BanReason = GetLocalisedText("noreason")
end
end
local bt = {}
for i,a in ipairs(banLength) do
table.insert(bt, a.label)
end
local thisItem = NativeUI.CreateListItem(GetLocalisedText("banlength"),bt, 1,GetLocalisedText("banlengthguide") )
thisBanMenu:AddItem(thisItem)
local BanTime = 1
thisItem.OnListChanged = function(sender,item,index)
BanTime = index
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("confirmban"),GetLocalisedText("confirmbanguide"))
thisBanMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
if BanReason == "" then
BanReason = GetLocalisedText("noreason")
end
TriggerServerEvent("EasyAdmin:offlinebanPlayer", cachedplayer.id, BanReason, banLength[BanTime].time, cachedplayer.name)
BanTime = 1
BanReason = ""
_menuPool:CloseAllMenus()
Citizen.Wait(800)
GenerateMenu()
playermanagement:Visible(true)
end
end
end
end
if permissions.manageserver then
local thisItem = NativeUI.CreateItem(GetLocalisedText("setgametype"), GetLocalisedText("setgametypeguide"))
servermanagement:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 32 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result then
TriggerServerEvent("EasyAdmin:SetGameType", result)
end
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("setmapname"), GetLocalisedText("setmapnameguide"))
servermanagement:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 32 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result then
TriggerServerEvent("EasyAdmin:SetMapName", result)
end
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("startresourcebyname"), GetLocalisedText("startresourcebynameguide"))
servermanagement:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 32 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result then
TriggerServerEvent("EasyAdmin:StartResource", result)
end
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("stopresourcebyname"), GetLocalisedText("stopresourcebynameguide"))
servermanagement:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", "", "", "", "", 32 + 1)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
if result then
if result ~= GetCurrentResourceName() and result ~= "NativeUI" then
TriggerServerEvent("EasyAdmin:StopResource", result)
else
TriggerEvent("chat:addMessage", { args = { "EasyAdmin", GetLocalisedText("badidea") } })
end
end
end
end
if permissions.unban then
unbanPlayer = _menuPool:AddSubMenu(servermanagement,GetLocalisedText("unbanplayer"),"",true)
unbanPlayer:SetMenuWidthOffset(menuWidth)
local reason = ""
local identifier = ""
for i,theBanned in ipairs(banlist) do
if i<(banlistPage*10) and i>(banlistPage*10)-10 then
if theBanned then
reason = theBanned.reason or "No Reason"
local thisItem = NativeUI.CreateItem(reason, GetLocalisedText("unbanplayerguide"))
unbanPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:unbanPlayer", i)
TriggerServerEvent("EasyAdmin:requestBanlist")
_menuPool:CloseAllMenus()
Citizen.Wait(800)
GenerateMenu()
unbanPlayer:Visible(true)
end
end
end
end
if banlistPage>1 then
local thisItem = NativeUI.CreateItem(GetLocalisedText("lastpage"), GetLocalisedText("lastpage"))
unbanPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
banlistPage=banlistPage-1
_menuPool:CloseAllMenus()
Citizen.Wait(300)
GenerateMenu()
unbanPlayer:Visible(true)
end
end
if #banlist > (banlistPage*10) then
local thisItem = NativeUI.CreateItem(GetLocalisedText("nextpage"), GetLocalisedText("nextpage"))
unbanPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
banlistPage=banlistPage+1
_menuPool:CloseAllMenus()
Citizen.Wait(300)
GenerateMenu()
unbanPlayer:Visible(true)
end
end
end
if permissions.unban then
local sl = {GetLocalisedText("unbanreasons"), GetLocalisedText("unbanlicenses")}
local thisItem = NativeUI.CreateListItem(GetLocalisedText("banlistshowtype"), sl, 1,GetLocalisedText("banlistshowtypeguide"))
settingsMenu:AddItem(thisItem)
settingsMenu.OnListChange = function(sender, item, index)
if item == thisItem then
i = item:IndexToItem(index)
if i == GetLocalisedText(unbanreasons) then
showLicenses = false
else
showLicenses = true
end
end
end
end
if permissions.unban then
local thisItem = NativeUI.CreateItem(GetLocalisedText("refreshbanlist"), GetLocalisedText("refreshbanlistguide"))
settingsMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:updateBanlist")
end
end
if permissions.ban then
local thisItem = NativeUI.CreateItem(GetLocalisedText("refreshcachedplayers"), GetLocalisedText("refreshcachedplayersguide"))
settingsMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:requestCachedPlayers")
end
end
local thisItem = NativeUI.CreateItem(GetLocalisedText("refreshpermissions"), GetLocalisedText("refreshpermissionsguide"))
settingsMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("amiadmin")
end
local sl = {GetLocalisedText("left"), GetLocalisedText("middle"), GetLocalisedText("right")}
local thisItem = NativeUI.CreateListItem(GetLocalisedText("menuOrientation"), sl, 1, GetLocalisedText("menuOrientationguide"))
settingsMenu:AddItem(thisItem)
settingsMenu.OnListChange = function(sender, item, index)
if item == thisItem then
i = item:IndexToItem(index)
if i == GetLocalisedText("left") then
SetResourceKvp("ea_menuorientation", "left")
elseif i == GetLocalisedText("middle") then
SetResourceKvp("ea_menuorientation", "middle")
else
SetResourceKvp("ea_menuorientation", "right")
end
end
end
local sl = {}
for i=0,150,10 do
table.insert(sl,i)
end
local thisi = 0
for i,a in ipairs(sl) do
if menuWidth == a then
thisi = i
end
end
local thisItem = NativeUI.CreateSliderItem(GetLocalisedText("menuOffset"), sl, thisi, GetLocalisedText("menuOffsetguide"), false)
settingsMenu:AddItem(thisItem)
thisItem.OnSliderSelected = function(index)
i = thisItem:IndexToItem(index)
SetResourceKvpInt("ea_menuwidth", i)
menuWidth = i
end
thisi = nil
sl = nil
local thisItem = NativeUI.CreateItem(GetLocalisedText("resetmenuOffset"), "")
settingsMenu:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
SetResourceKvpInt("ea_menuwidth", 0)
menuWidth = 0
end
if permissions.anon then
local thisItem = NativeUI.CreateCheckboxItem(GetLocalisedText("anonymous"), false, GetLocalisedText("anonymousguide"))
settingsMenu:AddItem(thisItem)
settingsMenu.OnCheckboxChange = function(sender, item, checked_)
if item == thisItem then
anonymous = checked_
TriggerServerEvent("EasyAdmin:SetAnonymous", checked_)
end
end
end
_menuPool:ControlDisablingEnabled(false)
_menuPool:MouseControlsEnabled(false)
_menuPool:RefreshIndex() -- refresh indexes
end
Citizen.CreateThread( function()
while true do
Citizen.Wait(0)
if drawInfo then
local text = {}
-- cheat checks
local targetPed = GetPlayerPed(drawTarget)
local targetGod = GetPlayerInvincible(drawTarget)
if targetGod then
table.insert(text,GetLocalisedText("godmodedetected"))
else
table.insert(text,GetLocalisedText("godmodenotdetected"))
end
if not CanPedRagdoll(targetPed) and not IsPedInAnyVehicle(targetPed, false) and (GetPedParachuteState(targetPed) == -1 or GetPedParachuteState(targetPed) == 0) and not IsPedInParachuteFreeFall(targetPed) then
table.insert(text,GetLocalisedText("antiragdoll"))
end
-- health info
table.insert(text,GetLocalisedText("health")..": "..GetEntityHealth(targetPed).."/"..GetEntityMaxHealth(targetPed))
table.insert(text,GetLocalisedText("armor")..": "..GetPedArmour(targetPed))
-- misc info
table.insert(text,GetLocalisedText("wantedlevel")..": "..GetPlayerWantedLevel(drawTarget))
table.insert(text,GetLocalisedText("exitspectator"))
for i,theText in pairs(text) do
SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.30)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(theText)
EndTextCommandDisplayText(0.3, 0.7+(i/30))
end
if IsControlJustPressed(0,103) then
local targetPed = PlayerPedId()
local targetx,targety,targetz = table.unpack(GetEntityCoords(targetPed, false))
RequestCollisionAtCoord(targetx,targety,targetz)
NetworkSetInSpectatorMode(false, targetPed)
StopDrawPlayerInfo()
ShowNotification(GetLocalisedText("stoppedSpectating"))
end
end
end
end)