Player Functions

Functions available on the server player object. Use GetPlayer to retrieve the object.

GetPlayer

To first access the player functions, you need to get the player

Parameter
Required
Type
Description

source

Number

Source of the player

TMC.Functions.RegisterServerEvent("example:server:getPlayer", function(src)
    local source = src
    local player = TMC.Functions.GetPlayer(source)
end)

Money

AddMoney

Add money to the player in the selected place

Parameter
Required
Type
Description

type

String

Money type e.g. cash or bank

amount

Number

Amount to be added

reason

String

Reason (Shown on bank statements)

-- Returns if the payment was successful

local player = TMC.Functions.GetPlayer(source)

local success = player.Functions.AddMoney("cash", 1000, "Example Payment")

RemoveMoney

Remove money from the player in the selected place

Parameter
Required
Type
Description

type

String

Money type e.g. cash or bank

amount

Number

Amount to be removed

reason

String

Reason (Shown on bank statements)

Jobs

AddJob

Add a job to the player

Parameter
Required
Type
Description

job

String

The job to add to the player

grade

Number

The grade to set the player to. If not set will default to 1

RemoveJob

Remove a job to the player

Parameter
Required
Type
Description

job

String

The job to remove from the player

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

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

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

OnDutyBusiness

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

SetJobDuty

Returns a bool indicating if the player duty was set

Parameter
Required
Type
Description

job

String

The job to set duty for

onDuty

Bool

If the player should be set on duty

Items

AddItem

Add an item to the player's inventory

Parameter
Required
Type
Description

item

String

The item to add to the player

amount

Number

The amount of items to add

slot

Number

The specific slot to add the item to

info

Object

The info/metadata for the object

RemoveItem

Remove an item to the player's inventory

Parameter
Required
Type
Description

item

String

The item to remove from the player

amount

Number

The amount of items to remove

slot

Number

The specific slot to remove the item from

UpdateItemInfo

Update the metadata/info of a specific item

Parameter
Required
Type
Description

slot

Number

The slot to update

slotIndex

Number

The slot index to update

info

Object

The updated item metadata (full object)

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

Crypto

AddCrypto

Add cryptocurrency to the player

Parameter
Required
Type
Description

crypto

String

Crypto key (See laptop/configCrypto.lua)

amount

Number

Amount to be added

RemoveCrypto

Remove cryptocurrency from the player

Parameter
Required
Type
Description

cryptoe

String

Crypto key (See laptop/configCrypto.lua)

amount

Number

Amount to be removed

Other

SetMetaData

Set metadata on the player object

Parameter
Required
Type
Description

metadataKey

String

The key to set within the player object

value

Any

The value to set

SetReputation

Set the rep value for a player. Will initialise at a value of 0 if it doesn't exist

Parameter
Required
Type
Description

rep

String

The rep to set

value

Any

The value to set

AddReputation

Adds the rep value to the existing rep for a player. Will initialise at a value of 0 if it doesn't exist

Parameter
Required
Type
Description

rep

String

The rep to add to

value

Any

The value to add

GetFullName

Returns the full name of the player character

Last updated