Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/02/24 in Files

  1. Version 1.0.0

    21 downloads

    This resource adds serverside API to set head blend palette colors. Head blend palette colors are used for crew colored clothing in GTA Online. (example here) Installing Put the files you downloaded in their respective places Add require('palette-sync') to client_packages/index.js All done API (Serverside) This resource adds 4 functions to the mp.Player prototype: /** * Sets the specified head blend palette color for the player. **Make sure `player.setCustomization` is called beforehand to avoid issues.** * @param {number} paletteIndex * @param {number} red * @param {number} green * @param {number} blue * @throws If `paletteIndex` is less than 0 or higher than 3. * @throws If `red`, `green` or `blue` is not an integer between 0 to 255. */ player.setHeadBlendPaletteColor(paletteIndex, red, green, blue); /** * Sets the head blend palette colors for the player. This function should be used to update multiple palette colors at once. **Make sure `player.setCustomization` is called beforehand to avoid issues.** * @param {Array<[number, number, number, number]>} colors 2-dimensional array where each element has palette index, red, green and blue color data such as `[[0, 255, 0, 0], [3, 0, 255, 0]]`. * @throws If `colors` is not an array. * @throws If any `paletteIndex` is less than 0 or higher than 3. * @throws If any `red`, `green` or `blue` is not an integer between 0 to 255. */ player.setHeadBlendPaletteColors(colors); /** * Returns the specified head blend palette color for the player. * @param {number} paletteIndex * @throws If `paletteIndex` is less than 0 or higher than 3. * @returns {Object} An object with `red`, `green` and `blue` properties, ranging from 0 to 255. */ player.getHeadBlendPaletteColor(paletteIndex); /** * Returns the head blend palette colors for the player. * @returns {Array<Object>} An array of objects where each element has `red`, `green` and `blue` properties, ranging from 0 to 255. */ player.getHeadBlendPaletteColors(); Example (Serverside) // EXAMPLE: Getting a specific color of the player mp.events.addCommand("mycolor", (player, _, index) => { index = Number(index); const paletteColor = player.getHeadBlendPaletteColor(index); player.outputChatBox(`paletteIndex #${index} - red: ${paletteColor.red}, green: ${paletteColor.green}, blue: ${paletteColor.blue}`); }); // EXAMPLE: Getting all colors of the player mp.events.addCommand("mycolors", (player) => { const paletteColors = player.getHeadBlendPaletteColors(); paletteColors.forEach((item, index) => { player.outputChatBox(`paletteIndex #${index} - red: ${item.red}, green: ${item.green}, blue: ${item.blue}`); }); }); // EXAMPLE: Setting one color mp.events.addCommand("setcolor", (player, _, index, r, g, b) => { index = Number(index); r = Number(r); g = Number(g); b = Number(b); player.setHeadBlendPaletteColor(index, r, g, b); }); // EXAMPLE: Setting multiple colors at once mp.events.addCommand("randomcolors", (player) => { let data = []; // the game has 4 palette colors for (let i = 0; i < 4; i++) { data.push([ i, // palette index Math.floor(Math.random() * 256), // random red Math.floor(Math.random() * 256), // random green Math.floor(Math.random() * 256), // random blue ]); } player.setHeadBlendPaletteColors(data); }); Notes The game doesn't seem to like it when you set palette color(s) of a ped that doesn't have headblend data, it's recommended that you do color changes after using Player::setCustomization Crew t-shirt palette indices: 0 - sleeve color, 1 - no difference, 2 - collar color, 3 - main color Crew jacket palette indices: 0, 1, 2 - no difference, 3 - main color Source code is also available on GitHub: https://github.com/root-cause/ragemp-palette-sync
    1 point
×
×
  • Create New...