Difference between revisions of "GetPlayersInACLGroup"

From Multi Theft Auto: Wiki
(Syntax)
(Code)
Line 33: Line 33:
 
end
 
end
 
</syntaxhighlight></section>
 
</syntaxhighlight></section>
 +
 +
==Example==
 +
This example gets Player In Group specific and Kill Players This Group
 +
<syntaxhighlight lang="lua">
 +
addCommandHandler ( "killPlayerGroup", 
 +
 +
function ( _ , _ , GroupName_ )
 +
 +
Players = getPlayersInGroup (  GroupName_  )
 +
 +
for i , PlayersGroup in ipairs ( Players ) do
 +
 +
killPed ( PlayersGroup )
 +
        end
 +
    end
 +
    ) ;
 +
 
 +
-- F8 Say : killPlayerGroup Console
 +
</syntaxhighlight>
 +
 +
 +
==Example 2==
 +
This example gets Player In Group specific and Give Players Money This Group
 +
<syntaxhighlight lang="lua">
 +
addCommandHandler("GiveGroupMoney",
 +
 +
function ( p , _ , Group_ , aMoney )
 +
 +
    Players = getPlayersInGroup ( Group_ )
 +
 +
    for i , PlayersGroup in ipairs ( Players ) do
 +
 +
    givePlayerMoney ( PlayersGroup , tonumber ( aMoney ) )
 +
 +
    end
 +
end
 +
    ) ;
 +
 +
--F8 Say : GiveGroupMoney Console 500
 +
</syntaxhighlight>
 +
 +
 +
Author: Abdul_KariM
 +
 +
skype : kreee89

Revision as of 05:18, 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

Example

This example gets Player In Group specific and Kill Players This Group

addCommandHandler ( "killPlayerGroup",  
 
function ( _ , _ , GroupName_ )
 
Players = getPlayersInGroup (  GroupName_  )
 
for i , PlayersGroup in ipairs ( Players ) do
 
killPed ( PlayersGroup )
        end
    end
    ) ;
   
-- F8 Say : killPlayerGroup Console


Example 2

This example gets Player In Group specific and Give Players Money This Group

addCommandHandler("GiveGroupMoney",
 
function ( p , _ , Group_ , aMoney )
 
    Players = getPlayersInGroup ( Group_ )
 
    for i , PlayersGroup in ipairs ( Players ) do
 
    givePlayerMoney ( PlayersGroup , tonumber ( aMoney ) )
 
    end
end
    ) ;
 
--F8 Say : GiveGroupMoney Console 500


Author: Abdul_KariM

skype : kreee89