Every docs URL answers with Markdown when you add .md. Site map: llms.txt
RedM for a FiveM script author
What changes when you write for RedM instead of FiveM: natives by hash, controls as hashes, peds that need an outfit, prompts, blips by style, and RDR2 game data.
这些文档目前是英文的。
You know FiveM Lua. Here is what feels different the first day on RedM. Each point has a longer version, with code, in Porting a FiveM resource.
Natives are called by hash
GTA V and RDR2 natives are two different sets. A GTA V native name does not exist on RDR2, and where both games have “the same” native, the hash is different. Many RDR2 natives have no settled name yet, so RedM scripts call them by hash:
-- SET_BLIP_SCALE
Citizen.InvokeNative(0xD38744167B2FA257, blip, 0.2)The hash never changes when a name does, which is why most RedM code you read looks like this. Write the native’s name in a comment beside it, as above, or nobody can read the script a month later.
Controls are hashes too
On GTA V a control is a small index (38 for the pickup key). On RDR2 a control is the joaat hash of its INPUT_ name, for example INPUT_JUMP is 0xD9D0E1C0. The Hash Calculator gives you any of them, and the RedM Assets page lists every input action the game defines.
if IsControlJustPressed(0, 0xD9D0E1C0) then -- INPUT_JUMP
endA ped needs an outfit
An RDR2 ped model spawned with nothing else done to it is invisible. Give it an outfit right after CreatePed:
local ped = CreatePed(model, x, y, z, heading, true, false, false, false)
-- _SET_RANDOM_OUTFIT_VARIATION: a RedM ped with no outfit is invisible
Citizen.InvokeNative(0x283978A15512B2FE, ped, true)CreatePed itself takes different arguments than on GTA V: there is no ped type first. Horses are peds too, spawned the same way.
“Press E” is a prompt
The game’s own way of offering an action is a prompt: the small key and label in the corner, with press, hold and mash variants and the hold timings the game itself uses. A FiveM style help text box and a hard coded key check is the thing that makes a port feel out of place. The Prompt Builder writes the prompt code for you.
Blips start from a style
A GTA V blip is a sprite id plus a colour id. An RDR2 blip is created from a blip style (a hash), and the style decides the icon, colour and label; you can then swap the icon for another sprite, also by hash:
-- BLIP_ADD_FOR_COORDS: the style decides the icon, colour and label
local blip = Citizen.InvokeNative(0x554D9D53F696D002, joaat("BLIP_STYLE_PICKUP_WEAPON"), x, y, z)
-- SET_BLIP_SPRITE: another icon than the style's own
Citizen.InvokeNative(0x74F74D3207ED525C, blip, joaat("blip_shop_store"), true)That pair (a style for the behaviour, a sprite for the icon) is how rsg-shops creates its store blips.
Blip Styles lists every style and Blip Placer writes this code for a set of points.
The game data is all new
Model names, weapons, scenarios, timecycles, zones, interiors and text labels are RDR2’s. None of the GTA V lists apply, and a GTA V model name copied into a RedM script never loads. Look names up on RedM Assets or in the Game Text Search.
What you do not have to relearn
Server scripts, events, exports, state bags, NUI, convars, ACE and your database layer work exactly as on FiveM. The FiveM guides on client and server events, exports, NUI and state bags apply as written, as long as the example does not call a GTA V native.