Jump to content

Give Permissions Panel - need help


dewu

Recommended Posts

Hi guys.

I find this script: viewtopic.php?f=108&t=52663

and i want when type /gpp, view only one group (VIP) on right listed. How to do that?

This get all ACL Groups:

-- get groups 
addEvent("getGroups",true) 
addEventHandler("getGroups",root, 
    function () 
    groups = {} 
            for i,group in ipairs(aclGroupList()) do -- get all groups 
            table.insert(groups,aclGroupGetName(group)) 
            end 
               for i,v in ipairs(groups) do -- get all groups in table 
                triggerClientEvent(source,"addGroups",source,v) 
                end 
            end 
) 

but i want only ONE.

Link to comment
  
-- get groups 
addEvent("getGroups",true) 
addEventHandler("getGroups",root, 
    function () 
    groups = {} 
            for i,group in ipairs(aclGroupList()) do -- get all groups 
             if aclGroupGetName(group) == "VIP" then  
            table.insert(groups,aclGroupGetName(group)) 
            end 
            end 
               for i,v in ipairs(groups) do -- get all groups in table 
                triggerClientEvent(source,"addGroups",source,v) 
                end 
            end 
) 
  

Link to comment

Ow, it's working, thanks!

Anothers, i'm trying to create ACL object listing:

  
addEvent("getGroups",true) 
addEventHandler("getGroups",root, 
    function () 
    objects = {} 
            for i,object in ipairs(aclGroupListObjects(aclGetGroup(allowedGroup))) do -- get all groups 
            table.insert(objects,getAccountName(object)) 
            end 
               for i,v in ipairs(objects) do -- get all groups in table 
                triggerClientEvent(source,"addGroups",source,v) 
                end 
            end 
) 
  

but i've got these error:

  
[2015-02-03 20:05:56] WARNING: gpp\server.lua:22: Bad argument @ 'getAccountName' [Expected account at argument 1, got string 'user.143'] 
[2015-02-03 20:05:56] WARNING: gpp\server.lua:22: Bad argument @ 'getAccountName' [Expected account at argument 1, got string 'user.155'] 
[2015-02-03 20:05:56] WARNING: gpp\server.lua:22: Bad argument @ 'getAccountName' [Expected account at argument 1, got string 'user.150'] 
[2015-02-03 20:05:56] WARNING: gpp\server.lua:22: Bad argument @ 'getAccountName' [Expected account at argument 1, got string 'user.dewu'] 
  

Link to comment

Try it:

addEvent("getGroups",true) 
addEventHandler("getGroups",root, function() 
    objects = {} 
    for i,object in ipairs(aclGroupListObjects(aclGetGroup(allowedGroup))) do -- get all groups 
        table.insert(objects,string.gsub(object, "user.","")) 
    end 
    for i,v in ipairs(objects) do -- get all groups in table 
        triggerClientEvent(source,"addGroups",source,v) 
    end 
end) 

Edited by Guest
Link to comment

Sometimes this error can give.

addEvent("getGroups",true) 
addEvent("getGroups",true) 
addEventHandler("getGroups",root, function() 
    objects = {} 
    for i,object in ipairs(aclGroupListObjects(aclGetGroup(allowedGroup))) do -- get all groups 
        local account_name = string.gsub(object, "user.", "") 
        table.insert(objects,account_name) 
    end 
    for i,v in ipairs(objects) do -- get all groups in table 
        triggerClientEvent(source,"addGroups",source,v) 
    end 
end) 
  

Link to comment

One more question, please!

I'd like to have option with removing listed objects.

There is script to remove player from chosen group:

-- remove player from chosen group 
addEvent("remove_g",true) 
addEventHandler("remove_g",root, 
    function (splayer,sgroup) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup(allowedGroup)) then 
        if not isGuestAccount(getPlayerAccount(getPlayerFromName(tostring(splayer)))) then 
        aclGroupRemoveObject (aclGetGroup(sgroup), "user."..getAccountName(getPlayerAccount(getPlayerFromName(splayer)))) 
        outputChatBox("* "..splayer.." successfully removed from "..sgroup.."",source,0,255,0) 
        outputChatBox("* You've been removed from "..sgroup.."",getPlayerFromName(splayer),255,0,0) 
        else 
        outputChatBox("* You can't remove "..splayer.." from "..sgroup.." because he is not logged in",source,255,0,0) 
        end 
    else 
    outputChatBox("* You don't have rights to do this.",source,255,0,0) 
    outputDebugString("* "..getPlayerName(source).." had attempted to hack the server",2) 
    end 
end 
) 

"user."..getAccountName(getPlayerAccount(getPlayerFromName(splayer)))) 

but the question is: how to get object from chosen group and remove it?

Link to comment

I already tried but, but it's not working.

addEvent("remove_g",true) 
addEventHandler("remove_g",root, 
    function (splayer,sgroup) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup(allowedGroup)) then 
        aclGroupRemoveObject (aclGetGroup(sgroup), "user."..getAccountPlayer ( splayer )) 
        outputChatBox("* "..splayer.." succesfully removed..",source,0,255,0) 
        outputChatBox("* You have been removed by "..getPlayerName(source).."",getPlayerFromName(splayer),0,255,0) 
  
    outputDebugString("* "..getPlayerName(source).." had attempted to hack the server",2) 
end 
end) 

Link to comment

Aww.. okay. splayer is a part of client-side script:

GUIEditor = { 
    gridlist = {}, 
    button = {}, 
    label = {}, 
    window = {}, 
} 
gpp = guiCreateWindow(126, 100, 802, 346, "Panel właściciela bazy", false) 
guiSetVisible(gpp,false) 
guiWindowSetSizable(gpp, false) 
guiSetAlpha(gpp, 1.00) 
  
pgrid = guiCreateGridList(34, 51, 225, 232, false, gpp) 
pc = guiGridListAddColumn(pgrid, "Gracze online :", 0.9) 
GUIEditor.label[1] = guiCreateLabel(42, 25, 121, 19, "1 - Wybierz gracza :", false, gpp) 
  
dgrid = guiCreateGridList(526, 51, 221, 232, false, gpp) 
dc = guiGridListAddColumn(dgrid, "Lokatorzy :", 0.9) 
GUIEditor.label[1] = guiCreateLabel(530, 25, 121, 19, "1 - Wybierz lokatora :", false, gpp) 
  
ggrid = guiCreateGridList(280, 51, 223, 232, false, gpp) 
gc = guiGridListAddColumn(ggrid, "Twoje bazy :", 0.9) 
GUIEditor.label[2] = guiCreateLabel(286, 25, 121, 19, "2 - Wybierz bazę  :", false, gpp) 
  
add = guiCreateButton(45, 293, 202, 39, "Dodaj ", false, gpp) 
guiSetProperty(add, "NormalTextColour", "FF00FF00") 
remove = guiCreateButton(536, 293, 202, 39, "Wyrzuć ", false, gpp) 
guiSetProperty(remove, "NormalTextColour", "FFFF0000") 
x = guiCreateButton(770, 23, 20, 18, "X", false, gpp) 
  
  
  
addEvent("show_gpp",true) 
addEventHandler("show_gpp",root, 
    function () 
    guiSetVisible(gpp,true) 
    showCursor(true) 
    clear() 
    triggerServerEvent ("getGroups", getLocalPlayer()) 
    triggerServerEvent ("getLocators", getLocalPlayer()) 
    addPlayers() 
    end 
) 
  
  
    function clear() 
guiGridListClear (ggrid) 
guiGridListClear (pgrid) 
guiGridListClear (dgrid) 
    end 
  
  
addEvent("refreshg",true) 
addEventHandler("refreshg",root, 
    function () 
    clear() 
    end 
) 
  
addEvent("addGroups",true) 
addEventHandler("addGroups",root, 
    function (v) 
    guiGridListSetItemText ( ggrid, guiGridListAddRow ( ggrid ), gc,v, false, false ) 
    end 
) 
  
addEvent("addLocators",true) 
addEventHandler("addLocators",root, 
    function (v) 
    guiGridListSetItemText ( dgrid, guiGridListAddRow ( dgrid ), dc,v, false, false ) 
    end 
) 
  
  
  
function addPlayers() 
    for i,player in ipairs(getElementsByType("player")) do 
            local row = guiGridListAddRow(pgrid) 
            guiGridListSetItemText ( pgrid, row, pc, (string.gsub(getPlayerName(player),'#%x%x%x%x%x%x','') or getPlayerName(player)), false, false) 
            guiGridListSetItemData ( pgrid, row, pc, getPlayerName(player)) 
    end 
end 
  
addEventHandler ( "onClientGUIClick",pgrid, 
function () 
splayer = guiGridListGetItemText ( pgrid, guiGridListGetSelectedItem ( pgrid ), 1 ) 
sgroup = guiGridListGetItemText ( ggrid, guiGridListGetSelectedItem ( ggrid ), 1 ) 
guiSetText(add,"Dodaj "..splayer.." do "..sgroup.."") 
guiSetText(remove,"Wyrzuć ") 
end 
) 
  
addEventHandler ( "onClientGUIClick",ggrid, 
function () 
splayer = guiGridListGetItemText ( pgrid, guiGridListGetSelectedItem ( pgrid ), 1 ) 
sgroup = guiGridListGetItemText ( ggrid, guiGridListGetSelectedItem ( ggrid ), 1 ) 
guiSetText(add,"Dodaj "..splayer.." do "..sgroup.."") 
guiSetText(remove,"Wyrzuć ") 
end) 
  
addEventHandler ( "onClientGUIClick",dgrid, 
function () 
slocator = guiGridListGetItemText ( dgrid, guiGridListGetSelectedItem ( dgrid ), 1 ) 
sgroup = guiGridListGetItemText ( ggrid, guiGridListGetSelectedItem ( ggrid ), 1 ) 
guiSetText(add,"Dodaj ") 
guiSetText(remove,"Wyrzuć "..slocator.." z "..sgroup.."") 
end) 
  
function onGuiClick (button, state, absoluteX, absoluteY) 
   if (source == add) then 
    if splayer and sgroup then 
    triggerServerEvent("add_g", getLocalPlayer(), guiGridListGetItemData(pgrid, guiGridListGetSelectedItem ( pgrid ), 1),sgroup) 
    end 
    elseif (source == remove) then 
    if slocator and sgroup then 
    triggerServerEvent("remove_g", getLocalPlayer(), guiGridListGetItemData(dgrid, guiGridListGetSelectedItem ( dgrid ), 1),sgroup) 
    end 
    elseif (source == x) then 
    guiSetVisible(gpp,false) 
    showCursor(false) 
     end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 

mean splayer is selected object on list.

splayer = guiGridListGetItemText ( pgrid, guiGridListGetSelectedItem ( pgrid ), 1 ) 

Link to comment

But i can't trigger ACL object, i think ;c

At least, i'm trying do that second day..

When i try do that by

Client:

triggerServerEvent("remove_g", getLocalPlayer(), guiGridListGetItemData(dgrid, guiGridListGetSelectedItem ( dgrid ), 1),splayer) 

Server:

aclGroupRemoveObject (aclGetGroup(allowedGroup), "user."..splayer) 

i got nil value:

[2015-02-04 15:38:45] ERROR: gpa\server.lua:53: attempt to concatenate local 'splayer' (a nil value) 

splayer - is selected ACL object on list

dgrid - is a grid where objects were listed

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...