# Server Callbacks

## `RegisterServerCallback(name, func)`

Registers a callback on the server-side ready to be called from a client.

* name<mark style="color:red;">\*</mark> (string) - uniquely identifying name of the callback
* func<mark style="color:red;">\*</mark> (function (source, callback, ...) ) - function to call when the callback is called. All optional arguments sent from the client will be the optional arguments of this function.

<mark style="color:red;">\*</mark> = required arguments

Example (paired with the client-side example):

```lua
FOM.RegisterServerCallback('test', function(source, cb, s1, s2)
    print(s1 .. ' ' .. s2)
    cb('hello', 1)
end)
```

See [Server Callbacks on the client-side](/client/server-callbacks.md) for triggering a callback.

Reference: `utils/sv_callback.lua`


---

# Agent Instructions: 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.callumg.net/server/server-callbacks.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.
