> 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/basketball-outcome.md).

# Basketball Outcome

```lua
function yourEvent(winners, losers, mvp, winnerScores, loserScores)
    if losers == nil then
        log('the game was cancelled!');
        return;
    end
    if winners == nil then
        log('the game was drawn!');
        log('everyone is a losers... their stats and order will exist in parameters, as well as the highest scorer as mvp');
    end

    log('the winners are...');
    wait(1);

    local str = '';
    
    for i,user in pairs(winners) do
      str = str .. ' ' .. user.displayName .. '#=' .. winnerScores[i];
    end
    log(str); --prints all winners like:
    -- clonzeh#=10 someonelse#=2 yetanother#=5
    wait(1);
    log('and the mvp is: ' .. mvp);
end

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/basketball-outcome.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
