RemoveResourceFile: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 7: Line 7:
bool removeResourceFile ( resource theResource, string fileName )
bool removeResourceFile ( resource theResource, string fileName )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[resource]]:removeFile}}
===Required Arguments===  
===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 -->
<!-- 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 -->
*'''theResource:''': The resource element.
*'''theResource:''' The resource element.
*'''fileName:''': The filename what you wan't to delete.
*'''fileName:''' The filename what you wan't to delete.


===Returns===
===Returns===
Returns ''true'' if file was deleted, otherwise ''false''.
Returns ''true'' if file was deleted, otherwise ''false'' if the resource is in use or the file doesn't exist.


==Example==
==Example==
<section name="Server" class="server" show="true">
This example removes a .txt file from the resource sx_remanager (in-game script editor) when started.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">addEventHandler("onResourceStart",resourceRoot,function()
-- Add example
resource = getResourceFromName("sx_resmanager")
removeResourceFile(resource,"description.txt")
end)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Resource_functions}}
{{Resource_functions}}

Latest revision as of 10:52, 21 February 2020

This function removes a file from the resource.

Syntax

bool removeResourceFile ( resource theResource, string fileName )

OOP Syntax Help! I don't understand this!

Method: resource:removeFile(...)


Required Arguments

  • theResource: The resource element.
  • fileName: The filename what you wan't to delete.

Returns

Returns true if file was deleted, otherwise false if the resource is in use or the file doesn't exist.

Example

This example removes a .txt file from the resource sx_remanager (in-game script editor) when started.

addEventHandler("onResourceStart",resourceRoot,function()
	resource = getResourceFromName("sx_resmanager")
	removeResourceFile(resource,"description.txt")
end)

See Also