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

IDName
0GAMER_NAME
1CREW_TAG
2healthArmour
3BIG_TEXT
4AUDIO_ICON
5MP_USING_MENU
6MP_PASSIVE_MODE
7WANTED_STARS
8MP_DRIVER
9MP_CO_DRIVER
10MP_TAGGED
11GAMER_NAME_NEARBY
12ARROW
13MP_PACKAGES
14INV_IF_PED_FOLLOWING
15RANK_TEXT
16MP_TYPING
17MP_BAG_LARGE
18MP_TAG_ARROW
19MP_GANG_CEO
20MP_GANG_BIKER
21BIKER_ARROW
22MC_ROLE_PRESIDENT
23MC_ROLE_VICE_PRESIDENT
24MC_ROLE_ROAD_CAPTAIN
25MC_ROLE_SARGEANT
26MC_ROLE_ENFORCER
27MC_ROLE_PROSPECT
28MP_TRANSMITTER
29MP_BOMB

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].tag)
      end

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

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

    mpGamerTags[i] = nil
  end
end

Example

Lua

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

C#

// Create gamer info
// assuming using static CitizenFX.Core.API;
int gamerTagId = CreateMpGamerTagForNetPlayer(
  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, // Clantag flags
  0, // red
  0, // green
  0  // blue
);

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
);