AclSave: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> This fake function is for use with blah & blah and does blahblahblabhalb...)
 
No edit summary
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{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 fake function is for use with blah & blah and does blahblahblabhalbhl
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.


==Syntax==  
==Syntax==  
Line 8: Line 9:
bool aclSave ()
bool aclSave ()
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP|This function is a static function underneath the ACL class.|[[ACL]].save||}}
===Required Arguments===
<!-- 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 -->
*'''argumentName:''' description
 
<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===
{{OptionalArg}}  
*'''argumentName2:''' description
*'''argumentName3:''' description
 
===Returns===
===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 blah, ''false'' otherwise.
Returns ''true'' if the ACL was successfully changed, ''false'' or ''nil'' if it could not be saved for some reason, ie. file in use.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example does...
This example saves the ACL when somebody types "/save-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">
--This line does...
function saveACL ( thePlayer, command ) -- Function header. Also where thePlayer is defined.
blabhalbalhb --abababa
local saved = aclSave() -- Save the ACL
--This line does this...
if ( saved ) then -- If it was successfully saved then...
mooo
outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- Output it saved
else -- If it wasn't saved for whatever reason then...
outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- Output it didn't save
end
end
addCommandHandler ( "save-acl", saveACL ) -- Make it trigger for "/save-acl".
</syntaxhighlight>
</syntaxhighlight>


Line 37: 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}}
[[Category:Incomplete]] -- leave this unless you complete the function
[[zh-cn:aclSave]]

Latest revision as of 08:37, 5 February 2021

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.

Syntax

bool aclSave ()

OOP Syntax Help! I don't understand this!

Note: This function is a static function underneath the ACL class.
Method: ACL.save(...)


Returns

Returns true if the ACL was successfully changed, false or nil if it could not be saved for some reason, ie. file in use.

Example

This example saves the ACL when somebody types "/save-acl".

function saveACL ( thePlayer, command ) -- Function header. Also where thePlayer is defined.
	local saved = aclSave() -- Save the ACL
		if ( saved ) then -- If it was successfully saved then...
			outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- Output it saved
		else -- If it wasn't saved for whatever reason then...
			outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- Output it didn't save
		end
end
addCommandHandler ( "save-acl", saveACL ) -- Make it trigger for "/save-acl".

See Also