Powered by Cfx.re, RedM is a modification for the single-player game Red Dead Redemption 2. This modification allows players to run dedicated servers with a focus on multiplayer elements – enabling us to create our own unique experiences within a dedicated server.
Involving languages such as Lua and C#, developers are able to create their own scripts within Rockstar’s game engine that was built for Red Dead Redemption 2. From implementing completely custom inventory systems, to editing the game assets themselves and turning them into something completely different— we are given a lot of freedom, but are of course restricted when it comes to the modding of Red Dead Redemption 2.
custom SCRIPTS
For the past two years, getting into RedM is something I’ve committed almost all of my time to outside of finishing my Bachelor’s degree. I have been a developer in several communities, working on implementing custom game systems, working on team-based projects, debugging server and script issues, and managing the development direction of those servers.
I have not only made my own scripts for these servers and their needs, but too I’ve managed to create my own 3D models and textures that are implemented into Red Dead Redemption 2’s game engine. From custom horse models, textures, and ped components— it is an ever-evolving door I’m always opening.
Herbalism Script
Language: LUA
Gameplay Focus: Custom XP system, player levels, spawning of composite and prop components, inventory management
Description: This script is a full-stack client-sided and server-sided herbalism system, where it manages herb spawning, collection detection, inventory rewards and input, and persistant player progression. While not stated, in the config.lua it uses herb zones across the entire map using vector3() coordinates.
This script ties in with the database to track player levels, progression, and zone cooldowns to ensure players do not exploit each zone.
client.lua
Lua
-- Reverse map item -> composite for lookup from config
lastPickTime = nil, -- Track when player last picked from this spawn point
}
end
end
end
This first snippet of code is to show how our script does a look up, and builds a spawn-point list used in the herbalism system. itemToComposite is a reverse map of compositeToItem – so the script is able to go quickly from an item name (the config.lua file) back to it’s composite definition. From here, it creates the herbSpawnPoints from Config.Herbs, where each coordinate becomes its own independent spawn point. Metadata is stored for every spawn coordinate: id, zoneId, zoneName, coordIndex, center, and items.
client.lua
Lua
-- Spawns a composite within a radius around center (vector3)
functionspawnCompositeInRadius(compositeName, center, radius)
-- Set cooldown timer when picking from this specific spawn point
spawnPoint.lastPickTime = GetGameTimer()
end
end
end
end
end
end)
This second snippet of code displays the core herb-spawning and collecting loop. spawnCompositeInRadius() requests and loads an herb asset, picks a random point within the spawn zone radius (which is also set in client.lua), snaps it to the ground height, spawns the herb composite, and then returns the scenario/entity. On pickup, it sens a server event to grant the item in the player’s inventory, logs the pickup, and removes the spawned scenario (aka herb prop).
Horse Stable Script
Language: LUA
Gameplay Focus: Ped modification, custom gameplay system, player interactions, rule-based ped AI behavior
Description: This custom stable script is a take on the original Red Dead Redemption 2 stable system, except it has been expanded upon to add equestrian elements to it that the original game does not have. With this system, the horses have been designed and coded to be given personalities, metabolism, an XP-based leveling system, custom training system, and dynamic interactions with the player. It utilizes Jump On Studio’s custom library – where we’ve had to learn this through documentation, but allows us to write cleaner code.
This script ties in with the database to track everything about the player’s horse – and even goes as far as storing tint hashing, state bags, and each coat the horse is given.
Note: We have integrated custom coat textures onto the server this script is implemented on, and we have made our own custom coat templates to which are stored in the database. Along with custom blender models for some of the horse ped drawable models.
client.lua
Lua
-------------
-- Background threads: apply personality behaviors to current mount
-- When mood is Hesitant or below, personality does not take full effect
ifGetMoodForHorseandConfig.metabolismthen
localmood = GetMoodForHorse(horse)
ifmoodandmood <= 2then
flags = {
-- Keep manual kick availability from preset even at low mood.
kick = flags.kick == true,
noFlee = false,
noBuck = false,
skipCommands = true,
alwaysObey = false,
alert = false,
loyal = false,
defend = false,
gluttony = false,
affectionate = false,
wander = false,
buckPassengerOnly = false,
}
end
end
returnflags, horse
end
This first snippet of code is to show how the custom personality system is applied to a horse. It first finds whether the horse is mounted or being lead by the player, and is able to find the personality that is cached from the horse’s entity state – and returns that preset’s behavior flags. There is also integration into the metabolism system, where if the horse’s mood is below a level 2, it will temporarily suppress all personality behavior.
Below are screenshots of what the in-game UI shows for a personality, and the metabolism notification a player gets for a horse’s mood.
client.lua
Lua
-- Apply coat from config based on stored coat index and optional custom tints
This second snippet of code is able to choose and apply the tinting of a horse’s coat. For textures in RDR2, they are given albedo textures which we are able to manipulate and tint through the 255 range of RGB values given in the game engine. It validates the horse entity first, acquires the coat data from the config.lua we have, and is able to apply the tints through the SetMetaPedTag native.
Below are screenshots of what this looks like in-game when a player is customizing their horse, and applying the tints in real time.
Custom Drawable Models
This is a custom bridle model, and the texture mapping of the vertices.
This is a custom, western harness model.
This is a custom mane model that introduces a new mane type for the player’s to equip on their horse.
Below are pictures of what each look like rendered in-game with their custom textures.