
π§ How to Install
FiveStar Script
Requirements
Insert SQL
Note
Last updated

FiveStar Script
Last updated
function client.closeInventory(server)
exports["FiveStar-MissionClub"]:closeInventory()
-- ....
end---Closes the inventory NUI
local function closeInventory()
exports["FiveStar-MissionClub"]:closeInventory()
SendNUIMessage({
action = "close",
})
end
RegisterNUICallback("CloseInventory", function()
exports["FiveStar-MissionClub"]:closeInventory()
...
end)RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other, items)
local src = source
local ply = Player(src)
local Player = QBCore.Functions.GetPlayer(src)
if not ply.state.inv_busy then
if name and id then
local secondInv = {}
if name == "stash" then
if Stashes[id] then
if Stashes[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
else
Stashes[id].isOpen = false
end
end
end
local maxweight = 1000000
local slots = 50
if other then
maxweight = other.maxweight or 1000000
slots = other.slots or 50
end
secondInv.name = "stash-"..id
secondInv.label = "Stash-"..id
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
if Stashes[id] and Stashes[id].isOpen then
secondInv.name = "none-inv"
secondInv.label = "Stash-None"
secondInv.maxweight = 1000000
secondInv.inventory = {}
secondInv.slots = 0
else
local stashItems = GetStashItems(id)
if next(stashItems) then
secondInv.inventory = stashItems
Stashes[id] = {}
Stashes[id].items = stashItems
Stashes[id].isOpen = src
Stashes[id].label = secondInv.label
else
Stashes[id] = {}
Stashes[id].items = {}
Stashes[id].isOpen = src
Stashes[id].label = secondInv.label
end
end
if items then
for i, v in ipairs(items) do
local itemInfo = QBCore.Shared.Items[v.Name]
if itemInfo then
table.insert(secondInv.inventory, {
useable = itemInfo["useable"],
unique = itemInfo["unique"],
name = itemInfo["name"],
amount = v.Count,
slot = i,
image = itemInfo["image"],
weight = itemInfo["weight"],
type = itemInfo["type"],
info = {
quality = 100
},
label = itemInfo["label"],
description = itemInfo["description"] or "",
})
else
print("^8warning: The desired item["..v.Name.."] was not found, please register it in qb-core/shared/items.lua ^0")
end
end
end
elseif name == "trunk" then
if Trunks[id] then
if Trunks[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Trunks[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Trunks[id].isOpen, name, id, Trunks[id].label)
else
Trunks[id].isOpen = false
end
end
end
secondInv.name = "trunk-"..id
secondInv.label = "Trunk-"..id
secondInv.maxweight = other.maxweight or 60000
secondInv.inventory = {}
secondInv.slots = other.slots or 50
if (Trunks[id] and Trunks[id].isOpen) or (QBCore.Shared.SplitStr(id, "PLZI")[2] and Player.PlayerData.job.name ~= "police") then
secondInv.name = "none-inv"
secondInv.label = "Trunk-None"
secondInv.maxweight = other.maxweight or 60000
secondInv.inventory = {}
secondInv.slots = 0
else
if id then
local ownedItems = GetOwnedVehicleItems(id)
if IsVehicleOwned(id) and next(ownedItems) then
secondInv.inventory = ownedItems
Trunks[id] = {}
Trunks[id].items = ownedItems
Trunks[id].isOpen = src
Trunks[id].label = secondInv.label
elseif Trunks[id] and not Trunks[id].isOpen then
secondInv.inventory = Trunks[id].items
Trunks[id].isOpen = src
Trunks[id].label = secondInv.label
else
Trunks[id] = {}
Trunks[id].items = {}
Trunks[id].isOpen = src
Trunks[id].label = secondInv.label
end
end
end
elseif name == "glovebox" then
if Gloveboxes[id] then
if Gloveboxes[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Gloveboxes[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Gloveboxes[id].isOpen, name, id, Gloveboxes[id].label)
else
Gloveboxes[id].isOpen = false
end
end
end
secondInv.name = "glovebox-"..id
secondInv.label = "Glovebox-"..id
secondInv.maxweight = 10000
secondInv.inventory = {}
secondInv.slots = 5
if Gloveboxes[id] and Gloveboxes[id].isOpen then
secondInv.name = "none-inv"
secondInv.label = "Glovebox-None"
secondInv.maxweight = 10000
secondInv.inventory = {}
secondInv.slots = 0
else
local ownedItems = GetOwnedVehicleGloveboxItems(id)
if Gloveboxes[id] and not Gloveboxes[id].isOpen then
secondInv.inventory = Gloveboxes[id].items
Gloveboxes[id].isOpen = src
Gloveboxes[id].label = secondInv.label
elseif IsVehicleOwned(id) and next(ownedItems) then
secondInv.inventory = ownedItems
Gloveboxes[id] = {}
Gloveboxes[id].items = ownedItems
Gloveboxes[id].isOpen = src
Gloveboxes[id].label = secondInv.label
else
Gloveboxes[id] = {}
Gloveboxes[id].items = {}
Gloveboxes[id].isOpen = src
Gloveboxes[id].label = secondInv.label
end
end
elseif name == "shop" then
secondInv.name = "itemshop-"..id
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = SetupShopItems(other.items)
ShopItems[id] = {}
ShopItems[id].items = other.items
secondInv.slots = #other.items
elseif name == "traphouse" then
secondInv.name = "traphouse-"..id
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = other.items
secondInv.slots = other.slots
elseif name == "crafting" then
secondInv.name = "crafting"
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = other.items
secondInv.slots = #other.items
elseif name == "attachment_crafting" then
secondInv.name = "attachment_crafting"
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = other.items
secondInv.slots = #other.items
elseif name == "otherplayer" then
local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(id))
if OtherPlayer then
secondInv.name = "otherplayer-"..id
secondInv.label = "Player-"..id
secondInv.maxweight = Config.MaxInventoryWeight
secondInv.inventory = OtherPlayer.PlayerData.items
if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
secondInv.slots = Config.MaxInventorySlots
else
secondInv.slots = Config.MaxInventorySlots - 1
end
Wait(250)
end
else
if Drops[id] then
if Drops[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Drops[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Drops[id].isOpen, name, id, Drops[id].label)
else
Drops[id].isOpen = false
end
end
end
if Drops[id] and not Drops[id].isOpen then
secondInv.coords = Drops[id].coords
secondInv.name = id
secondInv.label = "Dropped-"..tostring(id)
secondInv.maxweight = 100000
secondInv.inventory = Drops[id].items
secondInv.slots = 30
Drops[id].isOpen = src
Drops[id].label = secondInv.label
Drops[id].createdTime = os.time()
else
secondInv.name = "none-inv"
secondInv.label = "Dropped-None"
secondInv.maxweight = 100000
secondInv.inventory = {}
secondInv.slots = 0
end
end
TriggerClientEvent("qb-inventory:client:closeinv", id)
TriggerClientEvent("inventory:client:OpenInventory", src, {}, Player.PlayerData.items, secondInv)
else
TriggerClientEvent("inventory:client:OpenInventory", src, {}, Player.PlayerData.items)
end
else
TriggerClientEvent('QBCore:Notify', src, 'Not Accessible', 'error')
end
end)Config.CreateBag = {
ShowInvetory = function(_, Identifier)
local BagID = Config.CreateBag.Data.label.. " ["..math.random(1, 999).."]"
TriggerServerEvent('inventory:server:OpenInventory', 'stash', BagID, {
maxweight = Config.CreateBag.Data.weight,
slots = Config.CreateBag.Data.slots,
}, Config.CreateBag.Items)
TriggerEvent('inventory:client:SetCurrentStash', BagID)
end,
Data = {
label = "Matteo Malleri ",
slots = 50,
weight = 120000
},
Items = { -- ? Add items to the bag here
{
Name = "crypto_hardware",
Count = 1,
customer = 2
}, {
Name = "diamond",
Count = 8,
customer = 1
}, {
Name = "gold",
Count = 3,
customer = 2
}, {
Name = "laptop",
Count = 2,
customer = 3
}, {
Name = "rolex",
Count = 1,
customer = 2
}, {
Name = "platinum",
Count = 2,
customer = 1
}, {
Name = "phone",
Count = 1
}, {
Name = "bread",
Count = 2
}, {
Name = "water",
Count = 1
}},
RegisterBag = function(BagID, Identifier)
-- No need for qb
end,
ReceivedTheItemsAndExitedTheGame = function(xPlayer, Cutscene) -- Cutscene --- @param [0], [1], [2], [3]
-- ! The player is out of the game
if Cutscene == 0 then -- If Cutscene equals 0, it means that none of the items have been delivered
-- Remove player inventory item Mission 0/3
-- xPlayer.Functions.ClearInventory()
elseif Cutscene == 1 then
-- Remove player inventory item Mission 1/3
-- xPlayer.Functions.ClearInventory()
elseif Cutscene == 2 then
-- Remove player inventory item Mission 2/3
-- xPlayer.Functions.ClearInventory()
elseif Cutscene == 3 then
-- Remove player inventory item Mission 3/3
-- xPlayer.Functions.ClearInventory()
end
end
}