diff --git a/[admin]/admin/client/gui/admin_screenshot.lua b/[admin]/admin/client/gui/admin_screenshot.lua index e6671f820..ec83f6af5 100644 --- a/[admin]/admin/client/gui/admin_screenshot.lua +++ b/[admin]/admin/client/gui/admin_screenshot.lua @@ -16,10 +16,10 @@ function aPlayerScreenShot (player) local x,y = guiGetScreenSize() aScreenShotForm = guiCreateWindow ( x / 2 - 300, y / 2 - 125, 600, 250, "Screenshot Management", false ) aScreenShotList = guiCreateGridList ( 0.03, 0.08, 0.70, 0.90, true, aScreenShotForm ) - aScreenShotNew = guiCreateButton ( 0.75, 0.08, 0.42, 0.09, "Take New", true, aScreenShotForm ) - aScreenShotDelete = guiCreateButton ( 0.75, 0.18, 0.42, 0.09, "Delete", true, aScreenShotForm ) - aScreenShotView = guiCreateButton ( 0.75, 0.28, 0.42, 0.09, "View", true, aScreenShotForm ) - aScreenShotRefresh = guiCreateButton ( 0.75, 0.38, 0.42, 0.09, "Refresh", true, aScreenShotForm ) + aScreenShotNew = guiCreateButton ( 0.75, 0.08, 0.42, 0.09, "Take New", true, aScreenShotForm, "takescreenshot" ) + aScreenShotDelete = guiCreateButton ( 0.75, 0.18, 0.42, 0.09, "Delete", true, aScreenShotForm, "deletescreenshot" ) + aScreenShotView = guiCreateButton ( 0.75, 0.28, 0.42, 0.09, "View", true, aScreenShotForm, "viewscreenshot" ) + aScreenShotRefresh = guiCreateButton ( 0.75, 0.38, 0.42, 0.09, "Refresh", true, aScreenShotForm, "listscreenshots" ) aScreenShotClose = guiCreateButton ( 0.75, 0.88, 0.42, 0.09, "Close", true, aScreenShotForm ) guiGridListAddColumn(aScreenShotList,"Player",0.31 ) guiGridListAddColumn(aScreenShotList,"Admin",0.31 ) @@ -36,7 +36,9 @@ end function aScreenShotsRefresh () if aScreenShotList then guiGridListClear(aScreenShotList) - triggerServerEvent("aScreenShot",resourceRoot,"list",localPlayer) + if hasPermissionTo("command.listscreenshots") then + triggerServerEvent("aScreenShot",localPlayer,"list") + end end end @@ -54,7 +56,7 @@ function aScreenShotsDoubleClick (button) if source == aScreenShotList then local row = guiGridListGetSelectedItem(aScreenShotList) if row ~= -1 then - triggerServerEvent("aScreenShot",resourceRoot,"view",localPlayer,guiGridListGetItemData(aScreenShotList,row,1),guiGridListGetItemText(aScreenShotList,row,1)) + triggerServerEvent("aScreenShot",localPlayer,"view",guiGridListGetItemData(aScreenShotList,row,1),guiGridListGetItemText(aScreenShotList,row,1)) end end end @@ -69,12 +71,12 @@ function aScreenShotsClick (button) aMessageBox("error","No player selected!") else local name = guiGridListGetItemPlayerName(aTab1.PlayerList,guiGridListGetSelectedItem(aTab1.PlayerList),1) - triggerServerEvent("aScreenShot",resourceRoot,"new",localPlayer,getPlayerFromNick(name)) + triggerServerEvent("aScreenShot",localPlayer,"new",getPlayerFromNick(name)) end elseif source == aScreenShotDelete then local row = guiGridListGetSelectedItem ( aScreenShotList ) if row ~= -1 then - triggerServerEvent("aScreenShot",resourceRoot,"delete",localPlayer,guiGridListGetItemData(aScreenShotList,row,1)) + triggerServerEvent("aScreenShot",localPlayer,"delete",guiGridListGetItemData(aScreenShotList,row,1)) guiGridListRemoveRow(aScreenShotList,row) end elseif source == aScreenShotRefresh then @@ -82,7 +84,7 @@ function aScreenShotsClick (button) elseif source == aScreenShotView then local row = guiGridListGetSelectedItem(aScreenShotList) if row ~= -1 then - triggerServerEvent("aScreenShot",resourceRoot,"view",localPlayer,guiGridListGetItemData(aScreenShotList,row,1),guiGridListGetItemText(aScreenShotList,row,1)) + triggerServerEvent("aScreenShot",localPlayer,"view",guiGridListGetItemData(aScreenShotList,row,1),guiGridListGetItemText(aScreenShotList,row,1)) end else for player,gui in pairs (aScreenShotWindows) do diff --git a/[admin]/admin/conf/ACL.xml b/[admin]/admin/conf/ACL.xml index b6127945b..c8b61ed9b 100644 --- a/[admin]/admin/conf/ACL.xml +++ b/[admin]/admin/conf/ACL.xml @@ -81,6 +81,11 @@ + + + + + @@ -96,7 +101,7 @@ - + @@ -157,6 +162,11 @@ + + + + + @@ -233,6 +243,11 @@ + + + + + @@ -310,5 +325,10 @@ + + + + + diff --git a/[admin]/admin/server/admin_screenshot.lua b/[admin]/admin/server/admin_screenshot.lua index 5bbd54886..4961abce1 100644 --- a/[admin]/admin/server/admin_screenshot.lua +++ b/[admin]/admin/server/admin_screenshot.lua @@ -10,12 +10,20 @@ local con = dbConnect("sqlite", ":/registry.db") dbExec(con, "CREATE TABLE IF NOT EXISTS `admin_screenshots` (`id` INTEGER, `player` TEXT, `serial` TEXT, `admin` TEXT, `realtime` TEXT)") + local screenshots = {} local currentid = 0 +local rights = { + ["new"] = "takescreenshot", + ["delete"] = "deletescreenshot", + ["view"] = "viewscreenshot", + ["list"] = "listscreenshots" +} -addEventHandler("onResourceStart", resourceRoot, function() - dbQuery(resourceStartedCallback, {}, con, "SELECT `id` FROM `admin_screenshots`") -end +addEventHandler("onResourceStart", resourceRoot, + function() + dbQuery(resourceStartedCallback, {}, con, "SELECT `id` FROM `admin_screenshots`") + end ) function resourceStartedCallback(qh) @@ -28,10 +36,13 @@ function resourceStartedCallback(qh) end addEvent("aScreenShot",true) -addEventHandler("aScreenShot",resourceRoot, - function (action,admin,player,arg1,arg2) +addEventHandler("aScreenShot",root, + function (action,player,arg1) + local admin = client if not isElement(admin) then return end - if not hasObjectPermissionTo(admin,"command.takescreenshot") then return end + if not action then return end + local right = rights[action] + if not right or not hasObjectPermissionTo(admin,"command."..right) then return end if action == "new" then if not isElement(player) then return end if screenshots[player] then