-
-
Notifications
You must be signed in to change notification settings - Fork 171
admin2: replace give admin button with permissions widget #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fd1086a
a6be73a
f8139af
4b21e42
5397981
ac7a176
52d078a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
There was a problem hiding this comment.
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?"