Page cover image

Item Creation

This page will outline and explain how to create and customize items within the script.

Creating a new item

1

Please navigate to the items file within the resource, which can be found at the following path. settings > items.lua

2

Create a new section

Now that you are in the appropriate location, please proceed to create a new section in your specified category. These categories are purely for organizational purposes. Your resource will not break if you do not follow the categories.

Once you have selected a place to create your new section, please copy and paste the following:

['Example Name'] = {
    itemImage = 'example_image.png',
    takeMultiple = true,

    ---@param count integer
    ---@param itemName string
    ---@param parentId integer
    ---@return boolean
    takeFunction = function(count, itemName, parentId)
        local PROP_HASH = `example_prop_name`

        return object.spooner(PROP_HASH, count, itemName, parentId)
    end,
    ---@param itemName string
    ---@param parentId integer
    ---@return boolean
    returnFunction = function(itemName, parentId)
        return object.store(itemName, parentId)
    end,
},
3

Naming your item

You now have a new section or item that requires a unique name. The name of the item is determined by the string you input into the starting square brackets. By default, this will be set to 'Example Name.'

['My Item'] = {}
4

Assigning an icon to your item

You must now assign an icon to your item. This icon should accurately reflect the name and purpose of the item itself. You can assign an icon by inputting a string into the itemImagevariable. This string must correspond to a valid image located within the settings > icons folder. Please ensure that the string also includes the appropriate file extension, such as .png or .jpg.

itemImage = 'image.png',
5

Creating a take function for your item

Each item necessitates a take function. The content of this function will be executed when you collect the item from a vehicle's boot. This function can include any logic, provided that it returns a boolean value indicating whether the action was successful or not.

By default, z_boot offers four types of item functions, which are designed for object spawning, clothing management, weapon management, and command execution. Further details regarding these functions can be found later on this page.

The rationale behind enabling server owners to customize their functions is to facilitate the incorporation of their own custom functions and to ensure seamless integration with other resources.

Provided below is the template for the take function

---@param count integer
---@param itemName string
---@param parentId integer
---@return boolean
takeFunction = function(count, itemName, parentId)
    return true
end
6

Creating a return function for your item

Just as each item requires a take function, they also necessitate a return function. This function manages the action of placing an item back into a vehicle inventory. It can implement any logic, provided it returns a boolean value indicating whether the action was successful. By default z_boot offers various default examples of this function, which will be explained further later in this document.

Provided below is the template for the return function

---@param itemName string
---@param parentId integer
---@return boolean
returnFunction = function(itemName, parentId)
    return true
end

Default item functionality

Each item requires you to create its unique functionality, z_boot offer multipe default functionalities you can easily copy and paste and made addition too without requiring knowledge of coding, These are all below and are explained.

Command Execution is one of the most straightforward functionalities available. This feature allows a command to be triggered by the resource, which doesnt require user input via chat. For instance, if you have a command that provides the player with spiketrips, you can execute this command using this functionality.

Please be aware that you do not need to use a /to initiate the command; you only need to enter the command name itself.

---@return boolean
takeFunction = function()
    local isSuccess = true
        ExecuteCommand('YOUR_COMMAND')
    return isSuccess
end,
---@return boolean
returnFunction = function()
    local isSuccess = true
        ExecuteCommand('YOUR_COMMAND')
    return isSuccess
end

Last updated