RefreshResources: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Server function}} __NOTOC__ This function finds new resources and checks for changes to the current ones. ==Syntax== <syntaxhighlight lang="lua"> bool refreshResources ( ) </syntaxhighlight> ===Retur...") |
m (Note highlights) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This function finds new resources and checks for changes to the current ones. | This function finds new resources and checks for changes to the current ones. | ||
{{Note|The resource using this function needs access to ''function.refreshResources'' in order for this function to work. You can give it the access by including an [[Server_Commands#aclrequest|aclrequest]] command in its [[meta.xml]] file or by adding it to the admin [[ACL]] group.}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool refreshResources ( ) | bool refreshResources ( [ bool refreshAll = false, resource targetResource = nil ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
*'''refreshAll''': If ''true'' MTA will check for changes in all resources. If ''false'', MTA will only check for new resources and try to reload resources with errors | |||
{{New items|5.0155|1.5.5-9.11718| | |||
*'''targetResource''': If set, the refresh is restricted to the supplied resource only | |||
}} | |||
'''Note:''' Checking for changes in all resources can result in lag for a short period of time. It should generally be avoided to set refreshAll to ''true''. | |||
===Returns=== | ===Returns=== | ||
Returns true | Returns true if refresh was successful, false otherwise. | ||
==Example== | ==Example== | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
This example will refresh resources when a player uses the /refreshresources command just like the hardcoded / | This example will refresh resources when a player uses the /refreshresources command just like the hardcoded /refreshall. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function commandRefreshResources() | function commandRefreshResources(player) | ||
refreshResources() | refreshResources(true) | ||
outputChatBox("Resources refreshed", player, 255, 255, 0) | outputChatBox("Resources refreshed", player, 255, 255, 0) | ||
end | end | ||
addCommandHandler("refreshresources", commandRefreshResources) | addCommandHandler("refreshresources", commandRefreshResources) | ||
</syntaxhighlight> | |||
This example will refresh only the named resource: | |||
<syntaxhighlight lang="lua"> | |||
refreshResources(true, getResourceFromName("admin")) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
==Changelog== | |||
{{ChangelogHeader}} | |||
{{ChangelogItem|1.5.5-9.11718|Added targetResource argument}} | |||
==See Also== | ==See Also== | ||
{{Resource_functions}} | {{Resource_functions}} |
Latest revision as of 22:04, 17 May 2021
This function finds new resources and checks for changes to the current ones.
Note: The resource using this function needs access to function.refreshResources in order for this function to work. You can give it the access by including an aclrequest command in its meta.xml file or by adding it to the admin ACL group. |
Syntax
bool refreshResources ( [ bool refreshAll = false, resource targetResource = nil ] )
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- refreshAll: If true MTA will check for changes in all resources. If false, MTA will only check for new resources and try to reload resources with errors
Note: Checking for changes in all resources can result in lag for a short period of time. It should generally be avoided to set refreshAll to true.
Returns
Returns true if refresh was successful, false otherwise.
Example
Click to collapse [-]
ServerThis example will refresh resources when a player uses the /refreshresources command just like the hardcoded /refreshall.
function commandRefreshResources(player) refreshResources(true) outputChatBox("Resources refreshed", player, 255, 255, 0) end addCommandHandler("refreshresources", commandRefreshResources)
This example will refresh only the named resource:
refreshResources(true, getResourceFromName("admin"))
Changelog
Version | Description |
---|
1.5.5-9.11718 | Added targetResource argument |
See Also
- abortRemoteRequest
- addResourceConfig
- addResourceMap
- call
- callRemote
- copyResource
- createResource
- deleteResource
- fetchRemote
- getRemoteRequestInfo
- getRemoteRequests
- getResourceACLRequests
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceInfo
- getResourceLastStartTime
- getResourceLoadFailureReason
- getResourceLoadTime
- getResourceMapRootElement
- getResourceName
- getResourceOrganizationalPath
- getResourceRootElement
- getResources
- getResourceState
- getThisResource
- isResourceArchived
- isResourceProtected
- refreshResources
- removeResourceFile
- renameResource
- restartResource
- setResourceInfo
- startResource
- stopResource
- updateResourceACLRequest