IsObjectInACLGroup: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 16: Line 16:


==Example==  
==Example==  
 
This example adds a "jetpack" command that is only available to admins.  When entering the command, it will toggle the player's jetpack.
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
--TODO
</syntaxhighlight>
addCommandHandler ( "jetpack",
function(player)
--If the player has a jetpack already, remove it
if doesPedHaveJetPack ( player ) then
removePedJetPack ( player ) --Remove the jetpack
return --And stop the function here
end
--Otherwise, give him one and check if he has access
local playerName = getClientName(responsiblePlayer)
--Does he have access to Admin functions?
if isObjectInACLGroup ( "user."..playerName, aclGetGroup"Admin" ) then
--He's an admin.  Give him a jetpack
givePedJetPack ( player )
end
end
)
</section>
</section>



Revision as of 22:32, 30 March 2009

This function is used to determine if an object is in a group.

Syntax

bool isObjectInACLGroup ( string theObject, string theGroup )

Required Arguments

  • theObject: the name of the object to check. Examples: "resource.ctf", "user.Jim".
  • theGroup: the name of the group to look in. Example: "Admin"

Returns

Returns true if the object is in the specified group, false otherwise.

Example

This example adds a "jetpack" command that is only available to admins. When entering the command, it will toggle the player's jetpack.

Click to collapse [-]
Server

<syntaxhighlight lang="lua"> --TODO addCommandHandler ( "jetpack", function(player) --If the player has a jetpack already, remove it if doesPedHaveJetPack ( player ) then removePedJetPack ( player ) --Remove the jetpack return --And stop the function here end

--Otherwise, give him one and check if he has access local playerName = getClientName(responsiblePlayer) --Does he have access to Admin functions? if isObjectInACLGroup ( "user."..playerName, aclGetGroup"Admin" ) then --He's an admin. Give him a jetpack givePedJetPack ( player ) end end )

See Also