deleteResource
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function deletes a resource from the MTA memory and moves it to the /resources-cache/trash/ directory.
OOP Syntax Help! I don't understand this!
Note: This function is a static function underneath the Resource class.
- Method: Resource.)(...)
Syntax
bool deleteResource ( string resourceName )Required Arguments
- resourceName: The name of resource to delete.
Returns
- bool: value
Returns true if the resource has been deleted successfully, false otherwise.
Code Examples
shared
This example adds a command to delete a certain resource (admins only, no spaces in resource name allowed).
addCommandHandler ( "removeresource",function ( playerSource, commandName, name ) --Check if it is an admin using this command if not isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( playerSource ) ), aclGetGroup ( "Admin" ) ) then outputChatBox ( "You are not allowed to use this command", playerSource ) return end --Did the user pass a valid resource name? if not name or name == "" or name == " " then outputChatBox ( "An invalid resource name has been passed (/removeresource <name>)", playerSource ) return end --Let us check if the resource name exists --Get all resources local resourceTable = getResources ( ) for resourceKey, resourceValue in ipairs ( resourceTable ) do local resourceName = getResourceName ( resourceValue ) --Does the resource exist? if name == resourceName then --Stop the resource (maybe it is running) stopResource ( resourceValue ) --Delete it local deleted = deleteResource ( name ) if deleted then outputChatBox ( "Resource " .. name .. " has been successfully removed", playerSource ) else outputChatBox ( "There is an unknown problem with the resource", playerSource ) end --The function is finished and was successful, return to stop it return end end --If a resource with the specified name does not exist show an error message outputChatBox ( "The specified resource does not exist", playerSource )end )See Also
Resource Functions
- abortRemoteRequest
- addResourceConfig
- addResourceMap
- call
- callRemote
- copyResource
- createResource
- deleteResource
- fetchRemote
- getRemoteRequestInfo
- getRemoteRequests
- getResourceACLRequests
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceGUIElement
- getResourceInfo
- getResourceLastStartTime
- getResourceLoadFailureReason
- getResourceLoadTime
- getResourceMapRootElement
- getResourceName
- getResourceOrganizationalPath
- getResourceRootElement
- getResources
- getResourceState
- getThisResource
- isResourceArchived
- isResourceProtected
- refreshResources
- removeResourceFile
- renameResource
- restartResource
- setResourceInfo
- startResource
- stopResource
- updateResourceACLRequest