ZH-CN/aclGroupAddObjectServer: Difference between revisions
Jump to navigation
Jump to search
Qwe7769611 (talk | contribs) No edit summary |
mNo edit summary |
||
(3 intermediate revisions by one other user not shown) | |||
Line 8: | Line 8: | ||
''resource.<resourcename>'' | ''resource.<resourcename>'' | ||
对象被指定为字符串。ACL组用于用户帐户和其中指定的资源. | |||
== | ==语法== | ||
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --> | <!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 16: | Line 16: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[aclgroup]]:addObject||}} | {{OOP||[[aclgroup]]:addObject||}} | ||
=== | ===必填参数=== | ||
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --> | <!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --> | ||
*'''theGroup:''' | *'''theGroup:''' 要添加对象名称字符串的组. | ||
*'''theObjectName:''' | *'''theObjectName:''' 要添加到给定ACL的对象字符串. | ||
=== | ===返回值=== | ||
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | <!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | ||
如果对象已成功添加到ACL,则返回“true”;如果对象已存在于列表中,则返回“false”. | |||
== | ==示例== | ||
<!-- Explain what the example is in a single sentance --> | <!-- Explain what the example is in a single sentance --> | ||
这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,这个命令会将一个特定的帐户名作为ACL对象添加到“Admin”组中. | |||
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | <!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function giveAdminRights (playerSource, commandName, accountName) -- | function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数 | ||
if accountName then -- | if accountName then --如果输入了accountName | ||
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) -- | aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin” | ||
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) -- | outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加 | ||
else -- | else --否则,将错误消息和命令的正确语法输出给输入它的玩家 | ||
outputChatBox ("No account name specified.", playerSource) | outputChatBox ("No account name specified.", playerSource) | ||
outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource) | outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource) | ||
Line 40: | Line 40: | ||
end | end | ||
addCommandHandler ("giveAccountAdminRights", giveAdminRights) -- | addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 46: | Line 46: | ||
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
{{ACL_functions}} | {{ACL_functions}} | ||
[[en:aclGroupAddObjectServer]] | |||
[[ar:aclGroupAddObjectServer]] | |||
[[en:AclGroupAddObjectServer]] | |||
[[zh-cn:aclGroupAddObjectServer]] |
Latest revision as of 18:29, 21 February 2021
此函数用于将对象添加到给定的ACL组。对象可以是玩家的帐户,指定为:
user.<accountname>
或者是资源,指定为:
resource.<resourcename>
对象被指定为字符串。ACL组用于用户帐户和其中指定的资源.
语法
bool aclGroupAddObject ( aclgroup theGroup, string theObjectName )
OOP Syntax Help! I don't understand this!
- Method: aclgroup:addObject(...)
必填参数
- theGroup: 要添加对象名称字符串的组.
- theObjectName: 要添加到给定ACL的对象字符串.
返回值
如果对象已成功添加到ACL,则返回“true”;如果对象已存在于列表中,则返回“false”.
示例
这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,这个命令会将一个特定的帐户名作为ACL对象添加到“Admin”组中.
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数 if accountName then --如果输入了accountName aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin” outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加 else --否则,将错误消息和命令的正确语法输出给输入它的玩家 outputChatBox ("No account name specified.", playerSource) outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource) end end addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中
See Also
- aclCreate
- aclCreateGroup
- aclDestroy
- aclDestroyGroup
- aclGet
- aclGetGroup
- aclGetName
- aclGetRight
- aclGroupAddACL
- aclGroupAddObject
- aclGroupGetName
- aclGroupList
- aclGroupListACL
- aclGroupListObjects
- aclGroupRemoveACL
- aclGroupRemoveObject
- aclList
- aclListRights
- aclReload
- aclRemoveRight
- aclSave
- aclSetRight
- hasObjectPermissionTo
- isObjectInACLGroup