Skip to content

Commit 41695c2

Browse files
committed
admin2: Refactor use tables instead of element data
1 parent 6d5de99 commit 41695c2

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

[admin]/admin2/admin_definitions.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ enum(
4646
"EVENT_SCREEN_SHOT",
4747
"EVENT_RESOURCE_START",
4848
"EVENT_RESOURCE_STOP",
49-
"EVENT_PLAYER_JOIN"
49+
"EVENT_PLAYER_JOIN",
50+
"EVENT_ANONYMOUS_UPDATE"
5051
},
5152
"ae"
5253
)

[admin]/admin2/client/main/admin_players.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function aPlayersTab.onClientClick(button)
263263
end
264264
end
265265
elseif (source == aPlayersTab.AnonAdmin) then
266-
setElementData(localPlayer, "AnonAdmin", guiCheckBoxGetSelected(aPlayersTab.AnonAdmin))
266+
triggerServerEvent(EVENT_ANONYMOUS_UPDATE, localPlayer, guiCheckBoxGetSelected(aPlayersTab.AnonAdmin))
267267
elseif (source == aPlayersTab.ColorCodes) then
268268
aPlayersTab.Refresh()
269269
aSetSetting('hideColorCodes', guiCheckBoxGetSelected(source))

[admin]/admin2/server/admin_server.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,17 @@ addEventHandler(
418418
end
419419
)
420420

421+
addEvent(EVENT_ANONYMOUS_UPDATE, true)
422+
addEventHandler(
423+
EVENT_ANONYMOUS_UPDATE,
424+
root,
425+
function(state)
426+
if (hasObjectPermissionTo(client, "general.adminpanel", false)) then
427+
aPlayers[client]["AnonymousAdmin"] = state
428+
end
429+
end
430+
)
431+
421432
addCommandHandler(get("adminChatCommandName"),
422433
function(thePlayer, cmd, ...)
423434
if (hasObjectPermissionTo(thePlayer, "general.tab_adminchat", false) and #arg > 0) then

[admin]/admin2/shared/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function isAnonAdmin(aplayer)
3838
return false
3939
end
4040

41-
return (getElementData(player, "AnonAdmin") == true)
41+
return aPlayers[aplayer] and aPlayers[aplayer]["AnonymousAdmin"] or false
4242
end
4343

4444
-- Source: https://wiki.multitheftauto.com/wiki/FormatDate

0 commit comments

Comments
 (0)