Entity fix and stash update
Slimed OpenStash down to just an src and id instead of needing duplicate data. Was not sure if this affects newb so im throwing it in a pr.
This commit is contained in:
1 parent
68e81b720a
commit
0d606bc859
10 files changed
+109
-18
No files matched your search
@@ -20,7 +20,7 @@ local function SpawnEntity(entityData)
|
|||||||
|
|
||||||
local entity = nil
|
local entity = nil
|
||||||
local coords = entityData.coords
|
local coords = entityData.coords
|
||||||
local rotation = entityData.rotation
|
local rotation = entityData.rotation or vector3(0.0, 0.0, 0.0) -- Default rotation if not provided
|
||||||
|
|
||||||
if entityData.entityType == 'object' then
|
if entityData.entityType == 'object' then
|
||||||
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
|
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
|
||||||
@@ -40,7 +40,7 @@ local function SpawnEntity(entityData)
|
|||||||
SetModelAsNoLongerNeeded(model)
|
SetModelAsNoLongerNeeded(model)
|
||||||
SetEntityAsMissionEntity(entity, true, true) -- Keep entity from being deleted by game engine
|
SetEntityAsMissionEntity(entity, true, true) -- Keep entity from being deleted by game engine
|
||||||
FreezeEntityPosition(entity, true) -- Optional freeze based on meta
|
FreezeEntityPosition(entity, true) -- Optional freeze based on meta
|
||||||
if entityData.OnSpawn and type(entityData.OnSpawn) == 'function' then
|
if entityData.OnSpawn then
|
||||||
entityData.OnSpawn(entityData)
|
entityData.OnSpawn(entityData)
|
||||||
end
|
end
|
||||||
-- print(string.format("[ClientEntity] Spawned %s entity %s (GameID: %s)", entityData.entityType, entityData.id, entity))
|
-- print(string.format("[ClientEntity] Spawned %s entity %s (GameID: %s)", entityData.entityType, entityData.id, entity))
|
||||||
@@ -59,7 +59,7 @@ local function RemoveEntity(entityData)
|
|||||||
SetEntityAsMissionEntity(entityHandle, false, false)
|
SetEntityAsMissionEntity(entityHandle, false, false)
|
||||||
DeleteEntity(entityHandle)
|
DeleteEntity(entityHandle)
|
||||||
end
|
end
|
||||||
if entityData.OnRemove and type(entityData.OnRemove) == 'function' then
|
if entityData.OnRemove then
|
||||||
entityData.OnRemove(entityData)
|
entityData.OnRemove(entityData)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
if GetResourceState('codem-inventory') ~= 'started' then return end
|
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
local codem = exports['codem-inventory']
|
local codem = exports['codem-inventory']
|
||||||
|
|
||||||
@@ -104,10 +105,16 @@ end
|
|||||||
---@param groups table
|
---@param groups table
|
||||||
---@param coords table
|
---@param coords table
|
||||||
---@return nil
|
---@return nil
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id)
|
||||||
|
local stash = Inventory.Stashes[id]
|
||||||
|
assert(stash, "Stash not found", id)
|
||||||
|
local label = stash.label
|
||||||
|
local slots = stash.slots
|
||||||
|
local weight = stash.weight
|
||||||
TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = label, slots = slots, weight = weight })
|
TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = label, slots = slots, weight = weight })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---This will register a stash
|
---This will register a stash
|
||||||
---@param id number||string
|
---@param id number||string
|
||||||
---@param label string
|
---@param label string
|
||||||
@@ -118,6 +125,16 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
if Inventory.Stashes[id] then return true end
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = slots,
|
||||||
|
weight = weight,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
if GetResourceState('core_inventory') ~= 'started' then return end
|
if GetResourceState('core_inventory') ~= 'started' then return end
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
local core = exports.core_inventory
|
local core = exports.core_inventory
|
||||||
|
|
||||||
---This will add an item, and return true or false based on success
|
---This will add an item, and return true or false based on success
|
||||||
@@ -133,10 +133,10 @@ end
|
|||||||
---@param groups table
|
---@param groups table
|
||||||
---@param coords table
|
---@param coords table
|
||||||
---@return nil
|
---@return nil
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id)
|
||||||
if not slots then slots = 30 end
|
local stash = Inventory.Stashes[id]
|
||||||
local mathyShit = slots / 2
|
assert(stash, "Stash not found", id)
|
||||||
core:openInventory(playerid, id, 'stash', mathyShit, mathyShit, true, nil, false)
|
core:openInventory(src, id, 'stash', stash.slots, stash.weight, true, nil, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will register a stash
|
---This will register a stash
|
||||||
@@ -149,8 +149,18 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
if Inventory.Stashes[id] then return true end
|
||||||
if not slots then slots = 30 end
|
if not slots then slots = 30 end
|
||||||
local mathyShit = slots / 2
|
local mathyShit = slots / 2
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = mathyShit,
|
||||||
|
weight = mathyShit,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false)
|
core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ local jpr = exports['jpr-inventory']
|
|||||||
local registeredShops = {}
|
local registeredShops = {}
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
---This will add an item, and return true or false based on success
|
---This will add an item, and return true or false based on success
|
||||||
---@param src number
|
---@param src number
|
||||||
@@ -70,8 +71,10 @@ end
|
|||||||
---@param groups table
|
---@param groups table
|
||||||
---@param coords table
|
---@param coords table
|
||||||
---@return nil
|
---@return nil
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id)
|
||||||
TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = weight, slots = slots })
|
local stash = Inventory.Stashes[id]
|
||||||
|
assert(stash, "Stash not found", id)
|
||||||
|
TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = stash.weight, slots = stash.slots })
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will register a stash
|
---This will register a stash
|
||||||
@@ -84,6 +87,16 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
if Inventory.Stashes[id] then return true end
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = slots,
|
||||||
|
weight = weight,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
if GetResourceState('origen_inventory') ~= 'started' then return end
|
if GetResourceState('origen_inventory') ~= 'started' then return end
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
local origin = exports.origen_inventory
|
local origin = exports.origen_inventory
|
||||||
|
|
||||||
@@ -107,7 +108,9 @@ end
|
|||||||
---@param groups table
|
---@param groups table
|
||||||
---@param coords table
|
---@param coords table
|
||||||
---@return nil
|
---@return nil
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id)
|
||||||
|
local stash = Inventory.Stashes[id]
|
||||||
|
assert(stash, "Stash not found", id)
|
||||||
return origin:OpenInventory(src, 'stash', id)
|
return origin:OpenInventory(src, 'stash', id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,6 +124,16 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
if Inventory.Stashes[id] then return true end
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = slots,
|
||||||
|
weight = weight,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
return origin:registerStash(id, label, slots, weight, owner, groups, coords)
|
return origin:registerStash(id, label, slots, weight, owner, groups, coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ local ox_inventory = exports.ox_inventory
|
|||||||
local registeredShops = {}
|
local registeredShops = {}
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
---This will add an item, and return true or false based on success
|
---This will add an item, and return true or false based on success
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param item string
|
---@param item string
|
||||||
@@ -94,8 +94,9 @@ end
|
|||||||
---@param groups table
|
---@param groups table
|
||||||
---@param coords table
|
---@param coords table
|
||||||
---@return nil
|
---@return nil
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id)
|
||||||
TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id)
|
assert(Inventory.Stashes[id], "Stash not found", id)
|
||||||
|
TriggerClientEvent('ox_inventory:openInventory', src, 'stash', id)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will register a stash
|
---This will register a stash
|
||||||
@@ -108,7 +109,17 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
return ox_inventory:RegisterStash(id, label, slots, weight, owner)
|
if Inventory.Stashes[id] then return true end
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = slots,
|
||||||
|
weight = weight,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
|
return ox_inventory:RegisterStash(id, label, slots, weight, owner, groups)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a boolean if the player has the item.
|
---This will return a boolean if the player has the item.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local sloth = exports['ps-inventory']
|
|||||||
local registeredShops = {}
|
local registeredShops = {}
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
---This will add an item, and return true or false based on success
|
---This will add an item, and return true or false based on success
|
||||||
---@param src number
|
---@param src number
|
||||||
@@ -106,6 +107,16 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
if Inventory.Stashes[id] then return true end
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = slots,
|
||||||
|
weight = weight,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ if GetResourceState('qb-inventory') ~= 'started' then return end
|
|||||||
local qbInventory = exports['qb-inventory']
|
local qbInventory = exports['qb-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
local registeredShops = {}
|
local registeredShops = {}
|
||||||
local v1ShopData = {}
|
local v1ShopData = {}
|
||||||
@@ -85,8 +86,11 @@ end
|
|||||||
---@param groups table
|
---@param groups table
|
||||||
---@param coords table
|
---@param coords table
|
||||||
---@return nil
|
---@return nil
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id)
|
||||||
TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots })
|
local stash = Inventory.Stashes[id]
|
||||||
|
assert(stash, "Stash not found", id)
|
||||||
|
|
||||||
|
TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = stash.weight, slots = stash.slots})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will register a stash
|
---This will register a stash
|
||||||
@@ -99,6 +103,16 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
if Inventory.Stashes[id] then return true end
|
||||||
|
Inventory.Stashes[id] = {
|
||||||
|
id = id,
|
||||||
|
label = label,
|
||||||
|
slots = slots,
|
||||||
|
weight = weight,
|
||||||
|
owner = owner,
|
||||||
|
groups = groups,
|
||||||
|
coords = coords
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ if GetResourceState('qs-inventory') ~= 'started' then return end
|
|||||||
local quasar = exports['qs-inventory']
|
local quasar = exports['qs-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
---This will add an item, and return true or false based on success
|
---This will add an item, and return true or false based on success
|
||||||
---@param src number
|
---@param src number
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
|||||||
local tgiann = exports["tgiann-inventory"]
|
local tgiann = exports["tgiann-inventory"]
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
Inventory.Stashes = Inventory.Stashes or {}
|
||||||
|
|
||||||
---This will add an item, and return true or false based on success
|
---This will add an item, and return true or false based on success
|
||||||
---@param src number
|
---@param src number
|
||||||
|
|||||||
Reference in new issue
Block a user