> For the complete documentation index, see [llms.txt](https://docs.streamavatars.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/boss-battle-outcome.md).

# Boss Battle Outcome

```lua
function yourEvent(users, boss_name, difficulty, result)
    if result == 'cancelled' or users == nil or boss_name == nil or difficulty == 'none' then
        return;
    end

    if result == 'players' then
        local str = 'players won... ';
        for i,user in pairs(users) do
            str = str .. ' ' .. user.displayName;
        end
        log(str);
    end

    if result == 'boss' then
        log('boss: ' .. boss_name .. ' won.');
    end

    log('boss difficulty was: ' .. difficulty); --difficulty can be: easy, normal, hard, none
end

return function()
    addEvent('bossBattleOutcome', 'yourEvent');
    keepAlive();
end
```

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}
