API
For advanced users and developers who wish to integrate the script with an inventory or interaction system not listed in the default configuration, you can edit the open_api.lua
files located in the client/
and server/
folders.
These files act as a bridge or an API layer between this resource and other scripts. By modifying them, you can add support for any custom framework, making this script universally compatible.
Client
This section details the functions available in the client/open_api.lua
file.
OnStartThrowing
- Description: Handles the setup process when the player begins throwing an item. It closes the inventory, sets the player's state as busy (
invBusy
), and prevents them from using weapons to ensure the throwing animation plays without interruption.
OnStopThrowing
- Description: Manages the cleanup process after the player has finished throwing an item. It resets the player's state by clearing the invBusy flag and re-enabling weapon usage, returning them to a normal state.
ShowTextUI
- Description: Displays a text UI element on the screen. This function acts as a wrapper for the configured UI library.
- Parameters:
text
(string): The text content to be displayed.
HideTextUI
- Description: Hides the text UI element that was previously shown by
ShowTextUI
.
AddPickupInteraction
- Description: Creates a pickup interaction point in the world for a dropped item. This function's behavior is dynamically determined by the
Config.pickupType
value defined inconfig.lua
, calling the appropriate export for the selected targeting system. - Parameters:
identifier
(string): A unique identifier for the interaction.coords
(vector3): The world coordinates where the interaction should be created.label
(string): The display name of the item (e.g., "Phone").count
(integer): The quantity of the item (e.g., 3).
- Returns:
- (
any
ornil
): Returns the zone/interaction ID created by the target script, which can be used later to remove it. Returnsnil
if theConfig.pickupType
is not handled by this function (e.g.,ox_inventory_drop
).
- (
RemovePickupInteraction
- Description: Removes a previously created pickup interaction from the world. This function's behavior is also determined by
Config.pickupType
. - Parameters:
identifier
(any): The unique identifier of the interaction to remove, which was previously returned byAddPickupInteraction
.
Server
This section details the functions available in the server/open_api.lua
file.
GetItemConfig
- Description: Retrieves basic configuration data for a given item.
- Parameters:
name
(string): The unique name of the item (e.g.,phone
).
- Returns:
table
: A table containing the item'slabel
.
RemoveItem
- Description: Removes a full stack of an item from a specific inventory slot. It first validates that the item in the given slot is the correct one before attempting removal.
- Parameters:
source
(integer): The server ID of the player.name
(string): The expected name of the item in the slot.slot
(integer): The inventory slot number to remove the item from.
- Returns:
success
(boolean):true
if the item was removed,false
otherwise.itemData
(table): A table with details of the removed item (name, count, weight, metadata) if successful.
CanCarryItem
- Description: Checks if a player has enough free inventory space to carry an additional weight. If the player cannot carry the weight, it sends them an error notification.
- Parameters:
source
(integer): The server ID of the player.weight
(number): The additional weight to check.
- Returns:
canCarry
(boolean):true
if the player can carry the weight,false
otherwise.
AddItem
- Description: Adds a specified item to a player's inventory. If the action fails, it sends an error notification to the player with the reason.
- Parameters:
source
(integer): The server ID of the player.name
(string): The name of the item to add.count
(integer): The quantity of the item to add.metadata
(table): Metadata to associate with the item.
- Returns:
success
(boolean):true
if the item was added successfully,false
otherwise.