RefreshResources: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added missing optional argument, for correctness' sake)
No edit summary
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool refreshResources ( [ bool refreshAll = false ] )
bool refreshResources ( [ bool refreshAll = false, resource targetResource = nil ] )
</syntaxhighlight>
</syntaxhighlight>


Line 11: Line 11:
{{OptionalArg}}
{{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
*'''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''.
'''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''.


Line 26: Line 28:
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}}

Revision as of 01:09, 8 October 2017

This function finds new resources and checks for changes to the current ones.

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
ADDED/UPDATED IN VERSION 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 true is refresh was successful, false otherwise.

Example

Click to collapse [-]
Server

This 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