RefreshResources: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Added missing optional argument, for correctness' sake)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool refreshResources ( )
bool refreshResources ( [ bool refreshAll = false ] )
</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
'''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===
Line 13: Line 19:
==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 /refresh.
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(player)
function commandRefreshResources(player)
     refreshResources()
     refreshResources(true)
     outputChatBox("Resources refreshed", player, 255, 255, 0)
     outputChatBox("Resources refreshed", player, 255, 255, 0)
end
end

Revision as of 09:56, 17 March 2011

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

Syntax

bool refreshResources ( [ bool refreshAll = false ] )

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 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)

See Also