RenameResource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
This function renames a resource.
This function renames a resource. '''Please Note:''' You can't change a running resource, only resources that's loaded/stopped.


==Syntax==  
==Syntax==  
Line 20: Line 20:


==Example==
==Example==
{{Example}}
This example renames the resource "realdriveby" to "driveby" when the current resource is started.
}}
<syntaxhighlight lang="lua">addEventHandler("onResourceStart",resourceRoot,function()
renameResource("realdriveby","driveby")
end)
</syntaxhighlight>


==Requirements==
==Requirements==
Line 28: Line 31:
==See Also==
==See Also==
{{Resource_functions}}
{{Resource_functions}}
[[Category:Needs_Example]]

Revision as of 21:35, 27 April 2012

{{New feature/item|3.0120|1.2|3316|

This function renames a resource. Please Note: You can't change a running resource, only resources that's loaded/stopped.

Syntax

bool renameResource ( string resourceName, string newResourceName, [ string organizationalPath ] )

Required Arguments

  • resourceName: The name of resource to rename.
  • newResourceName: The name of what the resource should be renamed to.

Optional Arguments

  • organizationalPath: If you want to store the new resource inside a category.

Returns

Returns true if the resource has been renamed successfully, false otherwise. This could fail if the resource name already is in use, if a directory already exists with the name you've specified (but this isn't a valid resource) or if the name you specify isn't valid. It could also fail if the disk was full or for other similar reasons. Won't work on a started resource or if the resource is not loaded (not known by MTA (use /refresh))

Example

This example renames the resource "realdriveby" to "driveby" when the current resource is started.

addEventHandler("onResourceStart",resourceRoot,function()
	renameResource("realdriveby","driveby")
end)

Requirements

This template will be deleted.

See Also