AclObjectGetGroups: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This function returns a table of all groups the object is in. ==Syntax== <syntaxhighlight lang="lua"> table aclObjectGetGroups ( string object ) </syntaxhighlight> ===Required Arguments=== * '''object:''' The name of the ACL entry to get groups of ===Returns=== Returns a table of all groups the object is in on success, false if something went wrong. ==Examples== This example outputs a list of all groups of the calling user <section...")
 
m (Improved example)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
{{New items|3.0161|1.6.0|
This function returns a table of all groups the object is in.
This function returns a table of all groups the object is in.
|22273}}


==Syntax==  
==Syntax==  
Line 23: Line 25:


outputChatBox('Groups:', player)
outputChatBox('Groups:', player)
local groups = aclObjectGetGroups('user.'..getAccountName(account))


for _,v in ipairs(aclObjectGetGroups('user.'..getAccountName(account)) do
for _,v in ipairs(groups) do
outputChatBox('* '..aclGroupGetName(v))
outputChatBox('* '..aclGroupGetName(v))
end
end

Latest revision as of 06:27, 19 October 2023

ADDED/UPDATED IN VERSION 1.6.0 r22273:

This function returns a table of all groups the object is in.

Syntax

table aclObjectGetGroups ( string object )

Required Arguments

  • object: The name of the ACL entry to get groups of

Returns

Returns a table of all groups the object is in on success, false if something went wrong.

Examples

This example outputs a list of all groups of the calling user

Click to collapse [-]
addCommandHandler("listGroups",function(player)
	local account = getPlayerAccount(player)
	if not account or isGuestAccount(account) then return end

	outputChatBox('Groups:', player)
	local groups = aclObjectGetGroups('user.'..getAccountName(account)) 

	for _,v in ipairs(groups) do
		outputChatBox('* '..aclGroupGetName(v))
	end
end)


See Also