JRS COREDokumentasi
Tautan berguna

RDR3 Decompiled Scripts

How to read the game's own scripts to learn how a feature works, and how to use what you learn in Lua

Situs resmi · github.com ↗

The single player and online game are driven by compiled scripts (.ysc files). Community tools turn them back into readable code. Those decompiled scripts are the best way to learn how Rockstar calls a native, which arguments it passes and in which order things happen.

Warning

The decompiled code is Rockstar's property. JRS Core does not copy or redistribute it. Read it for research, learn the pattern, then write your own Lua. Never paste big parts of it into a resource.

What the output looks like#

Decompilers cannot recover the original names, so everything is generated:

You see Meaning
func_123(...) A script function. The number is its position, not a name.
Local_45 / iLocal_45 A variable local to the script. A prefix such as i, f, v or sz hints at integer, float, vector or string.
Global_1234.f_56 A global shared by many scripts. The path means "struct 1234, field 56".
PLAYER::GET_PLAYER_PED(...) A native. NAMESPACE::NAME is how the databases list it.
joaat("hash") / MISC::GET_HASH_KEY(...) A hash computed from a name. In Lua write it as a backtick literal: `name`.

A workflow that works#

  1. Find the feature in game and note any text, animation, sound or prompt you can see.
  2. Search the scripts for a string, a hash or a native name connected to it (for example the prompt text key or the animation dictionary).
  3. Read around the match. The lines before show which checks run first, the lines after show the cleanup. Copy the order of natives, not the code.
  4. Look up each native (see RDR3 Natives) to learn what the arguments mean.
  5. Rebuild it in Lua with names for every argument, and test in a quiet area.
  6. Keep a comment with what you learned (native, what it does, game build). Natives and indexes move between builds.

Translating a call to Lua#

A decompiled line such as:

text
TASK::TASK_PLAY_ANIM(PLAYER::PLAYER_PED_ID(), "dict", "clip", 8.0, -8.0, -1, 0, 0.0, false, false, false, "", false);

becomes, in RedM Lua:

lua
TaskPlayAnim(PlayerPedId(), 'dict', 'clip', 8.0, -8.0, -1, 0, 0.0, false, false, false, '', false)

Rules of thumb: NAMESPACE:: disappears, UPPER_SNAKE becomes PascalCase, joaat("x") becomes `x`, floats keep their .0.

Reading globals and locals#

Global_* and Local_* indexes change with every game build. Do not hard code them in a resource. If you must read one, keep it in a config value, and document the build you tested on.

Common traps#

  • A native can behave differently when called from a script thread and from a resource. If a call "does nothing", test the same native with a larger delay or from a different thread.
  • Some natives only work on network-owned entities. Ask for control first (NetworkRequestControlOfEntity) and wait until you have it.
  • A function that looks simple may be a wrapper that sets several flags. Read the callee too.
  • Never trust a decompiled branch condition blindly: the decompiler can invert or merge conditions.

Where to get the scripts#

The community keeps public decompilations of the game scripts for research. One maintained collection: outsider31000/rdr2-scripts-decompiled. It has no license, so use it only to read.

JRS Core · Framework RedM gratis dan open source · dibuat oleh JRS TEAM