Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions [admin]/admin/client/gui/admin_screenshot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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

Expand All @@ -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
Expand All @@ -69,20 +71,20 @@ 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
aScreenShotsRefresh()
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
Expand Down
22 changes: 21 additions & 1 deletion [admin]/admin/conf/ACL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
<right name="command.banserial" access="true" />
<right name="command.unbanserial" access="true" />
<right name="command.listbans" access="true" />
<!--Screenshot related-->
<right name="command.takescreenshot" access="true" />
<right name="command.deletescreenshot" access="true" />
<right name="command.viewscreenshot" access="true" />
<right name="command.listscreenshots" access="true" />
</acl>
<acl name="SuperModerator">
<!--This is the ACL for Admin group-->
Expand All @@ -96,7 +101,7 @@
<right name="command.kick" access="true" />
<right name="command.freeze" access="true" />
<right name="command.mute" access="true" />
<right name="command.setnick" access="true" />
<right name="command.setnick" access="true" />
<right name="command.shout" access="true" />
<right name="command.spectate" access="true" />
<right name="command.slap" access="true" />
Expand Down Expand Up @@ -157,6 +162,11 @@
<right name="command.banserial" access="true" />
<right name="command.unbanserial" access="true" />
<right name="command.listbans" access="true" />
<!--Screenshot related-->
<right name="command.takescreenshot" access="true" />
<right name="command.deletescreenshot" access="true" />
<right name="command.viewscreenshot" access="true" />
<right name="command.listscreenshots" access="true" />
</acl>
<acl name="Moderator">
<!--This is the ACL for Admin group-->
Expand Down Expand Up @@ -233,6 +243,11 @@
<right name="command.banserial" access="false" />
<right name="command.unbanserial" access="false" />
<right name="command.listbans" access="false" />
<!--Screenshot related-->
<right name="command.takescreenshot" access="true" />
<right name="command.deletescreenshot" access="true" />
<right name="command.viewscreenshot" access="true" />
<right name="command.listscreenshots" access="true" />
</acl>
<acl name="Default">
<!--This is the ACL for Admin group-->
Expand Down Expand Up @@ -310,5 +325,10 @@
<right name="command.banserial" access="false" />
<right name="command.unbanserial" access="false" />
<right name="command.listbans" access="false" />
<!--Screenshot related-->
<right name="command.takescreenshot" access="false" />
<right name="command.deletescreenshot" access="false" />
<right name="command.viewscreenshot" access="false" />
<right name="command.listscreenshots" access="false" />
</acl>
</ACL>
23 changes: 17 additions & 6 deletions [admin]/admin/server/admin_screenshot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down