RemoveResourceFile: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{Server function}} __NOTOC__ tba ==Syntax== <syntaxhighlight lang="lua"> bool removeResourceFile ( resource, name ) </syntaxhighlight> ===Required Arguments=== <!-- List each argument one per line. This shoul...)
 
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
tba
This function removes a file from the resource.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool removeResourceFile ( resource, name )
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 -->
*'''argumentName:''' description
*'''theResource:''' The resource element.
 
*'''fileName:''' The filename what you wan't to delete.
<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' description
*'''argumentName3:''' description


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


==Example==
==Example==
This function lists all loaded resources in the console.
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()
function blabla ()
resource = getResourceFromName("sx_resmanager")
    --this does blabla
removeResourceFile(resource,"description.txt")
end
end)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Resource_functions}}
{{Resource_functions|server}}

Latest revision as of 22:48, 6 September 2024

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