/fivem-appearance

Primary LanguageLuaMIT LicenseMIT

ox_appearance

A fork of fivem-appearance written in Lua and providing some niche changes.

  • Refer to the link above for all standard features.
  • Basic support for ESX using skinchanger and esx_skin event handlers.
  • Clothing stores and barber shops.

Appearance data can be saved to server-kvp, but requires setup to use included exports.
Data is stored as identifier:appearance, where identifier can be any unique identifying value, i.e.

  • rockstar license
  • citizenid
  • auto-incrementing id
-- Example using cfx-server-data/player-data with a statebag
local id = Player(source).state['cfx.re/playerData@id']
local appearance = exports['fivem-appearance']:loadAppearance(source, id)

-- Example using ESX, if moving away from storing skin in the database
local skin = exports['fivem-appearance']:loadAppearance(xPlayer.source, xPlayer.identifier)

Preview

Customization Preview Customization Preview Customization Preview

Convars

Since this is a client script, you will need to use setr to set these convars.

Convar Default Type Description
fivem-appearance:locale "en" string Name of a file inside locales/. Choose the locale file for the customization interface.
fivem-appearance:radar 1 int Enables hiding/showing the radar when opening the customization interface.

config.cfg example:

setr fivem-appearance:locale "en"
ensure fivem-appearance

Client Exports

Appearance

Export Parameters Return
getPedModel ped: number string
getPedComponents ped: number PedComponent[]
getPedProps ped: number PedProp[]
getPedHeadBlend ped: number PedHeadBlend
getPedFaceFeatures ped: number PedFaceFeatures
getPedHeadOverlays ped: number PedHeadOverlays
getPedHair ped: number PedHair
getPedAppearance ped: number PedAppearance
setPlayerModel model: string Promise<void>
setPedComponent ped: number, component: PedComponent void
setPedComponents ped: number, components: PedComponent[] void
setPedProp ped: number, prop: PedProp void
setPedProps ped: number, props: PedProp[] void
setPedFaceFeatures ped: number, faceFeatures: PedFaceFeatures void
setPedHeadOverlays ped: number, headOverlays: PedHeadOverlays void
setPedHair ped: number, hair: PedHair void
setPedEyeColor ped: number, eyeColor: number void
setPlayerAppearance appearance: PedAppearance void
setPedAppearance ped: number, appearance: PedAppearance void
startPlayerCustomization callback: ((appearance: PedAppearance | undefined) => void), config? CustomizationConfig void

Examples

Customization command (Lua)

RegisterCommand('customization', function()
  local config = {
    ped = true,
    headBlend = true,
    faceFeatures = true,
    headOverlays = true,
    components = true,
    props = true,
  }

  exports['fivem-appearance']:startPlayerCustomization(function(appearance)
    if appearance then
      print('Saved')
    else
      print('Canceled')
    end
  end, config)
end, false)

Start player customization with callback (TypeScript)

const exp = (global as any).exports;

exp["fivem-appearance"].startPlayerCustomization((appearance) => {
  if (appearance) {
    console.log("Customization saved");
    emitNet("genericSaveAppearanceDataServerEvent", JSON.stringify(appearance));
  } else {
    console.log("Customization canceled");
  }
});

Set player appearance (TypeScript)

const exp = (global as any).exports;

onNet("genericPlayerAppearanceLoadedServerEvent", (appearance) => {
  exp["fivem-appearance"].setPlayerAppearance(appearance);
});

Data

Scripts used to generate some of the resource's data.

Peds

Credits