The fastest way to learn the API is a resource that does one thing. This one adds /hello: it greets the character and pays a small tip, with the amount decided on the server.
- Make the folder
Create
jrs_helloinside yourresourcesfolder. A resource needs only a manifest and one script. - Write the two files
Save both as UTF-8 without BOM, or the server will refuse to read the manifest.
fxmanifest.luafx_version 'cerulean' game 'rdr3' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' lua54 'yes' server_script 'server.lua'server.lualocal JRS = exports.jrs_core:getCoreApi() RegisterCommand('hello', function(source) local character = JRS.GetCharacter(source) if not character then return end -- player is still on the character screen JRS.NotifyRightTip(source, 'Hello ' .. character.firstname, 4000) JRS.AddMoney(source, 5) -- server decides the amount end) - Load it after the core
Add
ensure jrs_helloon its own line belowensure jrs_coreinserver.cfg, restart, join and type/hello.JRS.GetCharacterreturnsnilwhile the player is still on the character screen, which is why the command checks it first.
Editor#
Any editor works. The JRS Core extension for VS Code saves the most time: download jrs-core-vsc.vsix, open Extensions, press ... and choose Install from VSIX.
It gives you autocomplete and hover docs for every core export and event, snippets for common blocks, the JRS Dark theme and a command that opens this site. Type JRS., exports.jrs_core: or jrs- in a .lua file to check it is active.
Before your own events give money or items, read Writing solid scripts.