# xakra\_carts

## Requirements

* [oxmysql](https://github.com/overextended/oxmysql)
* [vorp\_menu](https://github.com/VORPCORE/vorp_menu)
* [vorp\_core](https://github.com/VORPCORE/vorp-core-lua)
* [vorp\_inventory](https://github.com/VORPCORE/vorp_inventory-v2)
* vorp\_stables | syn\_stables | xakra\_stables | gum\_stables | SS-Stable

***

## Installation

1. Copy the script into a folder (to choose) from the 'resources' folder.
2. Add 'ensure xakra\_carts' in the 'Resources.cfg' document
3. Check the config.lua file and configure to adapt the script.
4. Execute the queries in the database of the sql/columns.sql file, depending on the stable you have and change the option Config.SQL from the file 'config.lua'
5. You have to set Config.RadiusApplyMods to the same cart spawn radius as your stable script.

***

## Config & Framework

<details open>

<summary>config.lua</summary>

{% code expandable="true" %}

```lua
Config = {}

Config.defaultlang = 'en'

Config.Webhook = '' -- WEBHOOK VORP

Config.SQL = 'xakra_stables' -- 'xakra_stables', 'vorp_stables', 'syn_stable', 'gum_stables', 'kd_stables', 'SS-Stable'

Config.Align = 'top-left' -- Menu position

Config.KeyLoadoutCart = 0x620A6C5E	-- V
Config.KeyLightsCart = 0x760A9C6F	-- G
Config.KeyCleanCart = 0x018C47CF	-- E
Config.KeyCallCart = 0xF3830D8E -- Key used to call the cart, in default is J or false
Config.KeyDeleteCart = 0x760A9C6F -- G
Config.SeatCart = 0xA1ABB953 -- G
Config.RadiusApplyMods = 100.0 -- Radius to apply mods when call the cart by pressing J

Config.KeyOpenMenu = 0x5415BE48 -- Key to open the menu

Config.FloorMarkColor = { r = 0, g = 128, b = 0, alpha = 30 } -- RGB color of the floor mark (min 0, max 255)

Config.VisibleCart = true	-- This option will allow all players to see the car or only the person who opens the menu

Config.ColorBlips = 'green'    -- Choose the color of the blips ['yellow', 'white', 'green', 'blue', 'red', 'purple', 'orange', 'pink', 'grey']

Config.Workshops = { -- ADD NEW WORSHOP
	{
		name = 'Wagon Workshop', -- Name for blip
		blip = { enable = true, sprite = 'blip_shop_trainer' },	-- enable/disable blip, and hash blip
		pos = vector3(-252.49, 632.97, 113.45), -- Position workshop
		posSpawn = vector4(-256.96, 634.89, 113.47, 139.82), -- Coords X,Y,Z and H for spawn cart
        -- stable = 1, -- Option used in sql query, to establish in which stable the cart is created
        -- stable2 = 1, -- Option used in sql query, to establish in which stable the cart is created
		jobs = {	-- Job list, remove or set to false for all players to access
			{ job = 'workshopcart', grade = 1 },
			-- { job = 'example', grade = false },
		},
        DisableWalk = false, -- Disable walk-to-cart interaction to make the animation when crafting a car, it will make the animation in the menu location
	},

    {
		name = 'Wagon Workshop', -- Name for blip
		blip = { enable = true, sprite = 'blip_shop_trainer' },	-- enable/disable blip, and hash blip
        pos = vector3(2935.58, 560.82, 45.0), -- Position workshop
        posSpawn = vector4(2933.06, 560.11, 44.71, -12.0), -- Coords X,Y,Z and H for spawn cart
        -- stable = 1, -- Option used in sql query, to establish in which stable the cart is created
        -- stable2 = 1, -- Option used in sql query, to establish in which stable the cart is created
		jobs = {	-- Job list, remove or set to false for all players to access
			{ job = 'workshopcart', grade = false },
			-- { job = 'example', grade = false },
		},
        DisableWalk = false, -- Disable walk-to-cart interaction to make the animation when crafting a car, it will make the animation in the menu location
    },

	{
		name = 'Wagon Workshop', -- Name for blip
		blip = { enable = true, sprite = 'blip_shop_trainer' },	-- enable/disable blip, and hash blip
     	pos = vector3(2833.44, -1052.65, 43.92), -- Position workshop
     	posSpawn = vector4(2838.93, -1048.44, 43.77, 90.47), -- Coords X,Y,Z and H for spawn cart
        -- stable = 1, -- Option used in sql query, to establish in which stable the cart is created
        -- stable2 = 1, -- Option used in sql query, to establish in which stable the cart is created
		jobs = {	-- Job list, remove or set to false for all players to access
			{ job = 'workshopcart', grade = false },
			-- { job = 'example', grade = false },
		},
        DisableWalk = false, -- Disable walk-to-cart interaction to make the animation when crafting a car, it will make the animation in the menu location
    },

	{
		name = 'Wagon Workshop', -- Name for blip
		blip = { enable = true, sprite = 'blip_shop_trainer' },	-- enable/disable blip, and hash blip
    	pos = vector3(-867.33, -1286.82, 43.15), -- Position workshop
    	posSpawn = vector4(-871.85, -1289.15, 43.15, 270.5), -- Coords X,Y,Z and H for spawn cart
        -- stable = 1, -- Option used in sql query, to establish in which stable the cart is created
        -- stable2 = 1, -- Option used in sql query, to establish in which stable the cart is created
		jobs = {	-- Job list, remove or set to false for all players to access
			{ job = 'workshopcart', grade = false },
			-- { job = 'example', grade = false },
		},
        DisableWalk = false, -- Disable walk-to-cart interaction to make the animation when crafting a car, it will make the animation in the menu location
    },

	{
		name = 'Wagon Workshop', -- Name for blip
		blip = { enable = true, sprite = 'blip_shop_trainer' },	-- enable/disable blip, and hash blip
    	pos = vector3(-5515.59,-3040.36,-2.18), -- Position workshop
    	posSpawn = vector4(-5520.34, -3044.49, -2.18, 91.52), -- Coords X,Y,Z and H for spawn cart
        -- stable = 1, -- Option used in sql query, to establish in which stable the cart is created
        -- stable2 = 1, -- Option used in sql query, to establish in which stable the cart is created
		jobs = {	-- Job list, remove or set to false for all players to access
			{ job = 'workshopcart', grade = 1 },
			-- { job = 'example', grade = false },
		},
        DisableWalk = false, -- Disable walk-to-cart interaction to make the animation when crafting a car, it will make the animation in the menu location
    },
}

Config.Max = {
    Carts = 1,  -- number (Maximum number of cars without jobs)
    Jobs = {    -- List of jobs and maximum number of carts
        { Job = 'workshopcart', Carts = 3 },
        -- { Job = 'example', Carts = 5 },
    },
}

Config.CartInitialCustom = true -- true or false (Choose whether unpersonalized carts will always appear with the same appearance when called)

Config.Custom = { -- List of items required for each mod
    Tints = { -- TINT
        Currency = {
            label = '$',
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 20,
        },
        Items = {
            { label = 'Hard Wood', item = 'hwood', amount = 2 },
            -- { label = 'Example 1', item = 'iron', amount = 5 },
            -- { label = 'Example 2', item = 'wood', amount = 10 },
        },
	},
	Extras = { -- EXTRAS
        Currency = {
            label = '$',
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 30,
        },
        Items = {
            { label = 'Soft Wood', item = 'wood', amount = 1 },
            -- { label = 'Example 1', item = 'iron', amount = 5 },
            -- { label = 'Example 2', item = 'wood', amount = 10 },
        },
	},
	Liveries = { -- LIVERIES
        Currency = {
            label = '$',
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 10,
        },
        Items = {
            { label = 'Hard Wood', item = 'hwood', amount = 1 },
            -- { label = 'Example 1', item = 'iron', amount = 5 },
            -- { label = 'Example 2', item = 'wood', amount = 10 },
        },
	},
	LanternPropsets = { -- LANTERN PROPSETS
        Currency = {
            label = '$',
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 35,
        },
        Items = {
            { label = 'Soft Wood', item = 'wood', amount = 3 },
            { label = 'Iron Ore', item = 'iron', amount = 1 },
            -- { label = 'Example 1', item = 'iron', amount = 5 },
            -- { label = 'Example 2', item = 'wood', amount = 10 },
        },
	},
	Propsets = { -- PROPSETS
        Currency = {
            label = '$',
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 35,
        },
        Items = {
            { label = 'Soft Wood', item = 'wood', amount = 2 },
            { label = 'Hard Wood', item = 'hwood', amount = 1 },
            -- { label = 'Example 1', item = 'iron', amount = 5 },
            -- { label = 'Example 2', item = 'wood', amount = 10 },
        },
	},
}

Config.CartCrafts = { -- List of items required for create cart
	['small'] = {
		name = 'Carros pequeños', -- List menu button string
        currency = {
            type = 1,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = false,   -- number (currency required to craft) or false (no currency required)
            label = '$',    -- notification text
        },
		craft = { -- Items List
			{ item = 'wood', amount = 1, label = 'Soft Wood'},
			{ item = 'iron', amount = 1, label = 'Iron Ore' },
		},
        -- jobs = {	-- Job list, remove or set to false for all players to access
		-- 	{ job = 'workshopcart', grade = false },
		-- 	-- { job = 'example', grade = false },
		-- },
	},
	['medium'] = {
		name = 'Carros medianos', -- List menu button string
        currency = {
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 50,   -- number (currency required to craft) or false (no currency required)
            label = '$',    -- notification text
        },
		craft = { -- Items List
			{ item = 'hwood', amount = 2, label = 'Soft Wood' },
            { item = 'iron', amount = 2, label = 'Iron Ore' },
		},
        -- jobs = {	-- Job list, remove or set to false for all players to access
		-- 	{ job = 'workshopcart', grade = false },
		-- 	-- { job = 'example', grade = false },
		-- },
	},
	['large'] = {
		name = 'Carros grandes', -- List menu button string
        currency = {
            type = 0,   -- 0 = money, 1 = gold, 2 = rol
            typec = 'money',   -- 'money', 'gold', or 'rol'
            amount = 150,   -- number (currency required to craft) or false (no currency required)
            label = '$',    -- notification text
        },
		craft = { -- Items List
			{ item = 'wood', amount = 3, label = 'Soft Wood' },
            { item = 'hwood', amount = 3, label = 'Soft Wood' },
			{ item = 'iron', amount = 3, label = 'Iron Ore' },
		},
        -- jobs = {	-- Job list, remove or set to false for all players to access
		-- 	{ job = 'workshopcart', grade = false },
		-- 	-- { job = 'example', grade = false },
		-- },
	},
}

-- LIST OF VEHICLES TO CRAFT (YOU CAN ADD OR REMOVE) [hash = {'mode_name,'size'}]
Config.CartsCraft = {
    -- { 
    --     name = 'Example',   -- Name of the cart in the menu
    --     model = 'example',  -- Cart model
    --     category = 'example',   -- Config.CartCrafts assigned category
    --     InvCapacity = 0,    -- Inventory capacity of the cart (Visual only, should match what you have in your stable script)
    --     jobs = {	-- Job list, remove or set to false for all players to access
	-- 		{ job = 'example1', grade = false },
	-- 		{ job = 'example2', grade = false },
	-- 	},
    -- },

    { name = 'Army Supply Wagon', model = 'ArmySupplyWagon', category = 'large', InvCapacity = 750 },
    { name = 'Bounty Wagon', model = 'bountywagon01x', category = 'large', InvCapacity = 750}, 
    { name = 'Buggy 1', model = 'buggy01', category = 'small', InvCapacity = 50 },
    { name = 'Buggy 2', model = 'buggy02', category = 'small', InvCapacity = 50 },
    { name = 'Buggy 3', model = 'buggy03', category = 'small', InvCapacity = 50 },
    { name = 'Cart 1', model = 'cart01', category = 'small', InvCapacity = 50 },  
    { name = 'Cart 2', model = 'cart02', category = 'small', InvCapacity = 50 },  
    { name = 'Cart 3', model = 'cart03', category = 'medium', InvCapacity = 125 }, 
    { name = 'Cart 4', model = 'cart04', category = 'medium', InvCapacity = 125 }, 
    { name = 'Cart 5', model = 'cart05', category = 'small', InvCapacity = 50 },  
    { name = 'Cart 6', model = 'cart06', category = 'large', InvCapacity = 300 },  
    { name = 'Cart 7', model = 'cart07', category = 'medium', InvCapacity = 125 }, 
    { name = 'Cart 8', model = 'cart08', category = 'medium', InvCapacity = 125 },
    { name = 'Chuck Wagon 1', model = 'chuckwagon000x', category = 'large', InvCapacity = 750 }, 
    { name = 'Chuck Wagon 2', model = 'chuckwagon002x', category = 'large', InvCapacity = 750 }, 
    { name = 'Coach 1', model = 'coach2', category = 'large', InvCapacity = 300 },         
    { name = 'Coach 2', model = 'coach3_cutscene', category = 'large', InvCapacity = 300 },
    { name = 'Coach 3', model = 'coach3', category = 'large', InvCapacity = 300 },
    { name = 'Coach 4', model = 'coach4', category = 'medium', InvCapacity = 125 },
    { name = 'Coach 5', model = 'coach5', category = 'medium', InvCapacity = 125 },
    { name = 'Coach 6', model = 'coach6', category = 'medium', InvCapacity = 125 },
    { name = 'Coal Wagon', model = 'coal_wagon', category = 'medium', InvCapacity = 125 },
    { name = 'Gatchuck', model = 'gatchuck', category = 'large', InvCapacity = 750 },
    { name = 'Hunter Cart', model = 'huntercart01', category = 'large', InvCapacity = 300 },
	{ name = 'Log Wagon', model = 'logwagon', category = 'medium', InvCapacity = 125 },
    { name = 'Oil Wagon 1', model = 'oilWagon01x', category = 'large', InvCapacity = 300 },    
    { name = 'Oil Wagon 2', model = 'oilWagon02x', category = 'large', InvCapacity = 300 },    
    { name = 'Police Wagon', model = 'policewagon01x', category = 'large', InvCapacity = 300 }, 

    -- { name = 'Police Wagon Gatlin', model = 'policeWagongatling01x','large', InvCapacity = 300, jobs = { { job = 'police', grade = false }, { job = 'example', grade = false }, }, },
	-- { name = 'Gatchuck 2', model = 'gatchuck_2','large', InvCapacity = 300, jobs = { { job = 'police', grade = false }, { job = 'example', grade = false }, }, }, 

    { name = 'Stage Coach 1', model = 'stagecoach001x', category = 'large', InvCapacity = 300 }, 
    { name = 'Stage Coach 2', model = 'stagecoach002x', category = 'large', InvCapacity = 300 }, 
    { name = 'Stage Coach 3', model = 'stagecoach003x', category = 'large', InvCapacity = 300 }, 
    { name = 'Stage Coach 4', model = 'stagecoach004_2x', category = 'large', InvCapacity = 300 },
    { name = 'Stage Coach 5', model = 'stagecoach004x', category = 'large', InvCapacity = 300 }, 
    { name = 'Stage Coach 6', model = 'stagecoach005x', category = 'large', InvCapacity = 300 }, 
    { name = 'Stage Coach 7', model = 'stagecoach006x', category = 'large', InvCapacity = 300 }, 
    { name = 'Supply Wagon', model = 'supplywagon', category = 'large', InvCapacity = 750 },    
    { name = 'Utilli Wag', model = 'utilliwag', category = 'medium', InvCapacity = 125 },   
    { name = 'Wagon 1', model = 'wagon02x', category = 'large', InvCapacity = 750 },       
    { name = 'Wagon 2', model = 'wagon03x', category = 'large', InvCapacity = 300 },       
    { name = 'Wagon 3', model = 'wagon04x', category = 'large', InvCapacity = 750 },       
    { name = 'Wagon 4', model = 'wagon05x', category = 'large', InvCapacity = 750 },       
    { name = 'Wagon 5', model = 'wagon06x', category = 'medium', InvCapacity = 125 },    
    { name = 'Wagon Armoured', model = 'wagonarmoured01x', category = 'large', InvCapacity = 750 },
    { name = 'Wagon Circus 1', model = 'wagonCircus01x', category = 'large', InvCapacity = 300 }, 
    { name = 'Wagon Circus 2', model = 'wagonCircus02x', category = 'large', InvCapacity = 300 }, 
    { name = 'Wagon Dairy', model = 'wagondairy01x', category = 'medium', InvCapacity = 125 }, 
    { name = 'Wagon Doc', model = 'wagondoc01x', category = 'large', InvCapacity = 300 },    
    { name = 'Wagon Prison', model = 'wagonPrison01x', category = 'large', InvCapacity = 300 },            
    { name = 'Wagon Traveller', model = 'wagontraveller01x', category = 'medium', InvCapacity = 125 },
    { name = 'Wagon Work', model = 'wagonwork01x', category = 'medium', InvCapacity = 125 },

    -- { name = 'War Wagon', model = 'warwagon2', category = 'large', InvCapacity = 100 },
}

Config.Minigame = {
    Difficulty = 'easy', -- 'easy', 'normal' and 'difficult'
    Colors = {
        BackgroundBar = { r = 25, g = 25, b = 25 },
        Bar = { r = 255, g = 255, b = 255 },
        Image = { r = 255, g = 255, b = 255 },
    },
}

Config.ItemsRepairCart = { -- List of items to repair the cart
	{
        label = 'Kit de herramietas',   -- Label of the item that will be shown in notifications
        item = 'test1',  -- Name of the item in the database
        uses = false, -- number (Number of uses each item) or false (never consumed)
        jobs = false,   -- job list or false
    },
    {
        label = 'Martillo', -- Label of the item that will be shown in notifications
        item = 'hammer',    -- Name of the item in the database
        uses = 1, -- number (Number of uses each item) or false (never consumed)
        jobs = {    -- job list or false
            { job = 'workshopcart', grade = false },
            -- { job = 'example', grade = false },
        },
    },
}

Config.ItemsCleanCart = {   -- List of items to clean carts
	{
        label = 'Trapo',    -- -- Label of the item that will be shown in notifications
        item = 'rag',   -- Name of the item in the database
        uses = 1, -- number (Number of uses each item) or false (never consumed)
        jobs = false,   -- job list or false
    },
    -- {
    --     label = 'Trapo', -- -- Label of the item that will be shown in notifications
    --     item = 'rag',    -- Name of the item in the database
    --     uses = 1, -- number (Number of uses each item) or false (never consumed)
    --     jobs = {    -- job list or false
    --         { job = 'workshopcart', grade = false },
    --         -- { job = 'example', grade = false },
    --     },
    -- },
}

Config.SystemHealth = true -- Enable (true) or disable (false) the cart health system

Config.Stamina = {
    HudPosition = { x = 0.16, y = 0.95 },
    RechargeMultiplier = 1.0, -- Multiplies the base stamina recharge rate (1.0 = default)
    DrainMultiplier = 1.0     -- Multiplies the base stamina drain while sprinting (1.0 = default)
}

Config.Carts = {
    -- LoadoutCapacity = number (npcs and skins to the carts) or false
    -- Health = number or false
    -- Stamina = number or false

    ArmySupplyWagon = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    bountywagon01x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    buggy01 = { LoadoutCapacity = 3, Health = 1500, Stamina = 50 },
    buggy02 = { LoadoutCapacity = 3, Health = 1500, Stamina = 50 },
    buggy03 = { LoadoutCapacity = 3, Health = 1500, Stamina = 50 },
    cart01 = { LoadoutCapacity = 3, Health = 1500, Stamina = 50 },
    cart02 = { LoadoutCapacity = 3, Health = 1500, Stamina = 50 },
    cart03 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    cart04 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    cart05 = { LoadoutCapacity = 3, Health = 1500, Stamina = 50 },
    cart06 = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    cart07 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    cart08 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    chuckwagon000x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    chuckwagon002x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    coach2 = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    coach3_cutscene = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    coach3 = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    coach4 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    coach5 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    coach6 = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    coal_wagon = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    gatchuck = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    huntercart01 = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    logwagon = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    oilWagon01x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    oilWagon02x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    policewagon01x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    policeWagongatling01x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    gatchuck_2 = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach001x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach002x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach003x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach004_2x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach004x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach005x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    stagecoach006x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    supplywagon = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    utilliwag = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    wagon02x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    wagon03x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    wagon04x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    wagon05x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    wagon06x = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    wagonarmoured01x = { LoadoutCapacity = 15, Health = 5000, Stamina = 120 },
    wagonCircus01x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    wagonCircus02x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    wagondairy01x = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    wagondoc01x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    wagonPrison01x = { LoadoutCapacity = 7, Health = 2833, Stamina = 90 },
    wagontraveller01x = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    wagonwork01x = { LoadoutCapacity = 5, Health = 2166, Stamina = 70 },
    warwagon2 = { LoadoutCapacity = 8, Health = 3166 },
    hotAirBalloon01 = { LoadoutCapacity = 7, Health = 2833 },
}
```

{% endcode %}

</details>

<details open>

<summary>framework</summary>

client.lua

{% code expandable="true" %}

```lua
TriggerEvent("getCore", function(core)
    VORPcore = core
end)

TriggerEvent("vorp_menu:getData", function(call)
    MenuData = call
end)

function NotifyTip(text, time)
    VORPcore.NotifyTip(text, time)
end

function NotifyObjective(text, time)
    VORPcore.NotifyObjective(text, time)
end

InventoryImg = 'vorp_inventory/html/img/items/'

-- Function used by your stable script, so that xakra_carts finds the cart without using the call key
-- RegisterNetEvent('example')
-- AddEventHandler('example', function(id)
--     TriggerServerEvent('xakra_carts:ActiveCartId', false, id) -- xakra_carts server event to detect the cart
-- end)
```

{% endcode %}

server.lua

{% code expandable="true" %}

```lua
TriggerEvent("getCore", function(core)
    VORPcore = core
end)

local VORPInv = exports.vorp_inventory:vorp_inventoryApi()

function NotifyTip(source, text, time)
    VORPcore.NotifyTip(source, text, time)
end

function NotifyObjective(source, text, time)
    VORPcore.NotifyObjective(source, text, time)
end

function NotifyAvanced(source, title, dict, icon, color, time)
    VORPcore.NotifyAvanced(source, title, dict, icon, color, time)
end

function GetCharacter(source)
    -- .job
    -- .jobGrade
    -- .identifier
    -- .charIdentifier
    -- .money
    return VORPcore.getUser(source).getUsedCharacter
end

function removeCurrency(source, currency, amount)
    local Character = GetCharacter(source)
    Character.removeCurrency(currency, amount) -- Remove money 1000 | 0 = money, 1 = gold, 2 = rol
end

function RegisterUsableItem(item, cb)
    VORPInv.RegisterUsableItem(item, function(data)
        -- .source
        -- .item.mainid
        return cb(data)
    end)
end

function getItemCount(source, item, metadata)
    return VORPInv.getItemCount(source, item, metadata)
end

function subItem(source, item, amount)
    VORPInv.subItem(source, item, amount)
end

function CloseInv(source)
    VORPInv.CloseInv(source)
end

function AddWebhook(title, webhook, description, color, name, logo, footerlogo, avatar)
    VORPcore.AddWebhook(title, webhook, description, color, name, logo, footerlogo, avatar)
end

-- FOR ITEM USES MORE THAN 1
function getItemByMainId(source, mainid, callback)
    return exports.vorp_inventory:getItemByMainId(source, mainid, callback)
end

function getItemDB(item, callback)
    return exports.vorp_inventory:getItemDB(item, callback)
end

function subItemID(source, id, callback)
    exports.vorp_inventory:subItemID(source, id, callback)
end

function setItemMetadata(source, itemId, metadata, amount, callback)
    exports.vorp_inventory:setItemMetadata(source, itemId, metadata, amount, callback)
end
--

-- Function used by your stable script, so that xakra_carts finds the cart without using the call key "TriggerEvent('xakra_carts:ActiveCartId', source, id)"
-- source or nil (source player id or nil on client side)
-- id (Cart ID in the database table)

-- RegisterServerEvent('example')
-- AddEventHandler('example', function(id)
--     local _source = source
--     TriggerEvent('xakra_carts:ActiveCartId', _source, id) -- xakra_carts server event to detect the cart
-- end)
```

{% endcode %}

shared.lua

{% code expandable="true" %}

```lua
SQL = {
    Columns = {
        Id = 'id',
        Model = 'model',
        Comps = 'comps',
        Health = 'health',
        Loadouts = 'loadouts',
    },
    ListComps = {   -- Cart comp list option names (SQL.Columns.Comps if not a table)
        tint = 'Tint',
        extra = 'Extra',
        liverie = 'Livery',
        lantern_propsets = 'LanternPropset',
        propsets = 'Propset',
    },
    Select = 'SELECT * FROM wagons WHERE identifier = @identifier AND charid = @charid;',
    Update = 'UPDATE wagons SET comps = @mods_encode WHERE identifier = @identifier AND charid = @charid AND id = @id;',
    Insert = 'INSERT INTO wagons (identifier, charid, selected, model, name, health) VALUES (@identifier, @charid, 0, @model, @name, @health);',
    -- Insert = function(Source, Name, Model, Health, stable, stable2)
        -- code new wagon
    -- end,
    Selected = 'SELECT * FROM wagons WHERE identifier = @identifier AND charid = @charid AND selected = 1;',
    SelectedId = 'SELECT * FROM wagons WHERE identifier = @identifier AND charid = @charid AND id = @id;',  -- SELECT using in the event xakra_carts:ActiveCartId
    Health = 'UPDATE wagons SET health = @health WHERE identifier = @identifier AND charid = @charid AND id = @id;',
    Loadouts = 'UPDATE wagons SET loadouts = @loadouts WHERE identifier = @identifier AND charid = @charid AND id = @id;',
}

if Config.SQL == 'syn_stable' then
    SQL.ListComps = {
        tint = 'tint',
        extra = 'extra',
        liverie = 'liverie',
        lantern_propsets = 'lantern_propsets',
        propsets = 'propsets',
    }

elseif Config.SQL == 'vorp_stables' then
    SQL = {
        Columns = {
            Id = 'id',
            Model = 'modelname',
            Comps = 'gear',
            Health = 'health',
            Loadouts = 'loadouts',
        },
        ListComps = {   -- Cart comp list option names (SQL.Columns.Comps if not a table)
            tint = 'tint',
            extra = 'extra',
            liverie = 'liverie',
            lantern_propsets = 'lantern_propsets',
            propsets = 'propsets',
        },
        Select = 'SELECT * FROM stables WHERE type = "cart" and identifier = @identifier AND charidentifier = @charid;',
        Update = 'UPDATE stables SET gear = @mods_encode WHERE identifier = @identifier AND charidentifier = @charid AND id = @id;',
        Insert = 'INSERT INTO stables (identifier, charidentifier, name, modelname, type, isDefault, health) VALUES (@identifier, @charid, @name, @model, "cart", 0, @health);',
        Selected = 'SELECT * FROM stables WHERE type = "cart" AND identifier = @identifier AND charidentifier = @charid AND isDefault = 1;',
        SelectedId = 'SELECT * FROM stables WHERE type = "cart" AND identifier = @identifier AND charidentifier = @charid AND id = @id;',   -- SELECT using in the event xakra_carts:ActiveCartId
        Health = 'UPDATE stables SET health = @health WHERE identifier = @identifier AND charidentifier = @charid AND id = @id;',
        Loadouts = 'UPDATE stables SET loadouts = @loadouts WHERE identifier = @identifier AND charidentifier = @charid AND id = @id;',
    }

elseif Config.SQL == 'gum_stables' then
    SQL.Columns.Comps = {
        Extra = 'comp_extras',
        LanternPropsets = 'comp_lantern',
        Livery = 'comp_liveries',
        Tint = 'comp_tints',
        Propset = 'comp_propset',
    }
    SQL.Insert = 'INSERT INTO wagons (identifier, charid, selected, model, name, cityPosition, addonArray, damage_wheel, animals, health) VALUES (@identifier, @charid, 0, @model, @name, @stable, "[]", "{}", "[]", @health);'
    SQL.Update = 'UPDATE wagons SET comp_extras = @extra, comp_lantern = @lantern, comp_liveries = @livery, comp_tints = @tint, comp_propset = @propset WHERE identifier = @identifier AND charid = @charid AND id = @id;'
    SQL.ColumnNull = 'none' -- Choose value of cart modifications columns when removed (SQL.Columns.Comps is table)

elseif Config.SQL == 'kd_stables' then
    SQL = {
        Columns = {
            Id = 'id',
            Model = 'model',
            Comps = {
                Extra = 'vehicle_extras',
                LanternPropsets = 'vehicle_lantern_propsets',
                Livery = 'vehicle_liveries',
                Tint = 'vehicle_tints',
                Propset = 'vehicle_propsets',
            },
            Health = 'health',
        },
        Select = 'SELECT * FROM kd_wagons WHERE identifier = @identifier AND charid = @charid;',
        Update = 'UPDATE kd_wagons SET vehicle_extras = @extra, vehicle_lantern_propsets = @lantern, vehicle_liveries = @livery, vehicle_tints = @tint, vehicle_propsets = @propset WHERE identifier = @identifier AND charid = @charid AND id = @id;',
        Insert = function(Source, Name, Model, Health, stable, stable2)
            TriggerEvent('kd_stable:server:AddNewWagon', Source, stable, Model, Name)
        end,
        Selected = 'SELECT * FROM kd_wagons WHERE identifier = @identifier AND charid = @charid AND selected = 1;',
        SelectedId = 'SELECT * FROM kd_wagons WHERE identifier = @identifier AND charid = @charid AND id = @id;',   -- SELECT using in the event xakra_carts:ActiveCartId
        Health = 'UPDATE kd_wagons SET health = @health WHERE identifier = @identifier AND charid = @charid AND id = @id;',
        Loadouts = 'UPDATE kd_wagons SET loadouts = @loadouts WHERE identifier = @identifier AND charid = @charid AND id = @id;',
        ColumnNull = 0, -- Choose value of cart modifications columns when removed (SQL.Columns.Comps is table)
    }

elseif Config.SQL == 'SS-Stable' then
    SQL.Columns.Comps = 'components'
    SQL.ListComps = {   -- Cart comp list option names (SQL.Columns.Comps if not a table)
        tint = 'colors',
        extra = 'extra',
        liverie = 'livery',
        lantern_propsets = 'lights',
        propsets = 'props',
    }
    SQL.Update = 'UPDATE wagons SET components = @mods_encode WHERE identifier = @identifier AND charid = @charid AND id = @id;'
    SQL.Insert = [[
        INSERT INTO wagons (identifier, charid, selected, model, name, health, info, components) 
        VALUES (@identifier, @charid, 0, @model, @name, @health, '{"desc":"","stash":0,"price":0,"inventory":0,"label":"","gold":0}', '{"colors":false,"livery":false,"props":false,"lights":false}');
    ]]
    SQL.Selected = 'SELECT * FROM wagons WHERE identifier = @identifier AND charid = @charid AND selected = 1;'
    SQL.SelectedId = 'SELECT * FROM wagons WHERE identifier = @identifier AND charid = @charid AND id = @id;'  -- SELECT using in the event xakra_carts:ActiveCartId
end
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xakra-scripts.gitbook.io/xakra-scripts-docs/redm-docs/xakra_carts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
