-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathserver.lua
67 lines (59 loc) · 1.71 KB
/
server.lua
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
local GetCurrentResourceName = GetCurrentResourceName()
local ox_inventory = exports.ox_inventory
-- These stashes are all created on resource start
local stashes = {
{
-- Police stash
id = 'example_stash',
label = 'Police Stash',
slots = 50,
weight = 100000,
owner = false,
jobs = 'police'
},
{
-- Owned stash
id = 'example_stash_2',
label = 'Stash',
slots = 50,
weight = 100000,
owner = 'bobsmith',
},
{
-- Personal stashes
id = 'example_stash_3',
label = 'Stash',
slots = 50,
weight = 100000,
owner = true,
},
}
AddEventHandler('onServerResourceStart', function(resourceName)
if resourceName == 'ox_inventory' or resourceName == GetCurrentResourceName then
for i=1, #stashes do
local stash = stashes[i]
ox_inventory:RegisterStash(stash.id, stash.label, stash.slots, stash.weight, stash.owner, stash.jobs)
end
end
Wait(500)
local inventory = ox_inventory:GetInventory({id = 'example_stash_3', owner = 115})
ox_inventory:AddItem(inventory.id, 'water', 1)
end)
-- Register this stash only when this event is called
RegisterNetEvent('ox:lazyStash', function()
ox_inventory:RegisterStash('lazyStash', 'Stash', 20, 20000, true)
end)
exports('testburger', function(event, item, inventory, slot, data)
if event == 'usingItem' then
if ox_inventory:GetItem(inventory, item, inventory.items[slot].metadata, true) > 0 then
-- if we return false here, we can cancel item use
return {
inventory.label, event, 'external item use poggies'
}
end
elseif event == 'usedItem' then
print(('%s just ate a %s from slot %s'):format(inventory.label, item.label, slot))
elseif event == 'buying' then
print(data.id, data.coords, json.encode(data.items[slot], {indent=true}))
end
end)