onStockWithdrawnFromShop
Last updated
Last updated
exports['sd-shops']:registerServerHook('onStockWithdrawnFromShop', function(data)
-- Log withdrawal
print(('[STOCK] %s withdrew %dx %s from %s (Stock: %d -> %d)'):format(
data.withdrawnBy, data.quantity, data.itemLabel,
data.shopName, data.previousStock, data.newStock
))
-- Log potential theft/misuse for auditing
exports['your-logging']:Log('stock-withdrawal', {
shop = data.shopName,
item = data.itemLabel,
quantity = data.quantity,
previousStock = data.previousStock,
newStock = data.newStock,
withdrawnBy = data.withdrawnBy,
withdrawnById = data.withdrawnByIdentifier
})
-- Alert for large withdrawals
if data.quantity >= 50 then
exports['your-logging']:Log('large-withdrawal-alert', {
shop = data.shopName,
item = data.itemLabel,
quantity = data.quantity,
by = data.withdrawnBy
})
end
end)