> 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()
