# deleteResource (Server)

> Takes a stopped resource out of the resource list and moves its folder or archive into the `trash` folder of the server's resource cache.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Resources and modules
- **URL**: https://wiki.mymp.gg/en/deleteResource

## Syntax

```lua
bool deleteResource(resource|string resource)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `resource` | `resource\|string` | The resource, or its name. |

## Returns

`true` if the resource was moved, `false` otherwise.

## Example

```lua
addCommandHandler("delres", function(player, command, name)
    if getResourceState(name) == "loaded" then
        deleteResource(name)
    end
end)
```

### Note

A resource that is not stopped cannot be deleted. Since `stopResource` only stops the resource on the next pulse, calling `deleteResource` right after it fails.

## See also

- [stopResource (Shared)](https://wiki.mymp.gg/en/stopResource.md): Asks to stop a running resource. It stops on the next resource pulse, not during the call.
- [refreshResources (Shared)](https://wiki.mymp.gg/en/refreshResources.md): Reads the resources folder again: adds the new resources, removes the ones that are gone (stopping those that ran) and logs which running resources changed on disk.
- [getResourceState (Shared)](https://wiki.mymp.gg/en/getResourceState.md): Tells which state a resource is in.
