ZH-CN/aclSave: 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 --> The ACL XML file is automatically save...")
 
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 -->
The ACL XML file is automatically saved whenever the ACL is modified, but the automatic save can be delayed by up to 10 seconds for performance reasons. Calling this function will force an immediate save.  
每当修改ACL时,ACL XML文件都会自动保存,但出于性能原因,自动保存最多可延迟10秒。调用此函数将强制立即保存.  


==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 aclSave ()
bool aclSave ()
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP|This function is a static function underneath the ACL class.|[[ACL]].save||}}
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].save||}}
===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 ACL was successfully changed, ''false'' or ''nil'' if it could not be saved for some reason, ie. file in use.
如果ACL已成功更改,则返回“true”;如果由于某种原因(如文件正在使用)无法保存,则返回“false”或“nil”.


==Example==  
==示例==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example saves the ACL when somebody types "/save-acl".
此示例在有人键入“/save ACL”时保存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 saveACL ( thePlayer, command ) -- Function header. Also where thePlayer is defined.
function saveACL ( thePlayer, command ) -- 函数标题.也是定义图层的地方
local saved = aclSave() -- Save the ACL
local saved = aclSave() -- 保存ACL
if ( saved ) then -- If it was successfully saved then...
if ( saved ) then -- 如果成功保存,则...
outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- Output it saved
outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- 输出已保存
else -- If it wasn't saved for whatever reason then...
else -- If it wasn't saved for whatever reason then...
outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- Output it didn't save
outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- 输出它没有保存输出
end
end
end
end
addCommandHandler ( "save-acl", saveACL ) -- Make it trigger for "/save-acl".
addCommandHandler ( "save-acl", saveACL ) -- 使其触发“/save-acl”
</syntaxhighlight>
</syntaxhighlight>


Line 33: Line 33:
<!-- 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:aclSave]]
[[en:aclSave]]

Latest revision as of 07:13, 6 February 2021

每当修改ACL时,ACL XML文件都会自动保存,但出于性能原因,自动保存最多可延迟10秒。调用此函数将强制立即保存.

语法

bool aclSave ()

OOP 语法 什么是OOP?

提示: This function is a static function underneath the ACL class.
方法: ACL.save(...)

返回值

如果ACL已成功更改,则返回“true”;如果由于某种原因(如文件正在使用)无法保存,则返回“false”或“nil”.

示例

此示例在有人键入“/save ACL”时保存ACL.

function saveACL ( thePlayer, command ) -- 函数标题.也是定义图层的地方
	local saved = aclSave() -- 保存ACL
		if ( saved ) then -- 如果成功保存,则...
			outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- 输出已保存
		else -- If it wasn't saved for whatever reason then...
			outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- 输出它没有保存输出
		end
end
addCommandHandler ( "save-acl", saveACL ) -- 使其触发“/save-acl”

See Also