Skip to content
Closed
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
14 changes: 3 additions & 11 deletions [admin]/admin2/client/main/admin_players.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function aPlayersTab.Create(tab)
aPlayersTab.Shout = guiCreateButton(0.74, 0.19, 0.12, 0.04, "Shout", true, tab, "shout")
aPlayersTab.Spectate = guiCreateButton(0.87, 0.19, 0.12, 0.04, "Spectate", true, tab, "spectate")
aPlayersTab.SetNick = guiCreateButton(0.74, 0.235, 0.12, 0.04, "Set nick", true, tab, "setnick")
aPlayersTab.Admin = guiCreateButton(0.87, 0.235, 0.12, 0.04, "Give admin", true, tab, "setgroup")
aPlayersTab.Permissions = guiCreateButton(0.87, 0.235, 0.12, 0.04, "Permissions", true, tab, "setgroup")
aPlayersTab.SlapOptions = guiCreateComboBox(0.76, 0.28, 0.1, 0.04, "0", true, tab)
local width, height = guiGetSize(aPlayersTab.SlapOptions, false)
for i = 0, 200, 20 do
Expand Down Expand Up @@ -256,15 +256,8 @@ function aPlayersTab.onClientClick(button)
end
elseif (source == aPlayersTab.WarpPlayer) then
aPlayerWarp(player)
elseif (source == aPlayersTab.Admin) then
if
(aPlayers[player]["admin"] and
messageBox("Revoke admin rights from " .. name .. "?", MB_WARNING))
then
triggerServerEvent("aPlayer", getLocalPlayer(), player, "setgroup", false)
elseif (messageBox("Give admin rights to " .. name .. "?", MB_WARNING)) then
triggerServerEvent("aPlayer", getLocalPlayer(), player, "setgroup", true)
end
elseif (source == aPlayersTab.Permissions) then
aPermissions.Show()
end
end
elseif (source == aPlayersTab.AnonAdmin) then
Expand All @@ -284,7 +277,6 @@ function aPlayersTab.onClientClick(button)
guiSetText(aPlayersTab.Groups, "Groups: N/A")
guiSetText(aPlayersTab.Mute, "Mute")
guiSetText(aPlayersTab.Freeze, "Freeze")
guiSetText(aPlayersTab.Admin, "Give admin")
guiSetText(aPlayersTab.Health, "Health: 0%")
guiSetText(aPlayersTab.Armour, "Armour: 0%")
guiSetText(aPlayersTab.Skin, "Skin: N/A")
Expand Down
101 changes: 101 additions & 0 deletions [admin]/admin2/client/widgets/admin_permissions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* client\widgets\admin_permissions.lua
*
* Original File by lil_Toady
*
**************************************]]
aPermissions = {
Form = nil
}

addEvent(EVENT_ACL, true)

function aPermissions.Show()
if (not aPermissions.Form) then
local x, y = guiGetScreenSize()
aPermissions.Form = guiCreateWindow(x / 2 - 150, y / 2 - 125, 300, 250, "Player Permissions Management", false)
aPermissions.Label =
guiCreateLabel(0.03, 0.09, 0.94, 0.07, "Select a group from the list to give or revoke", true, aPermissions.Form)
guiLabelSetHorizontalAlign(aPermissions.Label, "center")
guiLabelSetColor(aPermissions.Label, 255, 0, 0)
aPermissions.List = guiCreateGridList(0.03, 0.18, 0.50, 0.71, true, aPermissions.Form)
guiGridListAddColumn(aPermissions.List, "Groups", 0.85)
aPermissions.Update = guiCreateButton(0.03, 0.90, 0.50, 0.08, "Refresh", true, aPermissions.Form)
aPermissions.Give = guiCreateButton(0.55, 0.18, 0.42, 0.09, "Give Group", true, aPermissions.Form, "createteam")
aPermissions.Revoke = guiCreateButton(0.55, 0.28, 0.42, 0.09, "Revoke Group", true, aPermissions.Form, "destroyteam")
aPermissions.Hide = guiCreateButton(0.55, 0.88, 0.42, 0.09, "Close", true, aPermissions.Form)

addEventHandler(EVENT_ACL, getLocalPlayer(), aPermissions.onSync)
addEventHandler("onClientGUIClick", aPermissions.Form, aPermissions.onClick)
--Register With Admin Form
aRegister("PlayerPermissions", aPermissions.Form, aPermissions.Show, aPermissions.Close)
end
aPermissions.Refresh()
guiSetVisible(aPermissions.Form, true)
guiBringToFront(aPermissions.Form)
end

aPermissions.SyncFunctions = {
[ACL_GROUPS] = function(data)
guiGridListClear(aPermissions.List)
for id, group in ipairs(data) do
local row = guiGridListAddRow(aPermissions.List)
guiGridListSetItemText(aPermissions.List, row, 1, group, false, false)
end
end,
}

function aPermissions.onSync(action, ...)
aPermissions.SyncFunctions[action](...)
end

function aPermissions.Close(destroy)
guiSetInputEnabled(false)
if (destroy) then
if (aPermissions.Form) then
removeEventHandler("onClientGUIClick", aPermissions.Form, aPermissions.onClick)
destroyElement(aPermissions.Form)
aPermissions.Form = nil
end
else
guiSetVisible(aPermissions.Form, false)
end
end

function aPermissions.onClick(button)
if (button == "left") then
if (source == aPermissions.Update) then
aPermissions.Refresh()
elseif (source == aPermissions.Give) then
if (guiGridListGetSelectedItem(aPermissions.List) == -1) then
messageBox("No group selected!", MB_WARNING)
else
local group = guiGridListGetItemText(aPermissions.List, guiGridListGetSelectedItem(aPermissions.List), 1)
if (messageBox('Are you sure to give "' .. group .. '"?', MB_QUESTION, MB_YESNO)) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better message would be "Are you sure you want to add [player] to the '[group name]' group?"

triggerServerEvent("aPlayer", getLocalPlayer(), getSelectedPlayer(), "setgroup", true, group)
end
end
elseif (source == aPermissions.Revoke) then
if (guiGridListGetSelectedItem(aPermissions.List) == -1) then
messageBox("No group selected!", MB_WARNING)
else
local group = guiGridListGetItemText(aPermissions.List, guiGridListGetSelectedItem(aPermissions.List), 1)
if (messageBox('Are you sure to revoke "' .. group .. '"?', MB_QUESTION, MB_YESNO)) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better message would be "Are you sure you want to remove [player] from the '[group name]' group?"

triggerServerEvent("aPlayer", getLocalPlayer(), getSelectedPlayer(), "setgroup", false, group)
end
end
elseif (source == aPermissions.Hide) then
aPermissions.Close(false)
end
end
end

function aPermissions.Refresh()
if (aPermissions.List) then
guiGridListClear(aPermissions.List)
triggerServerEvent(EVENT_ACL, getLocalPlayer(), ACL_GROUPS)
end
end
12 changes: 6 additions & 6 deletions [admin]/admin2/conf/messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@
<log>ADMIN: $admin has given a jetpack to $player</log>
</group>
<group action="adminr" r="255" g="0" b="0">
<admin>$player's admin rights have been revoked</admin>
<player>$admin has revoked your admin rights</player>
<log>ADMIN: $admin has revoked admin privilegies from $player</log>
<admin>$player's $data group have been revoked</admin>
<player>$admin has revoked your $data group</player>
<log>ADMIN: $admin has revoked $data group from $player</log>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think it would be better to say "[player] has been removed from the [group] group."

</group>
<group action="admina" r="0" g="255" b="0">
<admin>$player has been given admin rights</admin>
<player>$admin has given you admin rights</player>
<log>ADMIN: $admin has given admin privilegies to $player</log>
<admin>$player has been given $data group</admin>
<player>$admin has given you $data group</player>
<log>ADMIN: $admin has given $data group to $player</log>
</group>
<group action="givevehicle" r="0" g="255" b="0">
<admin>$player has been given a '$data'</admin>
Expand Down
1 change: 1 addition & 0 deletions [admin]/admin2/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<script src="client/widgets/admin_inputbox.lua" type="client" />
<script src="client/widgets/admin_color.lua" type="client" />
<script src="client/widgets/admin_performance.lua" type="client" />
<script src="client/widgets/admin_permissions.lua" type="client" />
<script src="client/widgets/admin_messages.lua" type="client" />
<script src="client/widgets/admin_message.lua" type="client" />
<script src="client/widgets/admin_spectator.lua" type="client" />
Expand Down
16 changes: 8 additions & 8 deletions [admin]/admin2/server/admin_ACL.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_acl.lua
*
* Original File by lil_Toady
*
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_acl.lua
*
* Original File by lil_Toady
*
**************************************]]
function aSetupACL()
outputDebugString("Verifying ACL...")
Expand Down
21 changes: 6 additions & 15 deletions [admin]/admin2/server/admin_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ aFunctions = {
["jetpack"] = function(player)
if (doesPedHaveJetPack(player)) then
removePedJetPack(player)
return true, "jetpackr"
return "jetpackr"
else
if (getPedOccupiedVehicle(player)) then
outputChatBox(
Expand All @@ -179,38 +179,29 @@ aFunctions = {
)
else
if (givePedJetPack(player)) then
return true, "jetpacka"
return "jetpacka"
end
end
end
end,
["setgroup"] = function(player, data)
-- NEEDS CHECKING
["setgroup"] = function(player, data, groupName)
local account = getPlayerAccount(player)
if (not isGuestAccount(account)) then
local group = aclGetGroup(data)
local group = aclGetGroup(groupName)
if (group) then
if (data == true) then
aclGroupAddObject(group, "user." .. getAccountName(account))
return true, "admina"
return "admina", groupName
elseif (data == false) then
aclGroupRemoveObject(group, "user." .. getAccountName(account))
aPlayers[player]["chat"] = false
return true, "adminr"
return "adminr", groupName
end
for id, p in ipairs(getElementsByType("player")) do
if (hasObjectPermissionTo(p, "general.adminpanel")) then
triggerEvent("aSync", p, "admins")
end
end
else
outputChatBox(
"Error - Admin group not initialized. Please reinstall admin resource.",
source,
255,
0,
0
)
end
else
outputChatBox("Error - Player is not logged in.", source, 255, 100, 100)
Expand Down
19 changes: 9 additions & 10 deletions [admin]/admin2/server/admin_sync.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_sync.lua
*
* Original File by lil_Toady
*
--[[**********************************
*
* Multi Theft Auto - Admin Panel
*
* admin_sync.lua
*
* Original File by lil_Toady
*
**************************************]]
addEvent(EVENT_SYNC, true)
addEventHandler(
Expand Down Expand Up @@ -69,8 +69,7 @@ addEventHandler(
elseif (type == SYNC_ADMINS) then
for id, player in ipairs(aPlayers) do
tableOut[player] = {}
tableOut[player]["admin"] = hasObjectPermissionTo(player, "general.adminpanel")
if (tableOut[player]["admin"]) then
if (hasObjectPermissionTo(player, "general.adminpanel")) then
tableOut[player]["chat"] = aPlayers[player]["chat"]
end
tableOut[player]["groups"] = "None"
Expand Down