Basic Configuration
This section covers how to configure the basic settings of the Advanced Ped Dialog script. By changing config.lua file.
UseInteraction
true/false
You need to decide whether you will use interactions. If you don't need text over the ped's head and don't plan to use key interactions, set this to false
. This way, the script will not start the checking thread, avoiding unnecessary position checks in your situation.
InteractionKey
number
Key to open ped dialog when you use key interaction to open it. You can find all key codes here.
PlayerInvisibleWhileInDialog
boolean
To make a player invisible locally while dialog is open set it to true
. (Other players can still see the player)
UIData
table
UI Configurations
imagePath
- the path to your images is designed to save file space by avoiding image duplication. You can load images from your inventory resources or your hosted CDN image storage. If you prefer to copy the images you want to use, replace this with./images/
and upload your item images to theweb/images/
directory.defaultImageExtension
- the default extension for your images. Don't worry if some of your images are .jpg or other formats; you can still configure this when creating selling or buying menus.moneyFormat
- how you want your server currency to be displayed for the players.moneyColors
- you can specify different font colors for different currencies of your server.
PedCam
table
Default camera settings for the ped. These settings will be used if specific camera settings are not defined for the created ped.
offset
- offset calculated from the ped position.fov
- camera FOVpointZOffset
- Z offset ofPointCamAtEntity
Draw3dText
function (text: string, coords: Vector3)
A function to display text over head.
Keep in mind that this function is called every frame don't add any heavy logic here.
Config.Draw3dText = function (text, coords)
BeginTextCommandDisplayHelp("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayHelp(2, false, false, 0)
SetFloatingHelpTextStyle(1, 1, 2, 191, 3, 0)
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z + 1.0)
end
Locales
This one should be easy to understand. The script uses string formatting, and the comments explain what each %s
in the format represents.
To use different messaged for different moneyType
, you can build locale like so:
['not_enough_${moneyType}']
= "Some message of money %s some item"
Default config
Config = {}
Config.UseInteraction = true
Config.InteractionKey = 38 -- E
Config.PlayerInvisibleWhileInDialog = true
Config.UIData = {
imagePath = 'https://cfx-nui-ox_inventory/web/images/',
defaultImageExtension = 'png',
moneyFormat = '${price}',
moneyColors = {
cash = '#FFFFFF',
black = '#FF0000'
}
}
Config.PedCam = {
offset = {
x = 0.0,
y = 2.0,
z = 1.0
},
fov = 50.0,
pointZOffset = 0.0
}
Config.Draw3dText = function (text, coords)
BeginTextCommandDisplayHelp("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayHelp(2, false, false, 0)
SetFloatingHelpTextStyle(1, 1, 2, 191, 3, 0)
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z + 1.0)
end
Locales = {
['ui_sell'] = 'Sell',
['ui_buy'] = 'Buy',
-- ped name / ped group
['ped_over_head'] = '%s [~b~%s~w~]',
-- ped name
['interact_ped_over_head'] = 'Press ~INPUT_CONTEXT~to interact with ~g~%s~w~',
-- item name (default error message for not enough money)
['not_enough_money'] = "You don't have enough money to buy ~b~%s",
-- Different error messages for different money types, this is formated as `not_enough_${moneyType}`
['not_enough_cash'] = "You don't have enough cash to buy ~b~%s",
['not_enough_black'] = "You don't have enough black money to buy ~b~%s",
--
['not_enough_space_in_inventory'] = "You don't have enough space in your inventory",
-- item count / item name
['not_enough_item_to_sell'] = "You don't have ~g~%sx~s~ of ~b~%s",
-- item count / item item / total price
['bought_item'] = 'You bought ~g~%s~w~x ~b~%s~w~ for ~g~$%s',
-- item count / item name / total price
['sold_item'] = 'You sold ~g~%s~w~x ~b~%s~w~ for ~g~$%s',
-- For those who are using custom fonts
['blip_text_component_string'] = '%s',
}
Last updated