Skip to content

Commit 8ad426e

Browse files
committed
XD
1 parent cffdabf commit 8ad426e

File tree

42 files changed

+761
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+761
-582
lines changed

gamemode/core/derma/f1menu/cl_menu.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ function PANEL:Init()
146146
end
147147

148148
self:MakePopup()
149-
local defaultTab = lia.config.get("DefaultMenuTab", L("you"))
149+
local defaultTab = lia.config.get("DefaultMenuTab", "you")
150150
if not self.tabList[defaultTab] then
151-
if self.tabList[L("you")] then
152-
defaultTab = L("you")
151+
if self.tabList["you"] then
152+
defaultTab = "you"
153153
else
154154
local allKeys = {}
155155
for k in pairs(self.tabList) do

gamemode/core/derma/panels/voice.lua

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ local function CreateVoicePanelList()
7676
g_VoicePanelList:SetSize(270, ScrH() - 200)
7777
g_VoicePanelList:SetPos(ScrW() - 320, 100)
7878
g_VoicePanelList:SetPaintBackground(false)
79-
function g_VoicePanelList:Paint(w, h)
80-
local pnl = VoicePanels[LocalPlayer()]
81-
if not IsValid(pnl) then return end
82-
local vt = LocalPlayer():getNetVar("VoiceType", L("talking"))
83-
draw.SimpleText(L("voiceModeStatus", vt), "liaMediumFont", w / 2, h, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)
84-
end
8579
end
8680

8781
timer.Create("VoiceClean", 1, 0, function()

gamemode/core/hooks/server.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,13 +1003,14 @@ concommand.Add("plysetgroup", function(ply, _, args)
10031003
end)
10041004

10051005
lia.administrator.registerPrivilege({
1006-
Name = "stopSoundForEveryone",
1006+
Name = L("stopSoundForEveryone"),
1007+
ID = "stopSoundForEveryone",
10071008
MinAccess = "superadmin",
10081009
Category = "categoryServer"
10091010
})
10101011

10111012
concommand.Add("stopsoundall", function(client)
1012-
if client:hasPrivilege(L("stopSoundForEveryone")) then
1013+
if client:hasPrivilege("stopSoundForEveryone") then
10131014
for _, v in player.Iterator() do
10141015
v:ConCommand("stopsound")
10151016
end
@@ -1101,4 +1102,9 @@ end)
11011102
hook.Add("server_removeban", "LiliaLogServerUnban", function(data)
11021103
lia.admin(L("unbanLogFormat", data.networkid))
11031104
lia.db.query("DELETE FROM lia_bans WHERE playerSteamID = " .. lia.db.convertDataType(data.networkid))
1104-
end)
1105+
end)
1106+
1107+
local networkStrings = {"AdminModeSwapCharacter", "AnimationStatus", "ArgumentsRequest", "BinaryQuestionRequest", "ButtonRequest", "ChangeAttribute", "CharacterInfo", "CheckHack", "CheckSeed", "CreateTableUI", "CurTime-Sync", "CurTimeSync", "DisplayCharList", "ForceUpdateF1", "KickCharacter", "LIA_BigTable_Ack", "MyBigTableNetString", "NetStreamDS", "OpenInvMenu", "OptionsRequest", "RegenChat", "RequestDropdown", "RequestFactionRoster", "RequestRemoveWarning", "RunLocalOption", "RunOption", "ServerChatAddText", "SpawnMenuGiveItem", "SpawnMenuSpawnItem", "StringRequest", "TicketSystem", "TicketSystemClaim", "TicketSystemClose", "TransferMoneyFromP2P", "VendorAllowClass", "VendorAllowFaction", "VendorEdit", "VendorExit", "VendorFaction", "VendorMaxStock", "VendorMode", "VendorMoney", "VendorOpen", "VendorPrice", "VendorStock", "VendorSync", "VendorTrade", "VerifyCheats", "VerifyCheatsResponse", "ViewClaims", "WorkshopDownloader_Info", "WorkshopDownloader_Request", "WorkshopDownloader_Start", "actBar", "attrib", "blindFade", "blindTarget", "cMsg", "cfgList", "cfgSet", "charInfo", "charKick", "charSet", "charVar", "classUpdate", "cmd", "doorMenu", "doorPerm", "gVar", "invAct", "invData", "invQuantity", "item", "liaActiveTickets", "liaAllFlags", "liaAllPKs", "liaAllPlayers", "liaAllWarnings", "liaCharChoose", "liaCharCreate", "liaCharDelete", "liaCharFetchNames", "liaCharList", "liaCharacterData", "liaCharacterInvList", "liaCmdArgPrompt", "liaDBTableData", "liaDBTables", "liaData", "liaDataSync", "liaDatabaseViewData", "liaFactionRosterData", "liaFullCharList", "liaGroupPermChanged", "liaGroupsAdd", "liaGroupsRemove", "liaGroupsRename", "liaGroupsRequest", "liaGroupsSetPerm", "liaInventoryAdd", "liaInventoryData", "liaInventoryDelete", "liaInventoryInit", "liaInventoryRemove", "liaItemDelete", "liaItemInspect", "liaItemInstance", "liaModifyFlags", "liaNotify", "liaNotifyL", "liaPACPartAdd", "liaPACPartRemove", "liaPACPartReset", "liaPACSync", "liaPKsCount", "liaPlayerCharacters", "liaRequestActiveTickets", "liaRequestAllFlags", "liaRequestAllPKs", "liaRequestAllWarnings", "liaRequestDatabaseView", "liaRequestFactionRoster", "liaRequestFullCharList", "liaRequestPKsCount", "liaRequestPlayerCharacters", "liaRequestPlayers", "liaRequestStaffSummary", "liaRequestTableData", "liaRequestTicketsCount", "liaRequestWarningsCount", "liaStaffSummary", "liaStorageExit", "liaStorageOpen", "liaStorageTransfer", "liaStorageUnlock", "liaTeleportToEntity", "liaTicketsCount", "liaTransferItem", "liaWarningsCount", "lia_managesitrooms_action", "managesitrooms", "msg", "nDel", "nLcl", "nVar", "playerLoadedChar", "postPlayerLoadedChar", "prePlayerLoadedChar", "removeF1", "request_respawn", "rgnDone", "send_logs", "send_logs_request", "seqSet", "setWaypoint", "setWaypointWithLogo", "trunkInitStorage", "updateAdminGroups", "updateAdminPrivilegeIDs", "updateAdminPrivilegeMeta", "updateAdminPrivileges"}
1108+
for _, netString in ipairs(networkStrings) do
1109+
util.AddNetworkString(netString)
1110+
end

gamemode/core/libraries/admin.lua

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ lia.administrator = lia.administrator or {}
2727
lia.administrator.groups = lia.administrator.groups or {}
2828
lia.administrator.privileges = lia.administrator.privileges or {}
2929
lia.administrator.privMeta = lia.administrator.privMeta or {}
30+
lia.administrator.privIDs = lia.administrator.privIDs or {}
31+
lia.administrator.missingGroups = lia.administrator.missingGroups or {}
3032
lia.administrator.DefaultGroups = {
3133
user = 1,
3234
admin = 2,
@@ -171,10 +173,17 @@ function lia.administrator.hasAccess(ply, privilege)
171173
end
172174
end
173175

176+
local name = lia.administrator.privIDs and lia.administrator.privIDs[privilege] or privilege
177+
if not (lia.administrator.privileges and lia.administrator.privileges[name]) then
178+
lia.information(L("privilegeNotExist", name))
179+
if IsValid(ply) and ply.notifyLocalized then ply:notifyLocalized("privilegeNotExist", name) end
180+
return getGroupLevel(grp) >= (lia.administrator.DefaultGroups.superadmin or 3)
181+
end
182+
174183
if getGroupLevel(grp) >= (lia.administrator.DefaultGroups.superadmin or 3) then return true end
175184
local g = lia.administrator.groups and lia.administrator.groups[grp] or nil
176-
if g and g[privilege] == true then return true end
177-
local min = lia.administrator.privileges and lia.administrator.privileges[privilege] or "user"
185+
if g and g[name] == true then return true end
186+
local min = lia.administrator.privileges[name]
178187
return shouldGrant(grp, min)
179188
end
180189

@@ -186,7 +195,8 @@ end
186195
187196
Parameters:
188197
priv (table) - A table describing the privilege. Should contain:
189-
Name (string) - The name of the privilege.
198+
Name (string) - Localized name shown in privilege lists.
199+
ID (string) - Unique identifier used when checking permissions.
190200
MinAccess (string) - (Optional) The minimum usergroup required to have this privilege (default: "user").
191201
Category (string) - (Optional) The category for the privilege.
192202
@@ -199,29 +209,37 @@ end
199209
Example Usage:
200210
-- Register a new privilege "canFly" for admins and above
201211
lia.administrator.registerPrivilege({
202-
Name = "canFly",
212+
Name = L("canFly"),
213+
ID = "canFly",
203214
MinAccess = "admin",
204215
Category = "Fun"
205216
})
206217
]]
207218
function lia.administrator.registerPrivilege(priv)
208219
if not priv or not priv.Name then return end
209-
local name = L(priv.Name)
220+
if not priv.ID then
221+
lia.error("Privilege '" .. tostring(priv.Name) .. "' is missing an ID")
222+
return
223+
end
224+
225+
local name = tostring(priv.Name)
210226
if name == "" then return end
211227
if lia.administrator.privileges[name] ~= nil then return end
212228
local min = tostring(priv.MinAccess or "user"):lower()
213229
lia.administrator.privileges[name] = min
214230
local category = L(priv.Category or "unassigned")
215231
lia.administrator.privMeta[name] = category
232+
lia.administrator.privIDs[priv.ID] = name
216233
for groupName, perms in pairs(lia.administrator.groups) do
217234
perms = perms or {}
218235
lia.administrator.groups[groupName] = perms
219236
if shouldGrant(groupName, min) then perms[name] = true end
220237
end
221238

222-
if CAMI then camiRegisterPrivilege(name, min) end
239+
if CAMI then camiRegisterPrivilege(priv.ID, min) end
223240
hook.Run("OnPrivilegeRegistered", {
224241
Name = name,
242+
ID = priv.ID,
225243
MinAccess = min,
226244
Category = category
227245
})
@@ -248,18 +266,32 @@ end
248266
-- Remove the "canFly" privilege from all groups
249267
lia.administrator.unregisterPrivilege("canFly")
250268
]]
251-
function lia.administrator.unregisterPrivilege(name)
252-
name = tostring(name or "")
269+
function lia.administrator.unregisterPrivilege(id)
270+
id = tostring(id or "")
271+
local name = lia.administrator.privIDs and lia.administrator.privIDs[id] or id
253272
if name == "" or lia.administrator.privileges[name] == nil then return end
254273
lia.administrator.privileges[name] = nil
255274
lia.administrator.privMeta[name] = nil
275+
if lia.administrator.privIDs[id] then
276+
lia.administrator.privIDs[id] = nil
277+
else
278+
for k, v in pairs(lia.administrator.privIDs) do
279+
if v == name then
280+
lia.administrator.privIDs[k] = nil
281+
id = k
282+
break
283+
end
284+
end
285+
end
286+
256287
for _, perms in pairs(lia.administrator.groups or {}) do
257288
perms[name] = nil
258289
end
259290

260-
if CAMI then CAMI.UnregisterPrivilege(name) end
291+
if CAMI then CAMI.UnregisterPrivilege(id) end
261292
hook.Run("OnPrivilegeUnregistered", {
262-
Name = name
293+
Name = name,
294+
ID = id
263295
})
264296

265297
if SERVER then lia.administrator.save() end
@@ -462,6 +494,7 @@ function lia.administrator.createGroup(groupName, info)
462494
}
463495

464496
lia.administrator.groups[groupName] = info
497+
lia.administrator.missingGroups[groupName] = nil
465498
lia.administrator.applyInheritance(groupName)
466499
camiRegisterUsergroup(groupName, info._info.inheritance or "user")
467500
hook.Run("OnUsergroupCreated", groupName, lia.administrator.groups[groupName])
@@ -494,7 +527,7 @@ function lia.administrator.removeGroup(groupName)
494527
end
495528

496529
if not lia.administrator.groups[groupName] then
497-
lia.error(L("usergroupDoesntExist"))
530+
lia.error(L("usergroupDoesntExist", groupName))
498531
return
499532
end
500533

@@ -531,7 +564,7 @@ function lia.administrator.renameGroup(oldName, newName)
531564
end
532565

533566
if not lia.administrator.groups[oldName] then
534-
lia.error(L("usergroupDoesntExist"))
567+
lia.error(L("usergroupDoesntExist", oldName))
535568
return
536569
end
537570

@@ -542,6 +575,8 @@ function lia.administrator.renameGroup(oldName, newName)
542575

543576
lia.administrator.groups[newName] = lia.administrator.groups[oldName]
544577
lia.administrator.groups[oldName] = nil
578+
lia.administrator.missingGroups[oldName] = nil
579+
lia.administrator.missingGroups[newName] = nil
545580
lia.administrator.applyInheritance(newName)
546581
camiUnregisterUsergroup(oldName)
547582
local inh = lia.administrator.groups[newName]._info and lia.administrator.groups[newName]._info.inheritance or "user"
@@ -575,7 +610,10 @@ if SERVER then
575610
function lia.administrator.addPermission(groupName, permission, silent)
576611
if not lia.administrator.groups[groupName] then
577612
if lia.administrator._loading then return end
578-
lia.error(L("usergroupDoesntExist"))
613+
if not lia.administrator.missingGroups[groupName] then
614+
lia.administrator.missingGroups[groupName] = true
615+
lia.error(L("usergroupDoesntExist", groupName))
616+
end
579617
return
580618
end
581619

@@ -609,7 +647,10 @@ if SERVER then
609647
function lia.administrator.removePermission(groupName, permission, silent)
610648
if not lia.administrator.groups[groupName] then
611649
if lia.administrator._loading then return end
612-
lia.error(L("usergroupDoesntExist"))
650+
if not lia.administrator.missingGroups[groupName] then
651+
lia.administrator.missingGroups[groupName] = true
652+
lia.error(L("usergroupDoesntExist", groupName))
653+
end
613654
return
614655
end
615656

@@ -651,6 +692,7 @@ if SERVER then
651692
if not lia.net.ready[ply] then return end
652693
lia.net.writeBigTable(ply, "updateAdminPrivileges", lia.administrator.privileges or {})
653694
timer.Simple(0.05, function() if IsValid(ply) and lia.net.ready[ply] then lia.net.writeBigTable(ply, "updateAdminPrivilegeMeta", lia.administrator.privMeta or {}) end end)
695+
timer.Simple(0.1, function() if IsValid(ply) and lia.net.ready[ply] then lia.net.writeBigTable(ply, "updateAdminPrivilegeIDs", lia.administrator.privIDs or {}) end end)
654696
timer.Simple(0.15, function() if IsValid(ply) and lia.net.ready[ply] then lia.net.writeBigTable(ply, "updateAdminGroups", lia.administrator.groups or {}) end end)
655697
end
656698

@@ -1337,6 +1379,7 @@ else
13371379
lia.administrator.privMeta = tbl or {}
13381380
if IsValid(lia.gui.usergroups) and lia.administrator.groups then buildGroupsUI(lia.gui.usergroups, lia.administrator.groups) end
13391381
end)
1382+
lia.net.readBigTable("updateAdminPrivilegeIDs", function(tbl) lia.administrator.privIDs = tbl end)
13401383

13411384
net.Receive("liaGroupPermChanged", function()
13421385
local group = net.ReadString()

gamemode/core/libraries/commands.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ function lia.command.add(command, data)
8686

8787
if superAdminOnly or adminOnly then
8888
local privilegeName = data.privilege and L(data.privilege) or L("accessTo", command)
89+
local privilegeID = data.privilege or command
8990
lia.administrator.registerPrivilege({
9091
Name = privilegeName,
92+
ID = privilegeID,
9193
MinAccess = superAdminOnly and "superadmin" or "admin",
9294
Category = "commands"
9395
})
@@ -163,13 +165,13 @@ end
163165
function lia.command.hasAccess(client, command, data)
164166
if not data then data = lia.command.list[command] end
165167
if not data then return false, "unknown" end
166-
local privilegeKey = data.privilege
168+
local privilegeID = data.privilege or command
167169
local superAdminOnly = data.superAdminOnly
168170
local adminOnly = data.adminOnly
169171
local accessLevels = superAdminOnly and "superadmin" or adminOnly and "admin" or "user"
170-
local privilegeName = privilegeKey and L(privilegeKey) or accessLevels == "user" and L("globalAccess") or L("accessTo", command)
172+
local privilegeName = data.privilege and L(data.privilege) or accessLevels == "user" and L("globalAccess") or L("accessTo", command)
171173
local hasAccess = true
172-
if accessLevels ~= "user" then hasAccess = client:hasPrivilege(privilegeName) end
174+
if accessLevels ~= "user" then hasAccess = client:hasPrivilege(privilegeID) end
173175
local hookResult = hook.Run("CanPlayerUseCommand", client, command)
174176
if hookResult ~= nil then return hookResult, privilegeName end
175177
local char = IsValid(client) and client.getChar and client:getChar()

gamemode/core/libraries/compatibility/cami.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ hook.Add("CAMI.OnPrivilegeRegistered", "liaAdminPrivAdded", function(priv)
7373
local min = tostring(priv.MinAccess or "user"):lower()
7474
lia.administrator.privileges[name] = min
7575
lia.administrator.privMeta[name] = L(priv.Category or "unassigned")
76+
lia.administrator.privIDs[name] = name
7677
for groupName in pairs(lia.administrator.groups or {}) do
7778
if shouldGrant(groupName, min) then lia.administrator.groups[groupName][name] = true end
7879
end
@@ -89,6 +90,7 @@ hook.Add("CAMI.OnPrivilegeUnregistered", "liaAdminPrivRemoved", function(priv)
8990
if lia.administrator.privileges[name] == nil then return end
9091
lia.administrator.privileges[name] = nil
9192
lia.administrator.privMeta[name] = nil
93+
lia.administrator.privIDs[name] = nil
9294
for _, g in pairs(lia.administrator.groups or {}) do
9395
g[name] = nil
9496
end

gamemode/core/libraries/compatibility/pac.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,17 @@ lia.command.add("pacdisable", {
230230
end
231231
})
232232

233-
lia.config.add("BlockPackURLoad", L("blockPackUrlLoad"), true, nil, {
234-
desc = L("blockPackUrlLoadDesc"),
235-
category = L("categoryPAC3"),
233+
lia.config.add("BlockPackURLoad", "blockPackUrlLoad", true, nil, {
234+
desc = "blockPackUrlLoadDesc",
235+
category = "categoryPAC3",
236236
noNetworking = false,
237237
schemaOnly = false,
238238
type = "Boolean"
239239
})
240240

241241
lia.administrator.registerPrivilege({
242-
Name = "canUsePAC3",
242+
Name = L("canUsePAC3"),
243+
ID = "canUsePAC3",
243244
MinAccess = "admin",
244245
Category = "categoryPAC3"
245246
})

gamemode/core/libraries/compatibility/sam.lua

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ hook.Add("SAM.CanRunCommand", "liaSAM", function(client, _, _, cmd)
7979
return false
8080
end
8181

82-
if client:hasPrivilege(client, L("canBypassSAMFactionWhitelist"), nil) or client:isStaffOnDuty() then
82+
if client:hasPrivilege("canBypassSAMFactionWhitelist") or client:isStaffOnDuty() then
8383
return true
8484
else
8585
client:notifyLocalized("staffRestrictedCommand")
@@ -126,7 +126,7 @@ end
126126

127127
local function CanReadNotifications(client)
128128
if not lia.config.get("AdminOnlyNotification", true) then return true end
129-
return client:hasPrivilege(L("canSeeSAMNotificationsOutsideStaff")) or client:isStaffOnDuty()
129+
return client:hasPrivilege("canSeeSAMNotificationsOutsideStaff") or client:isStaffOnDuty()
130130
end
131131

132132
function sam.player.send_message(client, msg, tbl)
@@ -175,26 +175,28 @@ lia.command.add("cleardecals", {
175175
})
176176

177177
lia.administrator.registerPrivilege({
178-
Name = "canSeeSAMNotificationsOutsideStaff",
178+
Name = L("canSeeSAMNotificationsOutsideStaff"),
179+
ID = "canSeeSAMNotificationsOutsideStaff",
179180
MinAccess = "superadmin",
180181
Category = "categorySAM"
181182
})
182183

183184
lia.administrator.registerPrivilege({
184-
Name = "canBypassSAMFactionWhitelist",
185+
Name = L("canBypassSAMFactionWhitelist"),
186+
ID = "canBypassSAMFactionWhitelist",
185187
MinAccess = "superadmin",
186188
Category = "categorySAM"
187189
})
188190

189-
lia.config.add("AdminOnlyNotification", L("adminOnlyNotifications"), true, nil, {
190-
desc = L("adminOnlyNotificationsDesc"),
191-
category = L("categorySAM"),
191+
lia.config.add("AdminOnlyNotification", "adminOnlyNotifications", true, nil, {
192+
desc = "adminOnlyNotificationsDesc",
193+
category = "categorySAM",
192194
type = "Boolean"
193195
})
194196

195-
lia.config.add("SAMEnforceStaff", L("samEnforceStaff"), true, nil, {
196-
desc = L("samEnforceStaffDesc"),
197-
category = L("categorySAM"),
197+
lia.config.add("SAMEnforceStaff", "samEnforceStaff", true, nil, {
198+
desc = "samEnforceStaffDesc",
199+
category = "categorySAM",
198200
type = "Boolean"
199201
})
200202

gamemode/core/libraries/compatibility/serverguard.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function serverguard.permission:Add(identifier, priv)
3131
if lia.administrator and lia.administrator.registerPrivilege then
3232
lia.administrator.registerPrivilege({
3333
Name = identifier,
34+
ID = identifier,
3435
MinAccess = "admin",
3536
Category = "categoryServerGuard"
3637
})

0 commit comments

Comments
 (0)