Client Functions

GetLocalData

Returns variables of cached client data. These variables are checked every 500ms and are updated via events(LINK TBA) if they've changed

playerId, playerPedId, position, currentVehicle, currentMount, lastMount, currentGrid = TMC.Functions.GetLocalData()

-- playerId = PlayerId()
-- playerPedId = PlayerPedId()
-- position = GetEntityCoords(PlayerPedId())
-- currentVehicle = GetVehiclePedIsIn(PlayerPedId(), false)
-- currentMount = GetMount(PlayerPedId())) RDR3 Specific
-- lastMount = GetLastMount(PlayerPedId()) RDR3 Specific
-- currentGrid = TMC.Functions.GetGridZone()

Progress Bars

ProgressBar

Starts a progress bar with the specified config

Parameter
Required
Type
Description

callback

Function

A callback function that is called when the progress bar ends. Function has a bool parameter to inform the code if it has completed the progress bar or if it was cancelled.

length

Number

The length (in milliseconds) of the progress bar. If not defined the progress bar will not tick up and can be modified with TMC.Functions.SetProgressBar()

title

String

The title text of the progress bar

description

String

The subtitle text of the progress bar

settings

Object

Overrides default settings. All are optional and should only be provided if you need different settings to those shown below.

TMC.Functions.ProgressBar(function(complete)
    if complete then
        TMC.Functions.SimpleNotify('Success!', 'success')
    end
end, 5000, 'Title', 'Optional Description', {
    canCancel = true,
    disableMovement = true,
    disableCarMovement = true,
    disableMouse = false,
    disableCombat = true,
    ragdollCancel = false,
})

SetProgressBar

Used to update the current progress bar when the length hasn't been defined.

TMC.Functions.SetProgressBar(50) -- Parameter can be 0-100. When set to 100 the progressbar will be complete.

UpdateProgressBar

Used to update the title/description of the active progress bar.

TMC.Functions.UpdateProgressBar('New Title', 'New Description')

CancelProgressBar

Cancels the active progress bar. Will run the callback function with the first parameter set to false.

TMC.Functions.CancelProgressBar()

Current Character

GetPlayerData

Returns player (character) data

local data = TMC.Functions.GetPlayerData()
-- supports a callback function
TMC.Functions.GetPlayerData(function(data)

end)

GetPlayerItems

Returns player (character) item data array

local items = TMC.Functions.GetPlayerItems()
-- supports a callback function
TMC.Functions.GetPlayerItems(function(items)

end)

IsPlayerLoaded

Returns a bool indicating if the player (character) has loaded on the client

if TMC.Functions.IsPlayerLoaded() then
    --
end

IsPlayerSpawned

Returns a bool indicating if the player (character) has spawned in. This comes after the player has loaded

if TMC.Functions.IsPlayerSpawned() then
    --
end

GetFullName

Returns a string of the player (characters) first and last name

local fullname = TMC.Functions.GetFullName()
-- Example Output: "John Doe"

GetItemBySlot

Returns an array of the defined player's inventory slot

Parameter
Required
Type
Description

slot

Number

The inventory slot number

local slotData = TMC.Function.GetItemBySlot(1)
-- Example Output:
-- { [1] = { ["name"] = weapon_pistol,["slot"] = 2,["info"] = { ["ammo"] = 0,["created"] = 1682364609277,["decayRate"] = 201,["serial"] = 56LEj5cI701EpHn,["decay"] = 1,["microstamp"] = 35agp9ao964apYN,} ,["amount"] = 1,["index"] = 1,} ,}

IsDead

Returns a bool indicating if the player (character) is dead

if TMC.Functions.IsDead() then
    --
end

IsMale

Returns a bool indicating if the player (character) has a male body type

if TMC.Functions.IsMale() then
    --
end

IsFemale

Returns a bool indicating if the player (character) has a female body type

if TMC.Functions.IsFemale() then
    --
end

HasJob

Returns a bool indicating if the player (character) has the defined job. If a grade is also defined, it'll return a bool indicating if the player (character) has the defined job and grade. If the player (character) doesn't have the job (and optionally, the grade) then it'll return a second string value indicating if the mismatch is the defined job or grade

Parameter
Requried
Type
Description

job

String

The job name that the player must have

grade

Number

The grade number that the player must have

-- Example Player Job Data
-- { [1] = { ["grade"] = { ["level"] = 3,["name"] = Sergeant,} ,["onduty"] = true,["name"] = police,["isBusiness"] = false,["label"] = Law Enforcement,["isPolice"] = true,["payment"] = 870,}

if TMC.Functions.HasJob("police") then
    --
end

if TMC.Functions.HasJob("police", 3) then
    --
end

local hasJob = TMC.Functions.HasJob("police", 3)
-- hasJob = true

local hasJob, reason = TMC.Functions.HasJob("ems", 3)
-- hasJob = false
-- reason = "job"

local hasJob, reason = TMC.Functions.HasJob("police", 5)
-- hasJob = false
-- reason = "grade"

HasGrade

Returns a bool indicating if the player (character) has the defined job and grade access

Parameter
Required
Type
Description

job

String

The job name that the player must have

grade

Number

The grade number that the player must have

maxGrade

Bool

This defines the grade floor and ceiling when checking for access

-- Example Job Grade Data
-- { [1] = "High Command Staff", [2] = "Command Staff", [3] = "Sergeant", [4] = "Senior Officer", [5] = "Officer" }

-- Example Player Job Data
-- { [1] = { ["grade"] = { ["level"] = 3,["name"] = Sergeant,} ,["onduty"] = true,["name"] = police,["isBusiness"] = false,["label"] = Law Enforcement,["isPolice"] = true,["payment"] = 870,}

if TMC.Functions.HasGrade("police", 3, false) then
    -- player has the police job and a grade level between 1 - 3
end

if TMC.Functions.HasGrade("police", 3, true) then
    -- player has the police job and a grade level between 3 - 5
end

IsOnDuty

Returns either a bool or a string indicating if the player is on duty for any or the optionally defined job. If the player is on duty, it'll also return the grade level of the on-duty job

Parameter
Required
Type
Description

job

String

The job name that'll be used to check if the player is on duty

if TMC.Functions.IsOnDuty() then
    --
end

-- Example Player Job Data
-- { [1] = { ["grade"] = { ["level"] = 3,["name"] = Sergeant,} ,["onduty"] = true,["name"] = police,["isBusiness"] = false,["label"] = Law Enforcement,["isPolice"] = true,["payment"] = 870,}

if TMC.Functions.IsOnDuty("police") then
    --
end

local job, grade = TMC.Functions.IsOnDuty()
-- job = "police"
-- grade = 3

if TMC.Functions.IsOnDuty() == "police" then
    --
end

OnDutyBusiness

Returns either a bool or a string indicating if the player is on duty for a job that is a business

if TMC.Functions.OnDutyBusiness() then
    --
end

-- Example Player Job Data
-- { [1] = { ["grade"] = { ["level"] = 1,["name"] = Manager,} ,["onduty"] = true,["name"] = realtor,["isBusiness"] = true,["label"] = Dynasty 8,["isPolice"] = false,["payment"] = 300,}

local job = TMC.Functions.OnDutyBusiness()
-- job = "realtor"

if TMC.Functions.OnDutyBusiness() == "realtor" then
    --
end

HasItem

Returns a bool indicating if the player (character) has the defined item

Parameter
Required
Type
Description

name

String

The item name to check for

if TMC.Functions.HasItem("apple") then
    --
end

GetItemAmountByName

Returns a number indicating the amount of defined item the player (character) has

Parameter
Required
Type
Description

name

String

The item name to check the amount for

local amount = TMC.Functions.GetItemAmountByName("apple")

if TMC.Functions.GetItemAmountByName("apple") == 1 then
    --
end

GetItemsByPredicate

Returns an array of the player's (character) items that the defined predicate evaluates to be true

local goodApples = TMC.Functions.GetItemsByPredicate(function(item)
    if item and item.name == "apple" and TMC.Common.GetItemQuality(item.info) > 0 then
        return true
    end
end)

Game Wrappers

LoadModel

Attempts to load the specified model with a 5 second timeout

Parameter
Required
Type
Description

model

Number

The object model hash to load

TMC.Functions.LoadModel(GetHashKey("v_ind_ss_chair01"))
TMC.Functions.LoadModel(`v_ind_ss_chair01`)

LoadParticleFx

Attempts to load the specified particle fx with a 5 second timeout

Parameter
Required
Type
Description

ptfx

String

The particle fx name to load

TMC.Functions.LoadParticleFx('scr_ih_fin')

LoadAnimDict

Attempts to load the specified animation dictionary with a 5 second timeout

Parameter
Required
Type
Description

dict

String

The animation dictionary to load

TMC.Functions.LoadAnimDict('mp_common')

StartPropAnim

Tasks your player to do an animation and attaches an object/prop to the player

Parameter
Required
Type
Description

options

Array

Animation/Prop configuration

local tabletAnim = TMC.Functions.StartPropAnim({
    dict = 'amb@code_human_in_bus_passenger_idles@female@tablet@idle_a',
    anim = 'idle_a',
    prop = 'prop_cs_tablet',
    boneIndex = 28422,
    placement = {-0.05, 0.0, 0.0, 0.0, 0.0, 0.0},
    duration = -1,
    delayProp = false, -- Adds a delay in ms to create/attach prop
})

StopPropAnim

Stops animation task and cleans up attached object/prop

Parameter
Required
Type
Description

options

Array

Animation/Prop configuration

local tabletAnim = TMC.Functions.StartPropAnim({
    dict = 'amb@code_human_in_bus_passenger_idles@female@tablet@idle_a',
    anim = 'idle_a',
    prop = 'prop_cs_tablet',
    boneIndex = 28422,
    placement = {-0.05, 0.0, 0.0, 0.0, 0.0, 0.0},
    duration = -1,
    delayProp = false, -- Adds a delay in ms to create/attach prop
})

TMC.Functiosn.StopPropAnim(tabletAnim)

TeleportToCoords

Teleports player to specified coords with various options

Parameter
Required
Type
Description

coords

Vec2/3/4

Coords to teleport to

includeVehicle

Bool

If you're in a vehicle, this will teleport the vehicle and any occupants to the specified coords

delay

Number

Adds specified amount of delay (in ms) after the teleport is complete before fading the screen in

preFadeTime

Number

Screen fade out time (in ms) before teleport happens

postFadeTime

Number

Screen fade in time (in ms) after teleport happens

plyFade

Bool

If true, this will fade the entity out before the teleport and fade the entity in after the teleport

local blipCoords = TMC.Functions.GetMarkerCoords()
TMC.Functions.TeleportToCoords(blipCoords, false, false, false, false, true)

GetMarkerCoords

Return a vector2 of marked blip on the map

TMC.Functions.GetMarkerCoords()
-- Example Output: vector2(1485.76, 807.7446)

TeleportToMarker

Used to teleport the a map marker

Parameter
Required
Type
Description

includeVehicle

Bool

Specifies if you want to teleport the vehicle that the the player is in

TMC.Functions.TeleportToMarker(false)

GetPeds

Returns an array containing entity handles for each entity in the ped game pool

-- GetGamePool("CPed")
local peds = TMC.Functions.GetPeds()
for k,v in ipairs(peds) do
    -- v = entity
end

GetFilteredPeds

Returns an array containing entity handles for each entity in the ped game pool

Parameter
Required
Type
Description

ignoreList

Array

An array of entities to filter out of the return array

local filterOut = {123456, 654321}
local peds = TMC.Functions.GetFilteredPeds(filterOut)
for k,v in ipairs(peds) do
    -- v = entity
end

GetClosestPed

Returns the closest ped entity handle and its distance

Parameter
Required
Type
Description

coords

vector3

The coords at which to find the closest ped. If not passed through it'll use your ped's coords

ignoreList

Array

An array of entities to filter out of the return array

local closestPed, closestDistance = TMC.Functions.GetClosestPed()

local filterOut = {123456, 654321}
local closestPed, closestDistance = TMC.Functions.GetClosestPed(GetEntityCoords(PlayerPedId()), filterOut)

Notifications

SimpleNotify

Executes a simplified config with TMC.Functions.Notify

Parameter
Required
Type
Description

message

String

The message to include in the notification

ntype

String

The notification type to use with the notification

time

Number

The duration in ms the notification should show for

TMC.Functions.SimpleNotify("Test notification", "info", 2000)

Notify

Used to show a notification

Parameter
Required
Type
Description

notifConfig

Array

Notification config array

TMC.Functions.Notify({
	message = 'Test', -- String, Required
	length = 2000, -- Number (MS)
	id = 'test_notif', -- String, Required for persist notifs or updates
	persist = true, -- Boolean, requires id
	notifType = 'info', -- String (See list below)
	icon = '', -- String, can be any unicode icon
	style = {}, -- Table of css
})

-- Notif Types
-- "info"
-- "success"
-- "warning"
-- "error"
-- "loader"
-- "speech"
-- "default" (The default if nothing is entered (or `default` is entered) it has no icon unless specified with the `icon` parameter)

StopNotify

Used to stop a notification

Parameter
Required
Type
Description

id

String

Notification id to stop

TMC.Functions.Notify({
	message = 'Test', -- String, Required
	length = 2000, -- Number (MS)
	id = 'test_notif', -- String, Required for persist notifs or updates
	persist = true, -- Boolean, requires id
	notifType = 'info', -- String (See list below)
	icon = '', -- String, can be any unicode icon
	style = {}, -- Table of css
})

TMC.Functions.StopNotify("test_notif")

DeleteEntity

Deletes a networked or non-networked entity. If the entity is networked it'll move the delete request to the server to avoid any entity ownership issues

Parameter
Required
Type
Description

ent

Number

Entity handle to delete

TMC.Functions.DeleteEntity(123456)

UI Functions

CreateUiStat

Create custom HUD elements

Parameter
Required
Type
Description

statName

String

The name of the element to create

statType

String

Which group of elements to add to. Supports: primary, secondary & vehicle

statConfig

Object

An object containing settings for the stat type. All parameters of the object are optional. See below for info.

TMC.Functions.CreateUiStat('testStat', 'primary', {
    icon = 'fas fa-circle', -- Font awesome icon
    iconColor = nil, -- hex color for custom icon color
    color = '#6c757d', -- hex background color
    alwaysShow = false, -- Should the element always be shown
    useAlerts = false, -- Should it use the alerts system instead of percentage
    showPreferences = { -- If alwaysShow set to false custom logic
        isMinimum = true, -- Show when stat is greater than value, set to false for opposite.
        value = 0 -- value that this hud element should show at
    }
})

UpdateUiStat

Update HUD element info

Parameter
Required
Type
Description

statName

String

The name of the element to create

statConfig

Object

An object containing settings to update for the stat type. See below for options.

TMC.Functions.UpdateUiStat('testStat', {
    icon = '',
    count = 0, -- Used when "useAlerts" is set to true
    percentage = 0, -- How much to fill
    active = false, -- Toggle active icon (Voice toggle)
    visible = false, -- Force toggle visibility
    iconColour = '', -- Update the icon color
})

StartTimer

Used to create a timer HUD element with callback function

Parameter
Required
Type
Description

id

String

Timer ID

length

Number

Length of timer (in ms)

tooltip

String

Tooltip text that'll appear when the HUD element is hovered over

icon

String

Font Awesome icon reference

cb

Function

Callback function triggered when timer is complete

TMC.Functions.StartTimer("test", 10000, "Test Tooltip", "fas fa-timer", function()
    -- timer completed
end)

StopTimer

Used to immediately stop an active timer

Parameter
Required
Type
Description

id

String

Timer ID

TMC.Functions.StopTimer("test")

ShowDoorlockIndicator

Used to show the doorlock indicator HUD element

Parameter
Required
Type
Description

locked

Bool

This will indicate if the HUD element will show as an open or closed door

TMC.Functions.ShowDoorlockIndicator(true)

HideDoorlockIndicator

Used to hide the doorlock indicator HUD element

TMC.Functions.HideDoorlockIndicator()

Clipboard

Used to allow the user to copy information to their clipboard

Parameter
Required
Type
Description

data

String

The data to present and copy to the clipboard

title

String

The title of the clipboard modal

TMC.Functions.Clipboard('https://discord.gg/themoddingcollective', 'TMC Discord')

Other

HasPermission

Returns a bool indicating if the client has the defined permission access

Parameter
Required
Type
Description

reqPerm

String

The permission name

if TMC.Functions.HasPermission("admin") then
    --
end

GetCoords

Returns a vector4 of the position of the player or the defined entity

Parameter
Required
Type
Description

entity

Number

The entity handle to get the position of

local plyPos = TMC.Functions.GetCoords()

local entityPos = TMC.Functions.GetCoords(123456)

GetStreetLabel

Returns a string with the label street (and optionally the zone) at the defined coords

Parameter
Required
Type
Description

coords

Number

The desired coords for the street label. If not defined then it'll use your player coords

disableZone

Bool

Used if you want to include the zone name or not

local streetLabel = TMC.Functions.GetStreetLabel()
-- Example Output: "Alta St, Pillbox Hill" 

local streetLabel = TMC.Functions.GetStreetLabel(false, true)
-- Example Output: "Alta St"

local streetLabel = TMC.Functions.GetStreetLabel(GetEntityCoords(PlayerPedId()))
-- Example Output: "Alta St, Pillbox Hill" 

GetPlayerList

Returns an array containing players on the server

local players = TMC.Functions.GetPlayerList()
-- Example Output:
-- {
--     [1] = {
--         steam = "steam:11000010abcd123",
--         name = "John Doe",
--         citizenid = "ABC12345",
--         position = vector4(-206.6901, -1015.108, 30.12231, 283.4646)
--     },
--     [2] = {
--         steam = "steam:11000010efgh456",
--         name = "Jane Doe",
--         citizenid = "EFG67890",
--         position = vector4(-206.6901, -1015.108, 30.12231, 283.4646)
--     }
-- }

GetPlayer

Returns an array of the specified player

Parameter
Required
Type
Description

src

Number

The target players server id

local player = TMC.Functions.GetPlayer(GetPlayerServerId(PlayerId()))
-- Example Output:
-- [1] = {
--     steam = "steam:11000010abcd123",
--     name = "John Doe",
--     citizenid = "ABC12345",
--     position = vector4(-206.6901, -1015.108, 30.12231, 283.4646)
-- }

GetCoordsForPlayer

Returns a vector4 of the specified player

Parameter
Required
Type
Description

src

Number

The target players server id

local player = TMC.Functions.GetCoordsForPlayer(GetPlayerServerId(PlayerId()))
-- Example Output: vector4(-206.6901, -1015.108, 30.12231, 283.4646)

GetPlayerCount

Returns the number of players on the server

local count = TMC.Functions.GetPlayerCount()
-- Example Output: 15

GetOnscreenKeyboardInput

Returns an array of the specified player

Parameter
Required
Type
Description

TextEntry

String

The text above the typing field in the black square

ExampleText

String

An example text, what it should say in the typing field

MaxStringLength

Number

Maximum string length

local text = TMC.Functions.GetOnscreenKeyboardInput("Input Text", "", 10)
-- Example Output: "Test text"

IsOnscreenKeyboard

Returns a bool indicating if the on-screen keyboard is active

if TMC.Functions.IsOnscreenKeyboard() then
    --
end

Last updated