Shop Account

Instructions on using mechanic shop account in other resources

The resource offers a custom account system that is standalone and not dependent on frameworks.

Get Shop ID

You can get the player's mechanic shop id with this export:

local src = source
local shopID = exports['t1ger_mechanicsystem']:GetPlayerMechId(src)
-- src(INT): player server id

Add Account Money

Requires: Mechanic Shop ID (use exports to get the ID based on player's server id or player's job name)

exports['t1ger_mechanicsystem']:PlusMechanicAccount(shopId, amount)
-- shopId(INT): mechanic shop id
-- amount(INT): amount of money to add to the account

Remove Account Money

Requires: Mechanic Shop ID (use exports to get the ID based on player's server id or player's job name)

exports['t1ger_mechanicsystem']:MinusMechanicAccount(shopId, amount)
-- shopId(INT): mechanic shop id
-- amount(INT): amount of money to add to the account

Usage - Example #1

Here's an example to easily add/remove money from a mechanic shop:

local src = source -- player server id
local amount = 5000 -- how much should be added/removed? 

-- export to get the shop id based on player server id:
local shopId = exports['t1ger_mechanicsystem']:GetPlayerMechId(src)

-- add money:
exports['t1ger_mechanicsystem']:PlusMechanicAccount(shopId, amount)

-- remove oney:
exports['t1ger_mechanicsystem']:MinusMechanicAccount(shopId, amount)

Usage - Example #2

Here's an alternative example using TriggerEvent (similar to esx_addonaccount)

local playerJob = 't1mechanic' -- add function/export to get the player's job here. 
local amount = 5000 -- how much should be added/removed? 

TriggerEvent('mechanicsystem:server:getPlayerMechanicShop', playerJob, function(mechanicShop)
    -- remove money:
    if mechanicShop.account >= amount then
        exports['t1ger_mechanicsystem']:MinusMechanicAccount(mechanicShop.id, amount)
    else
        print("not enough money")
    end
    
    -- add money:
    exports['t1ger_mechanicsystem']:PlusMechanicAccount(mechanicShop.id, amount)
end)

Last updated