-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.lua
More file actions
48 lines (40 loc) · 1.59 KB
/
server.lua
File metadata and controls
48 lines (40 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local RSGCore = exports['rsg-core']:GetCoreObject()
local Config = require 'config'
---@class HandbagItem
---@field model string The model name of the handbag
---@field item string The item name in the inventory
---@field label string The display name of the handbag
---@field weight number Weight of the item
---@field description string Description of the item
-- Register all handbags dynamically
CreateThread(function()
-- First add all items to the shared items
local itemsToAdd = {}
for _, handbag in ipairs(Config.Handbags) do
itemsToAdd[handbag.item] = {
name = handbag.item,
label = handbag.label,
weight = handbag.weight,
type = 'item',
image = handbag.model .. '.png',
unique = false,
useable = true,
shouldClose = true,
description = handbag.description
}
end
-- Add items to shared items
exports['rsg-core']:AddItems(itemsToAdd)
-- Register all handbags as usable items
for _, handbag in ipairs(Config.Handbags) do
RSGCore.Functions.CreateUseableItem(handbag.item, function(source, item)
local src = source
local Player = RSGCore.Functions.GetPlayer(src)
if not Player then return end
-- Toggle the handbag on the player
TriggerClientEvent('bs-handbags:client:toggleBag', src, handbag.model)
end)
end
-- Log that the script has initialized
print('^2[bs-handbags]^7 Initialized with ' .. #Config.Handbags .. ' handbags')
end)