Gamer tags

All flags enabled

Gamer tag (also known as head display) - is an UI element above player character, which can display text and various icons. The control is carried out by enabling components. Usually used to display player’s name.

For each component you can: show/hide, change opacity, change colour.

Components list

ID Name
0 GAMER_NAME
1 CREW_TAG
2 healthArmour
3 BIG_TEXT
4 AUDIO_ICON
5 MP_USING_MENU
6 MP_PASSIVE_MODE
7 WANTED_STARS
8 MP_DRIVER
9 MP_CO_DRIVER
10 MP_TAGGED
11 GAMER_NAME_NEARBY
12 ARROW
13 MP_PACKAGES
14 INV_IF_PED_FOLLOWING
15 RANK_TEXT
16 MP_TYPING

Simple usage

Lua

For a more complete example, see the stock playernames resource included in the server package, or the documentation for the resource.

local mpGamerTags = {}

for i = 0, 255 do
  if NetworkIsPlayerActive(i) and i ~= PlayerId() then
    local ped = GetPlayerPed(i)

    -- change the ped, because changing player models may recreate the ped
    if not mpGamerTags[i] or mpGamerTags[i].ped ~= ped then
      local nameTag = ('%s [%d]'):format(GetPlayerName(i), GetPlayerServerId(i))

      if mpGamerTags[i] then
        RemoveMpGamerTag(mpGamerTags[i])
      end

      mpGamerTags[i] = {
        tag = CreateMpGamerTag(GetPlayerPed(i), nameTag, false, false, '', 0),
        ped = ped
      }
    end

    SetMpGamerTagVisibility(mpGamerTags[i].tag, 4, NetworkIsPlayerTalking(i))
  else
    RemoveMpGamerTag(mpGamerTags[i])

    mpGamerTags[i] = nil
  end
end

Example

Lua

-- Create gamer info
local gamerTagId = CreateMpGamerTag(
  ped, -- Ped to which gamer info will be assigned
  "User name", -- String to display for flag ""
  false, -- pointedClanTag
  false, -- Is R* clan
  "", -- Clantag
  0 -- Unknown
)

C#

// Create gamer info
// assuming using static CitizenFX.Core.API;
int gamerTagId = CreateMpGamerTag(
  ped.Handle, // Ped to which gamer info will be assigned
  "User name", // String to display for flag ""
  false, // pointedClanTag
  false, // Is R* clan
  clanTag,
  0 // Unknown
);

Toggling flags

Lua

-- Toggle components
SetMpGamerTagVisibility(
  gamerTagId,
  component,
  bool -- Toggle
)

C#

// Toggle flags
SetMpGamerTagVisibility(
  gamerTagId,
  component,
  toggle
);

Changing flags colour

Lua

-- Change component colour
SetMpGamerTagColour(
  gamerTagId,
  component,
  colour -- 0 - 255
)

C#

// Change component colour
Function.Call(
  (Hash)0x613ED644950626AE,
  (int)gamerTagId,
  (int)component,
  (int)colour // 0 - 255
);

Changing flags opacity

Lua

-- Change component opacity
SetMpGamerTagAlpha(
  gamerTagId,
  component,
  opacity -- 0 - 255
)

C#

// Changes flag opacity
Function.Call(
  (Hash)0xD48FE545CD46F857,
  (int)gamerTagId,
  (int)component,
  (int)opacity // 0 - 255
);

Special flags controls

Wanted level

For the WantedStar flag you can set number that will be shown inside of star icon: ### Lua

-- Set the number that will be set inside the wanted star icon
SetMpGamerTagWantedLevel(
  gamerTagId,
  wantedLevel -- 0 - 5
)

C#

// Set the number that will be set inside the wanted star icon
Function.Call(
  Hash._SET_HEAD_DISPLAY_WANTED,
  (int)gamerTagId,
  (int)wantedLevel // 0 - 5
);

Health bar colour

Health bar has 0 opacity by default. Colour of health bar changes using it’s own native: ### Lua

Lua

-- Change health bar colour
SetMpGamerTagHealthBarColor(
  gamerTagId,
  colour -- 0 - 255
)

C#

// Change health bar colour
Function.Call(
  (Hash)0x3158C77A7E888AB4,
  (int)gamerTagId,
  (int)colour // 0 - 255
);