Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage authored Sep 17, 2023
2 parents f50ae36 + 1bb8931 commit 771a320
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 93 deletions.
73 changes: 8 additions & 65 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,6 @@ local CurrentGlovebox = nil
local CurrentStash = nil
local isCrafting = false
local isHotbar = false
local trunkSize = {
[0] = {
maxweight = 38000,
slots = 30
},
[1] = {
maxweight = 50000,
slots = 40
},
[2] = {
maxweight = 75000,
slots = 50
},
[3] = {
maxweight = 42000,
slots = 35
},
[4] = {
maxweight = 38000,
slots = 30
},
[5] = {
maxweight = 30000,
slots = 25
},
[6] = {
maxweight = 30000,
slots = 25
},
[7] = {
maxweight = 30000,
slots = 25
},
[8] = {
maxweight = 15000,
slots = 15
},
[9] = { -- default weight if no class is set
maxweight = 60000,
slots = 35
},
[12] = {
maxweight = 120000,
slots = 25
},
[13] = {
maxweight = 0,
slots = 0
},
[14] = {
maxweight = 120000,
slots = 50
},
[15] = {
maxweight = 120000,
slots = 50
},
[16] = {
maxweight = 120000,
slots = 50
}
}

--#endregion Variables

Expand Down Expand Up @@ -229,10 +167,9 @@ local function CloseTrunk()
SetVehicleDoorShut(vehicle, 5, false)
end
end

---Checks weight and size of the vehicle trunk
local function GetTrunkSize(vehicleClass)
if not trunkSize[vehicleClass] then vehicleClass = 9 end
local trunkSize = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace["default"]
return trunkSize[vehicleClass].maxweight, trunkSize[vehicleClass].slots
end
exports("GetTrunkSize", GetTrunkSize)
Expand Down Expand Up @@ -820,11 +757,17 @@ RegisterCommand('inventory', function()

if CurrentVehicle then -- Trunk
local vehicleClass = GetVehicleClass(curVeh)
local maxweight, slots = GetTrunkSize(vehicleClass)
local trunkConfig = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace["default"]
if not trunkConfig then return print("Cannot get the vehicle trunk config") end
local slots = trunkConfig.slots
local maxweight = trunkConfig.maxWeight
if not slots or not maxweight then return print("Cannot get the vehicle slots and maxweight") end

local other = {
maxweight = maxweight,
slots = slots,
}

TriggerServerEvent("inventory:server:OpenInventory", "trunk", CurrentVehicle, other)
OpenTrunk()
elseif CurrentGlovebox then
Expand Down
74 changes: 72 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Config = Config or {}
Config = {}

Config.UseTarget = GetConvar('UseTarget', 'false') == 'true' -- Use qb-target interactions (don't change this, go to your server.cfg and add `setr UseTarget true` to use this and just that from true to false or the other way around)

Expand Down Expand Up @@ -46,6 +46,76 @@ Config.VendingItem = {
},
}

-- See the vehicle class here: https://docs.fivem.net/natives/?_0x29439776AAA00A62
-- The template:
-- [vehicleClass] = {slots = [number], maxWeight = [number]}
Config.TrunkSpace = {
["default"] = { -- All the vehicle class that not listed here will use this as default
slots = 35,
maxWeight = 60000
},
[0] = { -- Compacts
slots = 30,
maxWeight = 38000
},
[1] = { -- Sedans
slots = 40,
maxWeight = 50000
},
[2] = { -- SUVs
slots = 50,
maxWeight = 75000
},
[3] = { -- Coupes
slots = 35,
maxWeight = 42000
},
[4] = { -- Muscle
slots = 30,
maxWeight = 38000
},
[5] = { -- Sports Classics
slots = 25,
maxWeight = 30000
},
[6] = { -- Sports
slots = 25,
maxWeight = 30000
},
[7] = { -- Super
slots = 25,
maxWeight = 30000
},
[8] = { -- Motorcycles
slots = 15,
maxWeight = 15000
},
[9] = { -- Off-road
slots = 35,
maxWeight = 60000
},
[12] = { -- Vans
slots = 35,
maxWeight = 120000
},
[13] = { -- Cycles
slots = 0,
maxWeight = 0
},
[14] = { -- Boats
slots = 50,
maxWeight = 120000
},
[15] = { -- Helicopters
slots = 50,
maxWeight = 120000
},
[16] = { -- Planes
slots = 50,
maxWeight = 120000
},
}

Config.CraftingItems = {
[1] = {
name = "lockpick",
Expand Down Expand Up @@ -384,4 +454,4 @@ Config.MaximumAmmoValues = {
["smg"] = 250,
["shotgun"] = 200,
["rifle"] = 250,
}
}
52 changes: 26 additions & 26 deletions qb-inventory.sql
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
CREATE TABLE IF NOT EXISTS `gloveboxitems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`plate` varchar(255) DEFAULT NULL,
`items` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`plate`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
`items` json DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `plate` (`plate`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `stashitems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`stash` varchar(255) DEFAULT NULL,
`items` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`stash`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
`items` json DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `stash` (`stash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `trunkitems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`plate` varchar(255) DEFAULT NULL,
`items` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`plate`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
`items` json DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `plate` (`plate`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `player_vehicles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`license` varchar(50) DEFAULT NULL,
`citizenid` varchar(50) DEFAULT NULL,
`vehicle` varchar(50) DEFAULT NULL,
`hash` varchar(50) DEFAULT NULL,
`mods` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`mods` json DEFAULT NULL,
`plate` varchar(50) NOT NULL,
`fakeplate` varchar(50) DEFAULT NULL,
`garage` varchar(50) DEFAULT NULL,
`fuel` int(11) DEFAULT 100,
`fuel` int DEFAULT 100,
`engine` float DEFAULT 1000,
`body` float DEFAULT 1000,
`state` int(11) DEFAULT 1,
`depotprice` int(11) NOT NULL DEFAULT 0,
`drivingdistance` int(50) DEFAULT NULL,
`state` int DEFAULT 1,
`depotprice` int NOT NULL DEFAULT 0,
`drivingdistance` int DEFAULT NULL,
`status` text DEFAULT NULL,
`balance` int(11) NOT NULL DEFAULT 0,
`paymentamount` int(11) NOT NULL DEFAULT 0,
`paymentsleft` int(11) NOT NULL DEFAULT 0,
`financetime` int(11) NOT NULL DEFAULT 0,
`balance` int NOT NULL DEFAULT 0,
`paymentamount` int NOT NULL DEFAULT 0,
`paymentsleft` int NOT NULL DEFAULT 0,
`financetime` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `plate` (`plate`),
KEY `citizenid` (`citizenid`),
KEY `license` (`license`)
) ENGINE=InnoDB AUTO_INCREMENT=1;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

0 comments on commit 771a320

Please sign in to comment.