Framework Integration
This section guides you through the steps to integrate the Advanced Ped Dialog script with your framework, utilizing built-in functions for seamless integration.
Most of the setup should be understandable, but I'll highlight a few things you might need additional help with. By default, the script is set up for ESX + ox_inventory.
Client Functions
Client functions file can be found at configurations/client/CFunctions.lua
.
Inventory
This is designed for convenience, automatically taking item labels from your inventory and using them in buying and selling menus.
fetchItems
- toggler to use this feature.labelVar
- variable name in your inventory system.getAllItems
- function that should return all the registered items in your inventory system.
Items table has to be returned as follows:
This function is called only ONCE when a player first time triggers the menu, all the items are saved in cache. Therefore, retrieving your items from the database or server will not cause any issues, as this function is not repeatedly called.
type GetAllItems = () => ReturnType;
interface ReturnType {
[item_name: string]: {
// This will be your label var, it could also be named differently.
label: string;
// Other item variables. They will not be used, but everything is fine if you don't remove them.
[key: string]: unknown;
}
}
Notifications
Display notifications sent by the script. If you prefer to not show any notifications, you can just leave this function empty.
type Notification = (
message: string,
duration: number, // This will always be 3000
type: 'error' | 'success' // Notification type.
) => void;
Example Configuration
CFunctions = {
inventory = {
fetchItems = true,
labelVar = 'label',
getAllItems = function ()
return exports['ox_inventory']:Items()
end
},
TriggerServerCallback = function(name, cb, ...)
ESX.TriggerServerCallback(name, cb, ...)
end,
Notification = function (message, duration, type)
ESX.ShowNotification(message)
end,
}
Server Functions
Server functions file can be found at configurations/server/SFunctions.lua
.
Everything here should be understandable.
Example Configuration
SFunctions = {
RegisterServerCallback = function(name, cb, ...)
ESX.RegisterServerCallback(name, cb, ...)
end,
HasMoney = function(source, amount, moneyType)
local money = 0;
if not moneyType or moneyType == 'cash' then
money = exports['ox_inventory']:GetItem(source, 'money', false, true)
elseif moneyType == 'black' then
money = exports['ox_inventory']:GetItem(source, 'black_money', false, true)
end
return money >= amount
end,
AddMoney = function(source, amount, moneyType)
if not moneyType or moneyType == 'cash' then
exports['ox_inventory']:AddItem(source, 'money', amount)
elseif moneyType == 'black' then
exports['ox_inventory']:AddItem(source, 'black_money', amount)
end
end,
RemoveMoney = function(source, amount, moneyType)
if not moneyType or moneyType == 'cash' then
exports['ox_inventory']:RemoveItem(source, 'money', amount)
elseif moneyType == 'black' then
exports['ox_inventory']:RemoveItem(source, 'black_money', amount)
end
end,
HasItem = function(source, itemName, amount)
return exports['ox_inventory']:GetItem(source, itemName, false, true) >= amount
end,
CanCarryItem = function (source, itemName, amount)
return exports['ox_inventory']:CanCarryItem(source, itemName, amount)
end,
AddItem = function (source, itemName, amount)
exports['ox_inventory']:AddItem(source, itemName, amount)
end,
RemoveItem = function (source, itemName, amount)
exports['ox_inventory']:RemoveItem(source, itemName, amount)
end
}
Last updated