ZH-CN/aclReload: Difference between revisions
Jump to navigation
Jump to search
Qwe7769611 (talk | contribs) (Created page with "__NOTOC__ {{Server function}} <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> This function reloads the ACL's and th...") |
Qwe7769611 (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
{{Server function}} | {{Server function}} | ||
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | ||
此函数用于从ACL XML文件重新加载ACL和ACL组。所有ACL和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"> | ||
bool aclReload () | bool aclReload () | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{ | {{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].reload||}} | ||
=== | ===返回值=== | ||
<!-- 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 --> | ||
如果XML已成功从文件中重新加载,则返回“true”;如果XML无效、不存在或由于其他原因无法加载,则返回“false”或“nil”. | |||
== | ==示例== | ||
<!-- Explain what the example is in a single sentance --> | <!-- Explain what the example is in a single sentance --> | ||
此示例允许管理员通过键入“/reloadACL”来重新加载ACL. | |||
<!-- 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 reloadACL ( source, command ) | function reloadACL ( source, command ) | ||
-- | -- 检查他们是不是管理员... | ||
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then | if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then | ||
local reload = aclReload() -- | local reload = aclReload() -- 重新加载ACL | ||
if ( reload ) then -- | if ( reload ) then -- 检查是否已成功重新加载 | ||
outputChatBox ( "ACL was successfully reloaded.", source, 255, 0, 0 ) -- If so, output it | outputChatBox ( "ACL was successfully reloaded.", source, 255, 0, 0 ) -- If so, output it | ||
else -- | else -- 如果没有,输出下面一行↓ | ||
outputChatBox ( "An unknown error occured. Please check the ACL file exists.", source, 255, 0, 0 ) | outputChatBox ( "An unknown error occured. Please check the ACL file exists.", source, 255, 0, 0 ) | ||
end | end | ||
else -- | else -- 如果他们不是管理员,输出下面一行↓ | ||
outputChatBox ( "You must be an admin to use this command!", source, 255, 0, 0 ) | outputChatBox ( "You must be an admin to use this command!", source, 255, 0, 0 ) | ||
end | end | ||
Line 38: | Line 38: | ||
<!-- 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:aclReload]] |
Latest revision as of 07:08, 6 February 2021
此函数用于从ACL XML文件重新加载ACL和ACL组。所有ACL和ACL组元素在调用后都无效,不应再使用.
语法
bool aclReload ()
OOP 语法 什么是OOP?
- 提示: This function is a static function underneath the ACL class.
- 方法: ACL.reload(...)
返回值
如果XML已成功从文件中重新加载,则返回“true”;如果XML无效、不存在或由于其他原因无法加载,则返回“false”或“nil”.
示例
此示例允许管理员通过键入“/reloadACL”来重新加载ACL.
function reloadACL ( source, command ) -- 检查他们是不是管理员... if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then local reload = aclReload() -- 重新加载ACL if ( reload ) then -- 检查是否已成功重新加载 outputChatBox ( "ACL was successfully reloaded.", source, 255, 0, 0 ) -- If so, output it else -- 如果没有,输出下面一行↓ outputChatBox ( "An unknown error occured. Please check the ACL file exists.", source, 255, 0, 0 ) end else -- 如果他们不是管理员,输出下面一行↓ outputChatBox ( "You must be an admin to use this command!", source, 255, 0, 0 ) end end addCommandHandler ( "reloadACL", reloadACL )
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