Skip to content

Custom animations

import { ServerAnimations } from "@sagl/server";

Animations of your own, played like the game's: put .ifp files among your client files, and playAnim() takes them by their set name.

// client-files/anim/payphone.ifp holds the set "PAYPHONE": pickup, talk, hangup
await player.playAnim("PAYPHONE", "pickup", { ms: 2050 });
player.playAnim("PAYPHONE", "talk", { loop: true });

That's all there is to it:

  • Any .ifp in the client files (any folder) is an animation set, named by the name inside the file. San Andreas' format, and III's and Vice City's older one.
  • player.playAnim(set, name), ped.playAnim(set, name), { playAnim: [set, name] } in a ped's sequence, and client scripts' sagl.player.playAnim all take them, as they take the game's own ("PED", "DANCING", ...).
  • Players' games load a set the first time something plays from it, and unload idle ones when they need room, so you can have as many sets as you like.

server.animations.sets lists them (name, file, animations); server.animations.has(name) says whether one is yours.

Limits

They're the game's, and sensible ones:

Set names 1-15 letters, digits or _, unique among your files and different from the game's own sets (a game set of the same name wins: PED, DANCING, GANGS...). Case doesn't matter.
At once About 25 sets loaded at a time on a player's game (the game's free slots), and up to 600 animations. More than that in use at the same moment and the newest one doesn't play (and their client log says so); sets nothing is playing are unloaded to make room, least recently used first.
A set's size Up to 256 animations.
The first play Loads the set then and there: a small file (tens of KB) is instant; a big one can hitch a frame.
Skeleton San Andreas' ped skeleton, as the game's own animations: any skin plays them.

Animations from GTA III and Vice City

scripts/convert-anim.py converts GTA III or Vice City animations (their own skeleton) for San Andreas peds: each bone's movement is carried over to SA's matching bone, and SA's extra bones (clavicles, fingers) keep their standing pose. It reads both games' ped.ifp from your copies:

scripts/convert-anim.py --sa "path/to/GTA San Andreas" \
  --from "path/to/Grand Theft Auto 3/anim/ped.ifp" \
  --anims PHONE_in,PHONE_talk,PHONE_out --rename pickup,talk,hangup \
  --set PAYPHONE --out client-files/anim/payphone.ifp

The result is close, not exact (III's skeleton is simpler: no clavicles, fingers, or separate neck), and Rockstar's animations are theirs: share ones you're allowed to.

The freeroam example's payphone (examples/freeroam/payphone.ts) uses GTA III's payphone animations made this way.