### Resource Start Order in server.cfg Source: https://ndcore.dev/setup Specifies the order in which essential resources should be started in the server.cfg file. It's crucial for dependencies like oxmysql, ox_lib, and ND_Core to be loaded before other resources. ```cfg start oxmysql start ox_lib start ND_Core # all other resources below ``` -------------------------------- ### ND Core Configuration (ndcore.cfg) Source: https://ndcore.dev/setup This configuration file sets up various server parameters for ND Core, including server name, Discord integration details (invite link, app ID, assets, action buttons), and character identifier settings. Ensure 'exec ndcore.cfg' is called before starting ND_Core. ```cfg # Your servers name setr core:serverName "My FiveM Server" # Discord invite link setr core:discordInvite "https://discord.gg/Z9Mxu72zZ6" # Discord app id for rich presence setr core:discordAppId "858146067018416128" # Images for discord rich presence setr core:discordAsset "andyyy" setr core:discordAssetSmall "andyyy" # Buttons for discord rich presence setr core:discordActionText "DISCORD" setr core:discordActionLink "https://discord.gg/Z9Mxu72zZ6" setr core:discordActionText2 "STORE" setr core:discordActionLink2 "https://andyyy.tebex.io/category/fivem-scripts" # Used for getting users roles from your server, this can be useful for discord based scripts, if you don't add then it won't be used. # set core:discordGuildId "123456789012345678" # set core:discordBotToken "EXAMPLE_TOKEN.abc123.xyz456" # if set to true, and you have your discord token connected, users will have to join your discord to join your fivem server. set core:discordMemeberRequired false # The identifier to use for characters. Players aren't allowed to join without it, license is good don't change unless you know what you're doing. set core:characterIdentifier "license" ``` -------------------------------- ### Configure Core Settings (Server) Source: https://ndcore.dev/setup Sets core gameplay parameters such as disabling vehicle air control, adjusting random vehicle unlock chances, and enforcing key requirements for starting engines. These settings directly impact player interaction with vehicles. ```lua setr core:disableVehicleAirControl true setr core:randomUnlockedVehicleChance 30 setr core:requireKeys true setr core:useInventoryForKeys true ``` -------------------------------- ### Framework Compatibility and Permissions (Server) Source: https://ndcore.dev/setup Configures compatibility with other server frameworks and grants necessary permissions for ox_lib to manage commands. This ensures smooth integration and proper functionality of associated scripts. ```lua setr core:compatibility ["backwards"] add_ace resource.ox_lib command.add_ace allow add_ace resource.ox_lib command.remove_ace allow add_ace resource.ox_lib command.add_principal allow add_ace resource.ox_lib command.remove_principal allow ``` -------------------------------- ### txAdmin Recipe URL for ND Main Source: https://ndcore.dev/setup This is the remote URL template used with txAdmin to deploy the ND Main framework. It ensures all necessary free resources and the new character creation system are included for a complete server experience. ```yaml https://raw.githubusercontent.com/ND-Framework/txadmin-recipe/main/nd-main.yaml ``` -------------------------------- ### Configure NPWD Framework in server.cfg Source: https://ndcore.dev/addons/phone Sets the NPWD framework to 'ndcore' within the server configuration file. This ensures compatibility and proper integration between NPWD and NDCORE. ```cfg set npwd:framework ndcore ``` -------------------------------- ### Define In-Game Groups and Ranks (Server) Source: https://ndcore.dev/setup Sets up various in-game groups such as jobs, gangs, and emergency services. It defines the label, minimum boss rank, and available ranks within each group, structuring player progression and roles. ```lua setr core:groups { "unemployed": { "label": "Unemployed", "minimumBossRank": 1, "ranks": ["Unemployed"] }, "sahp": { "label": "SAHP", "minimumBossRank": 5, "ranks": ["Trooper", "Senior Trooper", "Corporal", "Sergeant", "Lieutenant", "Chief"] }, "lspd": { "label": "LSPD", "minimumBossRank": 5, "ranks": ["Officer", "Senior officer", "Corporal", "Sergeant", "Lieutenant", "Chief"] }, "bcso": { "label": "BCSO", "minimumBossRank": 5, "ranks": ["Officer", "Senior officer", "Corporal", "Sergeant", "Lieutenant", "Chief"] }, "swat": { "label": "SWAT", "minimumBossRank": 3, "ranks": ["Member", "Sniper", "Team lead", "Commander"] }, "lsfd": { "label": "LSFD", "minimumBossRank": 5, "ranks": ["Volunteer", "Firefighter", "Senior firefighter", "Lieutenant", "Fire Chief"] }, "ballas": { "label": "Ballas", "minimumBossRank": 2, "ranks": ["Member", "Leader"] }, "families": { "label": "Families", "minimumBossRank": 2, "ranks": ["Member", "Leader"] }, "cartel": { "label": "Madrazo Cartel", "minimumBossRank": 2, "ranks": ["Member", "Leader"] } } ``` -------------------------------- ### Admin and Role Configuration (Server) Source: https://ndcore.dev/setup Defines administrators and their associated Discord roles. It also maps Discord roles to in-game groups, granting players specific permissions and access based on their roles. ```lua set core:admins ["fivem:1459624", "fivem:1152629"] set core:adminDiscordRoles ["944284542758449212", "93422454258349612", "93345451558145232"] set core:groupRoles { "staff": ["955176855474929694", "1010595496915648624"] } ``` -------------------------------- ### Configure NPWD Database Settings in config.json Source: https://ndcore.dev/addons/phone Defines the database connection and table mapping for NPWD. It specifies how player data, including phone numbers, should be accessed and stored. ```json "database": { "useIdentifierPrefix": true, "playerTable": "nd_characters", "identifierColumn": "identifier", "identifierType": "license", "profileQueries": true, "phoneNumberColumn": "phonenumber" } ``` -------------------------------- ### Check Resource Started Status (Lua) Source: https://ndcore.dev/core/shared/functions Checks if a specified resource has started. It optionally accepts a callback function to be executed when the resource's state changes. Returns a boolean indicating the current started state. ```lua local started = NDCore.isResourceStarted(resourceName, cb) ``` ```lua local started = NDCore.isResourceStarted("ND_Fuel") print(started) ``` ```lua NDCore.isResourceStarted("ND_Fuel", function(started) print("ND_Fuel status started:", started) end) ``` -------------------------------- ### Example: Iterating and Printing Owned Vehicles Source: https://ndcore.dev/core/server/functions Demonstrates how to retrieve a player's vehicles using getVehicles and then iterate through them, printing their details in JSON format. It also shows the expected structure of a vehicle object. ```lua local player = NDCore.getPlayer(source) local vehicles = NDCore.getVehicles(player.id) for i=1, #vehicles do local veh = vehicles[i] print(json.encode(veh, {indent=true})) --[[ { id = 5, owner = 25, plate = "1234ABCD", properties = json.decode(vehicle.properties) or {}, stored = true, impounded = false, stolen = false, available = true } ]] end ``` -------------------------------- ### Resource Start Order Configuration Source: https://ndcore.dev/addons/characters This snippet shows the necessary commands to ensure the fivem-appearance and ND_Characters resources are loaded in the correct order within the server.cfg file. Proper order is crucial for dependencies to function correctly. ```cfg start fivem-appearance start ND_Characters ``` -------------------------------- ### Get Player License (Lua) Source: https://ndcore.dev/core/server/player Retrieves license information for a player character based on a provided identifier. Returns a table containing license details. ```lua player.getLicense(identifier) ``` ```lua local player = NDCore.getPlayer(source) local licenses = player.getMetadata("licenses") or {} local driverLicense = nil for i=1, #licenses do local license = licenses[i] if licenses.type == "driver" then driverLicense = licenses.identifier break end end if driverLicense then local license = player.getLicense(driverLicense) print(json.encode(license, {indent=true})) --[[ type = "driver", status = "valid", issued = 123123, expires = 123123, identifier = 123abc123abc ]] end ``` -------------------------------- ### Get Player Data Source: https://ndcore.dev/core/server/functions Retrieves a player's data and associated functions using their source ID. Returns a table containing player information. ```lua local player = NDCore.getPlayer(source) ``` -------------------------------- ### Get Players by Criteria Source: https://ndcore.dev/core/server/functions Retrieves active players based on specified criteria (key and value). Can return players as an array or an object indexed by their source ID. If no key or value is provided, all active players are returned. ```lua NDCore.getPlayers(key, value, returnArray) ``` ```lua local players = NDCore.getPlayers("job", "windowcleaner", true) for i=1, #players do local ply = players[i] print(ply.fullname) end ``` ```lua local players = NDCore.getPlayers("job", "windowcleaner", false) for playerSource, playerData in pairs(players) do print(playerData.fullname) end ``` -------------------------------- ### Get Player Server Info Source: https://ndcore.dev/core/server/functions Retrieves server-specific information for a player, including their identifiers and Discord details. This function is similar to combining player data and getDiscordInfo. ```lua local info = NDCore.getPlayerServerInfo(source) ``` -------------------------------- ### Get Vehicle Data by ID Source: https://ndcore.dev/core/server/functions Retrieves detailed data for a specific vehicle using its ID. Returns information such as owner, plate, properties, and availability status. ```lua local vehicle = NDCore.getVehicleById(id) print(json.encode(vehicle, {indent=true})) -- [[ -- { -- id = 5, -- owner = 25, -- plate = "1234ABCD", -- properties = json.decode(vehicle.properties) or {}, -- stored = true, -- impounded = false, -- stolen = false, -- available = true -- } -- ]] ``` -------------------------------- ### AI Ped Lifecycle Example (Lua) Source: https://ndcore.dev/core/client/functions Demonstrates the typical lifecycle of creating and removing an AI ped. First, an AI ped is created using `createAiPed` and its ID is stored. Then, the `removeAiPed` function is called using the stored ID to remove the NPC. ```lua local id = NDCore.createAiPed(info) NDCore.removeAiPed(id) ``` -------------------------------- ### Get NDCore Vehicle by Entity Source: https://ndcore.dev/core/server/functions Retrieves a vehicle entity from NDCore using its numerical entity ID. It returns a table representing the vehicle. ```lua local vehicle = NDCore.getVehicle(entity) ``` -------------------------------- ### Get Player Data (Lua) Source: https://ndcore.dev/core/server/player Retrieves specific data associated with a player character. It takes a data key as a string and returns the requested data. ```lua player.getData(data) ``` ```lua local player = NDCore.getPlayer(source) local playerName = player.getData("fullname") print(playerName) ``` -------------------------------- ### Get Discord Info by User ID Source: https://ndcore.dev/core/server/functions Fetches Discord information for a user based on their Discord User ID. Returns nil if the user is not found, otherwise returns their nickname, username, and roles. ```lua local discordInfo = NDCore.getDiscordInfo(discordUserId) ``` -------------------------------- ### Get Player Metadata (Lua) Source: https://ndcore.dev/core/server/player Fetches metadata for a player character. Metadata can be accessed using a string key or a table of keys. The function returns the requested metadata. ```lua player.getMetadata(metadata) ``` ```lua local player = NDCore.getPlayer(source) local count = player.getMetadata("deathCount") if count then local result = ("%s died %d times"):format(player.name, count) print(result) -- John died 5 times end ``` ```lua local player = NDCore.getPlayer(source) local metadata = player.getMetadata({"deathCount", "currentlyDead"}) local name = player.name if metadata.currentlyDead then local result = ("%s is currently dead"):format(name) print(result) -- John is currently dead end if metadata.deathCount then local result = ("%s died %d times"):format(name, count) print(result) -- John died 5 times end ``` -------------------------------- ### Get Player Job and Job Information Source: https://ndcore.dev/core/server/player Retrieves the player's current job name and associated job information. The job information table contains details similar to those returned by addGroup. ```lua local player = NDCore.getPlayer(source) local jobName, jobInfo = player.getJob() ``` -------------------------------- ### Get All Owned Vehicles for a Character Source: https://ndcore.dev/core/server/functions Fetches a table containing all vehicles owned by a specific character, identified by their characterId. This function provides similar information to getVehicleById. ```lua NDCore.getVehicles(characterId) ``` -------------------------------- ### Get Player Data (Lua) Source: https://ndcore.dev/core/client/functions Retrieves player-specific data. This function returns only the player's data table and does not include any associated player functions. It is a client-side function. ```lua local player = NDCore.getPlayer() ``` -------------------------------- ### Get Player Group Information Source: https://ndcore.dev/core/server/player Retrieves information about a specific group associated with the player's character. The 'name' parameter is the group's identifier. It returns a table with group details. ```lua local player = NDCore.getPlayer(source) local group = player.getGroup("swat") print(json.encode(group, {indent=true})) --[[ label = "SWAT", rankName = "Commander", rank = 4, isJob = nil ]] ``` -------------------------------- ### Import NDCore Server or Client Script in fxmanifest.lua Source: https://ndcore.dev/core Shows how to import NDCore specifically for either the server or client side, reducing overhead if only one environment requires its functionalities. This is useful for optimization. ```lua server_script "@ND_Core/init.lua" ``` ```lua client_script "@ND_Core/init.lua" ``` -------------------------------- ### Player License Management Source: https://ndcore.dev/core/server/player Functions to create, retrieve, and update player licenses. ```APIDOC ## POST /api/player/createLicense ### Description Creates a new license for the character. Licenses can be of any type (e.g., weapon, driver, hunting). ### Method POST ### Endpoint /api/player/createLicense ### Parameters #### Request Body - **licenseType** (string) - Required - The type of license to create. - **expire** (number) - Optional - The expiration timestamp of the license. If not provided, it defaults to one month from the current time. ### Request Example ```json { "licenseType": "driver", "expire": 1678886400 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the license was created successfully. #### Response Example ```json { "success": true } ``` ## GET /api/player/getLicense ### Description Retrieves a specific license associated with the player. ### Method GET ### Endpoint /api/player/getLicense ### Parameters #### Query Parameters - **identifier** (string) - Required - The unique identifier of the license to retrieve. ### Response #### Success Response (200) - **data** (table) - A table containing the license details. #### Response Example ```json { "data": { "type": "driver", "status": "valid", "issued": 1678800000, "expires": 1710422400, "identifier": "123abc123abc" } } ``` ## PUT /api/player/updateLicense ### Description Updates the data for an existing player license. ### Method PUT ### Endpoint /api/player/updateLicense ### Parameters #### Request Body - **identifier** (string) - Required - The identifier of the license to update. - **newData** (table) - Required - A table containing the new data to apply to the license. ### Request Example ```json { "identifier": "123abc123abc", "newData": { "status": "suspended" } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the license was updated successfully. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Create Player License (Lua) Source: https://ndcore.dev/core/server/player Creates a new license for a player character. Licenses can be of any type (e.g., 'driver', 'weapon'). An optional expiration timestamp can be provided; otherwise, it defaults to one month. ```lua player.createLicense(licenseType, expire) ``` ```lua -- create a driver license that expires in a month. player.createLicense("driver", os.time()+2592000) ``` -------------------------------- ### Open Wardrobe Export in FiveM Lua Source: https://ndcore.dev/addons/appearanceshops This Lua code snippet demonstrates how to call the `openWardrobe` export function from the ND_AppearanceShops resource in FiveM. This function is used to open the player's wardrobe, allowing them to manage their appearance. It requires the ND_AppearanceShops resource to be running on the server. ```lua exports["ND_AppearanceShops"]:openWardrobe() ``` -------------------------------- ### Import NDCore Shared Script in fxmanifest.lua Source: https://ndcore.dev/core Demonstrates how to import the NDCore shared script for use in both client and server environments. This is the most common method for integrating NDCore. ```lua shared_script "@ND_Core/init.lua" ``` ```lua shared_scripts { "@ND_Core/init.lua" } ``` -------------------------------- ### Create Invoice Export - ND_Banking Source: https://ndcore.dev/addons/banking Demonstrates how to use the `createInvoice` export from the ND_Banking resource. This function allows for the creation of invoices between entities, with parameters for amount, due date, request status, sender, and receiver information. It's useful for implementing payment requests or mandatory payments within the game. ```lua exports["ND_Banking"]:createInvoice(amount, due, request, from, to) ``` ```lua local from = { name = "Government", account = "0" } local player = NDCore.getPlayer(source) local to = { character = player.id } local banking = exports["ND_Banking"] banking:createInvoice(500, 7, false, from, to) ``` -------------------------------- ### Load SQL File Source: https://ndcore.dev/core/server/functions Executes an SQL query defined in a file using oxmysql. Requires the file location and the resource name. Returns a boolean indicating success. ```lua local success = NDCore.loadSQL(fileLocation, resource) ``` -------------------------------- ### Server Functions API Source: https://ndcore.dev/core/server/functions Functions for managing players and server-side data. ```APIDOC ## getPlayer ### Description Returns the player object, containing player data and functions. ### Method `NDCore.getPlayer(source)` ### Parameters #### Path Parameters - **source** (number) - Required - The source ID of the player. ### Returns - **player** (table) - The player object. ### Request Example ```lua local player = NDCore.getPlayer(source) ``` ``` ```APIDOC ## getPlayers ### Description Retrieves players based on optional key-value filters. Returns players as an array or an object keyed by their source. ### Method `NDCore.getPlayers(key, value, returnArray)` ### Parameters #### Path Parameters - **key** (string) - Optional - The key to filter players by. - **value** (any) - Optional - The value to filter players by. - **returnArray** (boolean) - Optional - If true, returns players as an array; otherwise, as an object. ### Returns - **players** (table) - A table containing the matching players. ### Request Example (Array) ```lua local players = NDCore.getPlayers("job", "windowcleaner", true) for i=1, #players do local ply = players[i] print(ply.fullname) end ``` ### Request Example (Object) ```lua local players = NDCore.getPlayers("job", "windowcleaner", false) for playerSource, playerData in pairs(players) do print(playerData.fullname) end ``` ``` ```APIDOC ## getPlayerServerInfo ### Description Returns server-specific information for a player, including identifiers and Discord details. ### Method `NDCore.getPlayerServerInfo(source)` ### Parameters #### Path Parameters - **source** (number) - Required - The source ID of the player. ### Returns - **info** (table) - A table containing: - **identifiers** (table) - Player identifiers. - **discord** (table) - Player Discord information. ### Request Example ```lua local info = NDCore.getPlayerServerInfo(source) ``` ``` ```APIDOC ## loadSQL ### Description Executes an SQL query from a specified file location within a given resource. ### Method `NDCore.loadSQL(fileLocation, resource)` ### Parameters #### Path Parameters - **fileLocation** (string) - Required - The path to the SQL file. - **resource** (string) - Required - The name of the resource. ### Returns - **success** (boolean) - True if the SQL query was executed successfully, false otherwise. ### Request Example ```lua local success = NDCore.loadSQL(fileLocation, resource) ``` ``` ```APIDOC ## getDiscordInfo ### Description Retrieves Discord information for a user based on their Discord ID. Returns nil if the user is not found. ### Method `NDCore.getDiscordInfo(discordUserId)` ### Parameters #### Path Parameters - **discordUserId** (string) - Required - The Discord user ID. ### Returns - **discordInfo** (table) - A table containing: - **nickname** (string) - The user's nickname. - **user** (string) - The user's username. - **roles** (table) - A table of the user's roles. ### Request Example ```lua local discordInfo = NDCore.getDiscordInfo(discordUserId) ``` ``` ```APIDOC ## enableMultiCharacter ### Description Enables or disables the multi-character system. By default, ND Core is single-character. ### Method `NDCore.enableMultiCharacter(enable)` ### Parameters #### Path Parameters - **enable** (boolean) - Required - Set to true to enable multi-character, false to disable. ### Request Example ```lua NDCore.enableMultiCharacter(enable) ``` ``` ```APIDOC ## newCharacter ### Description Creates a new player character in the database. ### Method `NDCore.newCharacter(source, info)` ### Parameters #### Path Parameters - **source** (number) - Required - The source ID of the player. - **info** (table) - Required - A table containing character details: - **firstname** (string) - **lastname** (string) - **dob** (string) - **gender** (string) - **cash** (number) - **bank** (number) - **groups** (table) - **metadata** (table) - **inventory** (table) ### Returns - **player** (table) - The newly created player object. ### Request Example ```lua local player = NDCore.newCharacter(source, { firstname = "John", lastname = "Doe", dob = "29/03/1999", gender = "male", cash = 2500, bank = 8000 }) print(player.firstname) -- John ``` ``` ```APIDOC ## fetchCharacter ### Description Fetches a specific character from the database using an identifier. Optionally checks if the source owns the character. ### Method `NDCore.fetchCharacter(identifier, source)` ### Parameters #### Path Parameters - **identifier** (string) - Required - The character identifier. - **source** (number) - Optional - The source ID of the player to check ownership. ### Returns - **player** (table) - The player object for the fetched character. ### Request Example ```lua local character = NDCore.fetchCharacter(identifier, source) ``` ``` ```APIDOC ## fetchAllCharacters ### Description Fetches all characters owned by a player. ### Method `NDCore.fetchAllCharacters(source)` ### Parameters #### Path Parameters - **source** (number) - Required - The source ID of the player. ### Returns - **characters** (table) - A table where keys are character IDs and values are character info. ### Request Example ```lua local characters = NDCore.fetchAllCharacters(source) ``` ``` ```APIDOC ## setActiveCharacter ### Description Sets a specific character as the active playing character for a player. ### Method `NDCore.setActiveCharacter(source, id)` ### Parameters #### Path Parameters - **source** (number) - Required - The source ID of the player. - **id** (number) - Required - The character ID to set as active. ### Returns - **player** (table) - The player object with the active character set. ### Request Example ```lua local player = NDCore.setActiveCharacter(source, id) ``` ``` -------------------------------- ### Player Data and Metadata Source: https://ndcore.dev/core/server/player Functions to retrieve and set player data and metadata. ```APIDOC ## GET /api/player/getData ### Description Get specific data from the player's data store. ### Method GET ### Endpoint /api/player/getData ### Parameters #### Query Parameters - **data** (string) - Required - The key of the data to retrieve. ### Response #### Success Response (200) - **data** (any) - The requested data. #### Response Example ```json { "data": "John Doe" } ``` ## GET /api/player/getMetadata ### Description Get metadata associated with a character. Can retrieve a single metadata value or multiple values if a table is provided. ### Method GET ### Endpoint /api/player/getMetadata ### Parameters #### Query Parameters - **metadata** (string | table) - Required - The key or a table of keys for the metadata to retrieve. ### Response #### Success Response (200) - **metadata** (any) - The requested metadata. If a table of keys was provided, this will be a table containing the corresponding values. #### Response Example (string key) ```json { "metadata": 5 } ``` #### Response Example (table keys) ```json { "metadata": { "deathCount": 5, "currentlyDead": false } } ``` ## POST /api/player/setMetadata ### Description Set metadata for a character. Can set a single key-value pair or multiple pairs using a table. ### Method POST ### Endpoint /api/player/setMetadata ### Parameters #### Request Body - **key** (string | table) - Required - The key or a table of key-value pairs to set. - **value** (any) - Optional - The value to set for the key (only applicable if `key` is a string). ### Request Example (string key) ```json { "key": "deathCount", "value": 5 } ``` ### Request Example (table keys) ```json { "key": { "deathCount": 5, "currentlyDead": false } } ``` ### Response #### Success Response (200) - **metadata** (table) - A table containing the updated metadata. #### Response Example ```json { "metadata": { "deathCount": 5, "currentlyDead": false } } ``` ``` -------------------------------- ### Create New Character Source: https://ndcore.dev/core/server/functions Creates a new player character in the database with the provided information. Requires the player's source ID and a table containing character details such as name, DOB, gender, currency, and more. ```lua NDCore.newCharacter(source, info) ``` ```lua local player = NDCore.newCharacter(source, { firstname = "John", lastname = "Doe", dob = "29/03/1999", gender = "male", cash = 2500, bank = 8000 }) print(player.firstname) -- John ``` -------------------------------- ### Create a New Vehicle Source: https://ndcore.dev/core/server/functions Spawns a new vehicle into the game world. It accepts a table of information including model, coordinates, and ownership details. If 'vehicleId' is omitted, a temporary one is created. ```lua local vehicle = NDCore.createVehicle() ``` ```lua -- works like this: NDCore.createVehicle({ model = `taxi`, coords = vec4(x, y, z, w) }) -- also like this: NDCore.createVehicle({ model = `taxi`, coords = vec3(x, y, z) heading = w }) -- also can add owner that will receive keys. local player = NDCore.getPlayer(source) NDCore.createVehicle({ model = `taxi`, coords = vec4(x, y, z, w), owner = player.id }) -- more key access can be given. local player = NDCore.getPlayer(source) NDCore.createVehicle({ model = `taxi`, coords = vec4(x, y, z, w), keys = { [player.id] = true } }) ``` -------------------------------- ### Player API - setJob Source: https://ndcore.dev/core/server/player Sets the player's job and rank, functioning similarly to addGroup. ```APIDOC ## setJob ### Description Set character job & rank. ### Method `player.setJob(name, rank)` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **name** (string) - Required - The name of the job to set. - **rank** (number) - Required - The rank within the job. ### Request Example ```lua player.setJob('police', 3) ``` ### Response #### Success Response (200) - **group** (table) - Information about the set job, containing player data. #### Response Example ```json { "label": "Police Department", "rankName": "Sergeant", "rank": 3, "isJob": true } ``` ``` -------------------------------- ### Get Closest Player From Coordinates (Lua) Source: https://ndcore.dev/core/client/functions Finds the local player ID of the nearest player from a given set of coordinates. This function is limited to players currently known to the client. It requires a distance and a vector3 coordinate as input. ```lua local closestPlayer = NDCore.getPlayersFromCoords(distance, coords) ``` -------------------------------- ### Job Access Configuration in Lua Source: https://ndcore.dev/addons/characters This Lua configuration demonstrates how to set up job access for character creation based on Discord role IDs. It shows how to assign jobs to specific roles or make them universally available. ```lua jobs = { ["Unemplyed"] = {"0"}, -- everyone can select Uneployed. ["Police"] = { "872921520719142932", -- players with these two discord roles can only select Police. "872921520719142932" } } ``` -------------------------------- ### Configure Inventory Item for NOS Bottle (Lua) Source: https://ndcore.dev/addons/nitro This snippet defines the configuration for a 'nos' inventory item, used by the ND_Nitro resource. It specifies item properties like label, weight, stackability, and client-side usage settings, including use time and export function. ```lua ["nos"] = { label = "NOS Bottle", weight = 2000, stack = false, close = true, client = { disable = { move = true, car = true, combat = true }, usetime = 3500, cancel = true, export = "ND_Nitro.nos" } } ``` -------------------------------- ### Create Dispatch Event for ND_MDT Integration Source: https://ndcore.dev/addons/mdt This Lua code snippet demonstrates how to use the `createDispatch` export function from the ND_MDT resource to send dispatch information to the MDT. It requires caller information and can optionally include location and coordinates for the dispatch. ```lua exports["ND_MDT"]:createDispatch({ caller = "John Doe", location = "Sandy shores", -- not required callDescription = "Whiteness bank robbery", coords = vec3(x, y, z) -- if this is used and location isn't used then it will still display the location from these coords. }) ``` -------------------------------- ### Player API - notify Source: https://ndcore.dev/core/server/player Sends a notification to the player, adapting to the currently used notification script. ```APIDOC ## notify ### Description Notify the player. This function checks for the active notification script. ### Method `player.notify(...)` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **...** (any) - Required - Arguments for the notification, depending on the notification script. ### Request Example ```lua player.notify('Welcome to the server!') ``` ### Response #### Success Response (200) No specific response body defined for this operation. #### Response Example N/A ``` -------------------------------- ### Spawn Point Configuration in Lua Source: https://ndcore.dev/addons/characters This Lua configuration defines various spawn points for characters in the ND_Characters resource. It includes default spawn locations and job-specific spawn points that become available based on the character's job. ```lua spawns = { ["DEFAULT"] = { {label = "Dream View Motel (Paleto Bay)", coords = vec4(-102.78, 6336.28, 31.49, 0)}, {label = "Eastern Motel (Sandy Shores)", coords = vec4(343.53, 2636.94, 43.94, 0)}, {label = "Legion Square", coords = vec4(196.96, -934.54, 29.69, 0)}, {label = "Del Perro Pier", coords = vec4(-1616.69, -1073.81, 12.15, 0)}, {label = "LSIA", coords = vec4(-1039.65, -2741.02, 12.89, 0)} }, ["Police"] = { {label = "Paleto Bay Sheriff", coords = vec4(-447.2, 6009.4, 30.72, 0)}, {label = "Sandy Shores Sheriff", coords = vec4(1849.4, 3688.6, 33.27, 0)}, {label = "Mission Row PD", coords = vec4(437.6, -986.6, 29.69, 0)} } } ``` -------------------------------- ### Revive Player Source: https://ndcore.dev/core/server/player Restores the player to a revived state. This function does not take any parameters. ```lua player.revive() ``` -------------------------------- ### Player Money Management Source: https://ndcore.dev/core/server/player Functions to deduct, add, deposit, and withdraw money from player accounts. ```APIDOC ## POST /api/player/deductMoney ### Description Deduct money from a character's account (`cash` or `bank`). ### Method POST ### Endpoint /api/player/deductMoney ### Parameters #### Request Body - **account** (string) - Required - The account to deduct from (`cash` or `bank`). - **amount** (number) - Required - The amount of money to deduct. - **reason** (string) - Required - The reason for the deduction. ### Request Example ```json { "account": "bank", "amount": 500, "reason": "Parking ticket" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the transaction was successful. #### Response Example ```json { "success": true } ``` ## POST /api/player/addMoney ### Description Add money to a character's account (`cash` or `bank`). ### Method POST ### Endpoint /api/player/addMoney ### Parameters #### Request Body - **account** (string) - Required - The account to add to (`cash` or `bank`). - **amount** (number) - Required - The amount of money to add. - **reason** (string) - Required - The reason for the addition. ### Request Example ```json { "account": "bank", "amount": 1500, "reason": "Daily salary" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the transaction was successful. #### Response Example ```json { "success": true } ``` ## POST /api/player/depositMoney ### Description Moves money from the `cash` account to the `bank` account. ### Method POST ### Endpoint /api/player/depositMoney ### Parameters #### Request Body - **amount** (number) - Required - The amount of money to deposit. ### Request Example ```json { "amount": 20 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the transaction was successful. #### Response Example ```json { "success": true } ``` ## POST /api/player/withdrawMoney ### Description Moves money from the `bank` account to the `cash` account. ### Method POST ### Endpoint /api/player/withdrawMoney ### Parameters #### Request Body - **amount** (number) - Required - The amount of money to withdraw. ### Request Example ```json { "amount": 20 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the transaction was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Player API - drop Source: https://ndcore.dev/core/server/player Kicks a player from the server with a specified reason. ```APIDOC ## drop ### Description Kick a player with a reason message. ### Method `player.drop(reason)` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **reason** (string) - Required - The message to display to the player upon being kicked. ### Request Example ```lua player.drop('You have been disconnected.') ``` ### Response #### Success Response (200) No specific response body defined for this operation. #### Response Example N/A ``` -------------------------------- ### Fetch Character by Identifier Source: https://ndcore.dev/core/server/functions Retrieves a specific character from the database using a unique identifier. Optionally, the player's source can be provided to verify ownership. ```lua local character = NDCore.fetchCharacter(identifier, source) ``` -------------------------------- ### Kick Player with Reason Source: https://ndcore.dev/core/server/player Removes a player from the server with a specified reason message. The 'reason' parameter must be a string. ```lua player.drop(reason) ``` -------------------------------- ### Fetch All Characters for a Player Source: https://ndcore.dev/core/server/functions Retrieves all characters associated with a player's source ID. The returned table is indexed by character IDs and contains character information without player functions. ```lua local characters = NDCore.fetchAllCharacters(source) ``` -------------------------------- ### Create Casino Chips Inventory Item (Lua) Source: https://ndcore.dev/addons/casino This snippet demonstrates how to define a new inventory item for casino chips in Lua, typically used within a game modification context. It specifies the item's internal name and its display label. ```lua ["casino_chips"] = { label = "Chips" } ``` -------------------------------- ### Player API - getJob Source: https://ndcore.dev/core/server/player Retrieves the player's current job and job-related information. ```APIDOC ## getJob ### Description Get the player job and job group. ### Method `player.getJob()` ### Parameters N/A ### Request Example ```lua local player = NDCore.getPlayer(source) local jobName, jobInfo = player.getJob() ``` ### Response #### Success Response (200) - **jobName** (string) - The name of the player's current job. - **jobInfo** (table) - Table containing job details, similar to group information. #### Response Example ```json { "jobName": "police", "jobInfo": { "label": "Police Department", "rankName": "Sergeant", "rank": 3, "isJob": true } } ``` ``` -------------------------------- ### Character Lifecycle Management Source: https://ndcore.dev/core/server/player Functions to delete, unload, and save player characters. ```APIDOC ## DELETE /api/player/delete ### Description Deletes a character completely from the system. ### Method DELETE ### Endpoint /api/player/delete ### Response #### Success Response (200) - **result** (boolean) - Indicates if the deletion was successful. #### Response Example ```json { "result": true } ``` ## POST /api/player/unload ### Description Unloads the currently playing player character. This action saves the character's data, location, and other relevant information. ### Method POST ### Endpoint /api/player/unload ### Response #### Success Response (200) - **saved** (boolean) - Indicates if the character data was successfully saved. #### Response Example ```json { "saved": true } ``` ## POST /api/player/save ### Description Saves the character's data to the database. ### Method POST ### Endpoint /api/player/save ### Response #### Success Response (200) - **saved** (boolean) - Indicates if the data was successfully saved. #### Response Example ```json { "saved": true } ``` ``` -------------------------------- ### Handle Player Money Changes (ND:moneyChange) Source: https://ndcore.dev/core/server/events Listens for changes in a player's account balance. This event is not safe for net and should only be listened to. It provides details about the source, account, amount, action (set, remove, add), and reason for the change. ```lua AddEventHandler("ND:moneyChange", function(source, account, amount, action, reason) end) ``` -------------------------------- ### Player API - revive Source: https://ndcore.dev/core/server/player Revives the player character. ```APIDOC ## revive ### Description Revive the player. ### Method `player.revive()` ### Parameters N/A ### Request Example ```lua player.revive() ``` ### Response #### Success Response (200) No specific response body defined for this operation. #### Response Example N/A ``` -------------------------------- ### Define Police Inventory Items with Lua Source: https://ndcore.dev/addons/police This Lua script defines various items for the police job within the game's inventory system. It specifies item labels, weights, stacking properties, and client-side export functions for actions like using a shield, deploying a spikestrip, cuffing suspects, and hotwiring vehicles. It also includes definitions for bullet casings and projectiles. ```lua ["shield"] = { label = "Police shield", weight = 8000, stack = false, consume = 0, client = { export = "ND_Police.useShield", add = function(total) if total > 0 then pcall(function() return exports["ND_Police"]:hasShield(true) end) end end, remove = function(total) if total < 1 then pcall(function() return exports["ND_Police"]:hasShield(false) end) end end } }, ["spikestrip"] = { label = "Spikestrip", weight = 500, client = { export = "ND_Police.deploySpikestrip" } }, ["cuffs"] = { label = "Handcuffs", weight = 150, client = { export = "ND_Police.cuff" } }, ["zipties"] = { label = "Zipties", weight = 10, client = { export = "ND_Police.ziptie" } }, ["tools"] = { label = "Tools", description = "Can be used to hotwire vehicles.", weight = 800, consume = 1, stack = true, close = true, client = { export = "ND_Core.hotwire", event = "ND_Police:unziptie" } }, ["handcuffkey"] = { label = "Handcuff key", weight = 10, client = { export = "ND_Police.uncuff" } }, ["casing"] = { label = "Bullet Casing" }, ["projectile"] = { label = "Projectile" }, ``` -------------------------------- ### Define MDT Inventory Item in items.lua Source: https://ndcore.dev/addons/mdt This Lua code snippet shows how to define the 'mdt' item within the `items.lua` file for integration with ox_inventory. It specifies the item's label, weight, and a client-side export function `ND_MDT.useTablet` to be called when the item is used. ```lua ["mdt"] = { label = "MDT", weight = 800, client = { export = "ND_MDT.useTablet" } } ```