Jump to content

table


Sasu

Recommended Posts

Posted (edited)

Client:

function obtenerIPSerialPing(serial, ip, account, groups) 
guiSetText(serialLabel, "Serial: "..serial) 
guiSetText(IPLabel, "IP: "..ip) 
guiSetText(accountLabel, "Cuenta: "..account) 
guiSetText(aclLabel, "Derechos en ACL: "..table["groups"]) 
end 
addEvent("getData", true) 
addEventHandler("getData", root, obtenerIPSerialPing) 

Server:

function obtenerdatos(source, name) 
local player = getPlayerFromName(name) 
local serial = getPlayerSerial(player) 
local IP = getPlayerIP (player) 
local playerAcc = getPlayerAccount(player) 
local account = getAccountName(playerAcc) 
local groups = aclGetAccountGroups(playerAcc) 
triggerClientEvent(source, "getData", source, serial, IP, account, groups) 
end 
addEvent("datos", true) 
addEventHandler("datos", root, obtenerdatos) 

My error on debugscript 3:

ERROR: adminPanel\panel.lua:294: attempt to concatenate field 'groups'(a nil value)

I want that set text with the acl like the admin panel 'p' -> Groups: Admin, Everyone, etc

Can anybody help me?

Thanks in advance.

Edited by Guest
Posted
aclGetAccountGroups function doesn't exist.

https://wiki.multitheftauto.com/wiki/Se ... _functions

function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end 

Posted
aclGetAccountGroups function doesn't exist.

https://wiki.multitheftauto.com/wiki/Se ... _functions

function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end 

Ok, I could not see where the function was created.

Posted
aclGetAccountGroups function doesn't exist.

https://wiki.multitheftauto.com/wiki/Se ... _functions

function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end 

Ok, I could not see where the function was created.

And can you help me? :/

Posted

Try this:

guiSetText(aclLabel, "Derechos en ACL: "..table["groups"] or "None") 

Is really difficult to know where the problem is because the code isn't full.

Posted

The same problem.

Client:

aclLabel = guiCreateLabel(17, 87, 274, 15, "Derechos en ACL: N/A", false, tabPanelInfo1) 
  
addEventHandler("onClientGUIClick", root, 
function () 
if source == listaPlayers then 
local row,column = guiGridListGetSelectedItem(listaPlayers) 
if row == -1 then return end 
if row then 
getPlayerData(playerName) 
end 
end 
end 
) 
  
function obtenerIPSerialPing(serial, ip, account, groups) 
guiSetText(serialLabel, "Serial: "..serial) 
guiSetText(IPLabel, "IP: "..ip) 
guiSetText(accountLabel, "Cuenta: "..account) 
guiSetText(aclLabel, "Derechos en ACL: "..table["groups"] or "None") 
end 
addEvent("getData", true) 
addEventHandler("getData", root, obtenerIPSerialPing) 
  
function getPlayerData(name) 
triggerServerEvent("datos", root, localPlayer, name) 
end 

Server:

function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end 
  
function obtenerdatos(source, name) 
local player = getPlayerFromName(name) 
local serial = getPlayerSerial(player) 
local IP = getPlayerIP (player) 
local playerAcc = getPlayerAccount(player) 
local account = getAccountName(playerAcc) 
local groups = aclGetAccountGroups(playerAcc) 
triggerClientEvent(source, "getData", source, serial, IP, account, groups) 
end 
addEvent("datos", true) 
addEventHandler("datos", root, obtenerdatos) 

:/

Posted
Try this:
guiSetText(aclLabel, "Derechos en ACL: "..table["groups"] or "None") 

My bad.

local groups = table["groups"] or "None" 
guiSetText(aclLabel, "Derechos en ACL: "..groups) 

Posted

@DNL291: Where's "table" defined?

@Sasuke: Try this:

function obtenerIPSerialPing ( serial, ip, account, groups ) 
    guiSetText ( serialLabel, "Serial: ".. serial ) 
    guiSetText ( IPLabel, "IP: ".. ip ) 
    guiSetText ( accountLabel, "Cuenta: ".. account ) 
    guiSetText ( aclLabel, "Derechos en ACL: ".. table.concat ( groups, ", " ) ) 
end 
addEvent ( "getData", true ) 
addEventHandler ( "getData", root, obtenerIPSerialPing ) 

Posted

ERROR: adminPanel\panel.lua:313: bad argument #1 to 'concat' (table expected, got string)

:/

Posted
@DNL291: Where's "table" defined?

'table' is defined in Sasuke's code. If he had not set, he would have an error in debug. You can see that he is using 'table' in the first post.

It set "None" when I am admin. Why?

'table' or 'groups' is returning nil. Make sure that the table is defined.

Posted
ERROR: adminPanel\panel.lua:313: bad argument #1 to 'concat' (table expected, got string)

:/

Works fine here, so the problem must be somewhere else on your script.

My test script:

addCommandHandler ( "groups", 
    function ( p ) 
        outputChatBox ( table.concat ( aclGetAccountGroups ( getPlayerAccount ( p ) ), ", " ) ) 
    end 
) 
  
function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end 

Posted

It was happening that the triggerClientEvent was wrong.

Arguments in client function

function obtenerIPSerialPing ( serial, ip, account, groups ) 

Arguments passed that I had

triggerClientEvent(source, "getData", source, name, serial, IP, account, groups) 

So I deleted 'name' and now works . Stupid error :P.

Thank you very much solid.

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...