> For the complete documentation index, see [llms.txt](https://r2northstar.gitbook.io/r2northstar-wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://r2northstar.gitbook.io/r2northstar-wiki/chinese/modding-and-development/getting-started/what-is-squirrel/callbacks.md).

# 回调函数

Callbacks within squirrel trigger functions when certain events occur and are defined serverside.

They will also often pass arguments to those functions based on the callbacks used

## A few examples

`AddCallback_OnPlayerRespawned(OnRespawn)`

This script will trigger the function "OnRespawn" when any player respawns, this function can be defined later in the mods file and this callback will pass one argument, the player entity that respawned

`AddCallback_OnPlayerKilled(AddPoints)`

This callback triggers the function "AddPoints" when a player is killed. this function passes 3 arguments: an entity (the attacking player), an entity (the killed player), and the damage informtion

`AddCallback_OnClientConnected(Connected)`

This callback triggers the function "Connected" whenever a player joins and passes 1 argument, the player entity.

## List of callbacks

This is an **incomplete** list of callbacks, a better list can be found in the list of all functions: <https://github.com/ScureX/Titanfall2-ModdingDocumentation/blob/main/AllMethodsClean.md>

AddCallback\_EntitiesDidLoad()

AddCallback\_GameStateEnter(gamestate, function to trigger)

AddCallback\_KillReplayEnded()

AddCallback\_KillReplayStarted()

AddCallback\_LocalClientPlayerSpawned()

AddCallback\_LocalViewPlayerSpawned()

AddCallback\_MinimapEntSpawned()

AddCallback\_OnClientConnected()

AddCallback\_OnClientScriptInit()

AddCallback\_OnNPCKilled()

AddCallback\_OnPetTitanChanged()

AddCallback\_OnPetTitanModeChanged()

AddCallback\_OnPilotBecomesTitan()

AddCallback\_OnPlayerDisconnected()

AddCallback\_OnPlayerGetsNewPilotLoadout()

AddCallback\_OnPlayerKilled()

AddCallback\_OnPlayerLifeStateChanged()

AddCallback\_OnPlayerRespawned()

AddCallback\_OnSatchelPlanted()

AddCallback\_OnSelectedWeaponChanged()

AddCallback\_OnTimeShiftAbilityUsed()

AddCallback\_OnTimeShiftTitanAbilityUsed()

AddCallback\_OnTitanBecomesPilot()

AddCallback\_OnUseEntity()

AddCallback\_PlayerClassChanged()

AddCallback\_ScriptTriggerEnter()

AddCallback\_ScriptTriggerLeave()

AddCallback\_UseEntGainFocus()

AddCallback\_UseEntLoseFocus()


---

# 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://r2northstar.gitbook.io/r2northstar-wiki/chinese/modding-and-development/getting-started/what-is-squirrel/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.
