# getCancelReason (Shared)

> Gives the reason passed to `cancelEvent` in the last event that finished running on this side.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Events
- **URL**: https://wiki.mymp.gg/en/getCancelReason

## Syntax

```lua
string getCancelReason()
```

## Returns

The reason, or an empty string if there was none.

## Example

```lua
addEvent("onShopOpen")

if not triggerEvent("onShopOpen", resourceRoot) then
    outputDebugString("shop closed: " .. getCancelReason())
end
```

## See also

- [cancelEvent (Shared)](https://wiki.mymp.gg/en/cancelEvent.md): Marks the running event as cancelled. What cancelling prevents depends on the event.
- [wasEventCancelled (Shared)](https://wiki.mymp.gg/en/wasEventCancelled.md): Tells whether the last event that finished running on this side was cancelled.
