Server Character

Import

-- Example name of admin group, if you do not have an admin group you can use a not used group name.
local name_of_admin_group = 'admin'

---@type NssLibsCharacterApi
character_api = exports.nss_libs:getCharacterApi(GetCurrentResourceName(), name_of_admin_group)

Methods

addMoney(_source, amount)

  • _source (integer) - The server player id of a joined player.

  • amount (float) - The amount of money to add.

Returns nothing.

local example_player_id = 99 -- The server player id of a joined player
character_api:addMoney(example_player_id, 1000)

getCharacterByName(character_name)

  • character_name (string) - The full character name to search for.

Important: This method loads the data from the database and not from the VORP (or other framework) cache. In case of VORP a change of group or job will be not saved at the moment the job or group is changed.

Returns an NssLibsCharacterItem instance or nil if not found.


getCharacterByCharId(char_id)

  • char_id (integer) - The character id to search for.

Important: This method loads the data from the database and not from the VORP (or other framework) cache. In case of VORP a change of group or job will be not saved at the moment the job or group is changed.

Returns an NssLibsCharacterItem instance or nil if not found.


getCharData(_source)

  • _source (integer) - The server player id of a joined player.

Returns an NssLibsCharacterItem instance or nil if not found.


getDiscordId(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the discord id.


getDiscordProfileUrl(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the discord profile url.


getFivmId(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the fivem id.


getIdentifiers(_source)

  • _source (integer) - The server player id of a joined player.

Returns an NssLibsCharacterIdentifiers instance.

getIp(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the ip.


getRedmCharacterName(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the redm character name.


getSteamId(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the steam id.


getSteamProfileUrl(_source)

  • _source (integer) - The server player id of a joined player.

Returns a string with the steam profile url.


hasMoney(_source, amount)

  • _source (integer) - The server player id of a joined player.

  • amount (float) - The amount of money to check for.

Returns a boolean if the player has the amount of money.


subMoney(_source, amount)

  • _source (integer) - The server player id of a joined player.

  • amount (float) - The amount of money to remove.

Returns nothing.


addGold(_source, amount)

  • _source (integer) - The server player id of a joined player.

  • amount (float) - The amount of gold to add.

Returns nothing.


hasGold(_source, amount)

  • _source (integer) - The server player id of a joined player.

  • amount (float) - The amount of gold to check for.

Returns a boolean if the player has the amount of gold.


subGold(_source, amount)

  • _source (integer) - The server player id of a joined player.

  • amount (float) - The amount of gold to remove.

Returns nothing.


onGroupChange(callback)

Since version 0.33.0.

  • callback (function) - The function to call when the group changes.

    • source (integer) - The server player id of a joined player.

    • char_id (string) - The character id of the player.

    • new_group (string) - The new group of the player.

Returns NssLibsSharedHelperEventHandlerApi.


onJobChange(callback)

Since version 0.33.0.

  • callback (function) - The function to call when the job changes.

    • source (integer) - The server player id of a joined player.

    • char_id (string) - The character id of the player.

    • new_job (string) - The new job of the player.

Returns NssLibsSharedHelperEventHandlerApi.


onJobGradeChange(callback)

Since version 0.33.0.

  • callback (function) - The function to call when the job grade changes.

    • source (integer) - The server player id of a joined player.

    • char_id (string) - The character id of the player.

    • new_job_grade (integer) - The new job grade of the player.

Returns NssLibsSharedHelperEventHandlerApi.


getSteamIdOfChar(char_id)

Since version 0.33.0.

  • char_id (integer) - The character id to search for.

Returns a string with the steam id or nil if not found.


getSourceOfChar(char_id)

Since version 0.33.0.

  • char_id (integer) - The character id to search for.

Returns a number with server player id or nil if not found.


Objects

NssLibsCharacterItem

Properties

  • char_id (integer)

  • group (string)

  • job (string)

  • job_grade (integer)

  • firstname (string)

  • lastname (string)

  • full_name (string)

  • money (float)

  • is_admin (boolean)

  • server_player_id (integer, nil)


Methods

hasOneOfTheJobs(jobs)

  • jobs (NssLibsCharacterJobList|NssLibsCharacterJobName[]) - The job list or job names to check for. The job names are case-sensitive.

Returns a boolean if the character has one of the jobs.


hasJob(job)

  • job (NssLibsCharacterJobName) - The job name to check for. The job name is case-sensitive.

Returns a boolean if the character has the job.


hasJobGrade(grade)

  • grade (integer) - The job grade to check for.

Returns a boolean if the character has the job grade.


isEmployed()

Returns a boolean if the character has a job.

NssLibsCharacterIdentifiers

Properties

  • steam (string)

  • license (string)

  • xbl (string)

  • live (string)

  • discord (string)

  • fivem (string)

  • license2 (string)

  • ip (string)


Last updated

Was this helpful?