Difference between revisions of "GetPlayersInACLGroup"

From Multi Theft Auto: Wiki
(Created page with "==Syntax== <syntaxhighlight lang="lua">table getPlayersInGroup ( string GroupName )</syntaxhighlight> ===Required Arguments=== * '''GroupName''': A string Group Name To Get All Players In It ===Retur...")
 
(Syntax)
Line 7: Line 7:
 
===Returns===
 
===Returns===
 
Returns All Players In Groups if it was Argument true , And vice false
 
Returns All Players In Groups if it was Argument true , And vice false
 +
 +
==Code==
 +
<section name="Server" class="server" show="true"><syntaxhighlight lang="lua">
 +
function getPlayersInGroup ( GroupName )
 +
 +
    local aTable = {}
 +
 +
    assert ( tostring ( GroupName ) , "Bad Argument At Argument #1 Group Moust String" )
 +
 
 +
    assert ( aclGetGroup ( tostring ( GroupName ) ) , "Bad Argument At Argument #1 Group not Found "  )
 +
 
 +
    for i , player_ in ipairs ( getElementsByType ( "player" ) ) do
 +
 
 +
    local TheAcc =  getPlayerAccount ( player_ )
 +
 
 +
    if not isGuestAccount ( TheAcc ) then 
 +
 +
    if isObjectInACLGroup ( "user." ..getAccountName ( TheAcc ) , aclGetGroup ( tostring ( GroupName ) ) ) then
 +
   
 +
    table.insert ( aTable , player_ )
 +
            end 
 +
        end
 +
    end
 +
    return aTable
 +
end
 +
</syntaxhighlight></section>

Revision as of 05:16, 7 May 2016

Syntax

table getPlayersInGroup ( string GroupName )

Required Arguments

  • GroupName: A string Group Name To Get All Players In It

Returns

Returns All Players In Groups if it was Argument true , And vice false

Code

Click to collapse [-]
Server
function getPlayersInGroup ( GroupName )
 
    local aTable = {}
 
    assert ( tostring ( GroupName ) , "Bad Argument At Argument #1 Group Moust String" )
   
    assert ( aclGetGroup ( tostring ( GroupName ) ) , "Bad Argument At Argument #1 Group not Found "  )
   
    for i , player_ in ipairs ( getElementsByType ( "player" ) ) do
   
    local TheAcc =  getPlayerAccount ( player_ )
   
    if not isGuestAccount ( TheAcc ) then  
 
    if isObjectInACLGroup ( "user." ..getAccountName ( TheAcc ) , aclGetGroup ( tostring ( GroupName ) ) ) then
     
    table.insert ( aTable , player_ )
             end  
        end
    end 
    return aTable
end