📩Exports - Server side

Get current Price

-- Single item
local price = exports['PS_Economic_system']:getCurrentPrice('copperore')
if price then
    print('Price for copperore:', price)
end

-- Multiple items
local prices = exports['PS_Economic_system']:getCurrentPrice({'copperore', 'ironore', 'goldore'})
for item, price in pairs(prices) do
    print('Price for ' .. item .. ': ' .. price)
end

Example: 

function GetPrice(item)

    local price = exports['PS_Economic_system']:getCurrentPrice(item)
    
    print("The current price of "..item.. "is "..price)
    
    return price 
end

Get Stock

-- Single item
local stock = exports['PS_Economic_system']:GetStock('copperore')
if stock then
    print('Stock of copperore:', stock)
end

-- Multiple items
local stocks = exports['PS_Economic_system']:GetStock({'copperore', 'ironore'})
for item, amount in pairs(stocks) do
    print('Stock of ' .. item .. ': ' .. amount)
end

Example:
function GetStock(item)

    local stock = exports['PS_Economic_system']:GetStock('copperore')
    
    print("The current stock of "..item.. "is "..stock)
    
    return stock 
end

Add Stock

-- Single item
exports['PS_Economic_system']:AddStock({name = 'copperore', amount = 50})

-- Multiple items
exports['PS_Economic_system']:AddStock({
    {name = 'copperore', amount = 50},
    {name = 'ironore', amount = 25},
    {name = 'goldore', amount = 10}
})

Example:
function AddStock(item, amount)

    exports['PS_Economic_system']:AddStock({name = item, amount = amount})
    
    print("Added "..amount.." of "..item.."to the stock")

end

Remove Stock

-- Single item
exports['PS_Economic_system']:RemoveStock({name = 'copperore', amount = 50})

-- Multiple items
exports['PS_Economic_system']:RemoveStock({
    {name = 'copperore', amount = 50},
    {name = 'ironore', amount = 25},
    {name = 'goldore', amount = 10}
})

Example:
function RemoveStock(item, amount)

    exports['PS_Economic_system']:RemoveStock({name = item, amount = amount})
    
    print("Removed "..amount.." of "..item.."from the stock")

end

Record Sold Items

-- Single item
exports['PS_Economic_system']:SelledItem({
    name = 'copperore',
    amount = 50
})

-- Multiple items
exports['PS_Economic_system']:SelledItem({
    {name = 'copperore', amount = 50},
    {name = 'ironore', amount = 25},
    {name = 'goldore', amount = 10}
})

function ItemSelled(item, amount)

exports['PS_Economic_system']:SelledItem({name = item, amount = amount})

end 

Last updated