ZH-CN/aclReload: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(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...")
 
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 -->
This function reloads the ACL's and the ACL groups from the ACL XML file. All ACL and ACL group elements are invalid after a call to this and should not be used anymore.
此函数用于从ACL XML文件重新加载ACL和ACL组。所有ACL和ACL组元素在调用后都无效,不应再使用.


==Syntax==  
==语法==  
<!-- 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|This function is a static function underneath the ACL class.|[[ACL]].reload||}}
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].reload||}}
===Returns===
===返回值===
<!-- 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 -->
Returns ''true'' if the XML was successfully reloaded from the file, ''false'' or ''nil'' if the XML was invalid, didn't exist or could not be loaded for some other reason.
如果XML已成功从文件中重新加载,则返回“true”;如果XML无效、不存在或由于其他原因无法加载,则返回“false”或“nil”.


==Example==  
==示例==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example allows an admin to reload the ACL by typing "/reloadACL".
此示例允许管理员通过键入“/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 )
-- Check if they're an admin...
-- 检查他们是不是管理员...
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then
local reload = aclReload() -- Reload the ACL
local reload = aclReload() -- 重新加载ACL
if ( reload ) then -- Check it was reloaded successfully
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 -- If not, output it (line below)
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 -- If they're not an admin, output it (below)
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}}
[[zh-cn:aclReload]]
[[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